Back to index

unity  6.0.0
HudController.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2010 Canonical Ltd
00003  *
00004  * This program is free software: you can redistribute it and/or modify
00005  * it under the terms of the GNU General Public License version 3 as
00006  * published by the Free Software Foundation.
00007  *
00008  * This program is distributed in the hope that it will be useful,
00009  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00010  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00011  * GNU General Public License for more details.
00012  *
00013  * You should have received a copy of the GNU General Public License
00014  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00015  *
00016  * Authored by: Neil Jagdish Patel <neil.patel@canonical.com>
00017  */
00018 
00019 #ifndef UNITYSHELL_HUD_CONTROLLER_H
00020 #define UNITYSHELL_HUD_CONTROLLER_H
00021 
00022 #include <functional>
00023 #include <memory>
00024 
00025 #include <gdk/gdk.h>
00026 #include <UnityCore/Hud.h>
00027 
00028 #include <NuxCore/Property.h>
00029 #include <NuxGraphics/GraphicsEngine.h>
00030 #include <Nux/Nux.h>
00031 #include <Nux/BaseWindow.h>
00032 
00033 #include "unity-shared/Animator.h"
00034 #include "unity-shared/UBusWrapper.h"
00035 #include "HudView.h"
00036 
00037 namespace unity
00038 {
00039 namespace hud
00040 {
00041 
00042 class Controller : public unity::debug::Introspectable
00043 {
00044 public:
00045   typedef std::shared_ptr<Controller> Ptr;
00046 
00047   Controller(std::function<AbstractView*(void)> const& function = []() { return new View; });
00048 
00049   nux::BaseWindow* window() const;
00050 
00051   nux::Property<int> launcher_width;
00052   nux::Property<int> icon_size;
00053   nux::Property<int> tile_size;
00054   nux::Property<bool> launcher_locked_out;
00055   nux::Property<bool> multiple_launchers;
00056 
00057   void ShowHideHud();
00058   void ShowHud();
00059   void HideHud(bool restore_focus = true);
00060   bool IsVisible();
00061 
00062 protected:
00063   // Introspectable
00064   std::string GetName() const;
00065   void AddProperties(GVariantBuilder* builder);
00066 
00067 private:
00068   void EnsureHud();
00069   void SetupWindow();
00070   void SetupHudView();
00071   void RegisterUBusInterests();
00072   void SetIcon(std::string const& icon_name);
00073 
00074   int GetTargetMonitor();
00075   bool IsLockedToLauncher(int monitor);
00076 
00077   nux::Geometry GetIdealWindowGeometry();
00078   void Relayout();
00079 
00080   void OnMouseDownOutsideWindow(int x, int y, unsigned long bflags, unsigned long kflags);
00081   void OnScreenUngrabbed();
00082   void OnExternalShowHud(GVariant* variant);
00083   void OnExternalHideHud(GVariant* variant);
00084   void OnActivateRequest(GVariant* variant);
00085 
00086   void OnSearchChanged(std::string search_string);
00087   void OnSearchActivated(std::string search_string);
00088   void OnQueryActivated(Query::Ptr query);
00089   void OnQuerySelected(Query::Ptr query);
00090 
00091   void StartShowHideTimeline();
00092   void OnViewShowHideFrame(double progress);
00093 
00094   static void OnWindowConfigure(int width, int height, nux::Geometry& geo, void* data);
00095 
00096   void OnQueriesFinished(Hud::Queries queries);
00097 
00098 private:
00099   nux::ObjectPtr<nux::BaseWindow> window_;
00100   UBusManager ubus;
00101   Hud hud_service_;
00102   bool visible_;
00103   bool need_show_;
00104 
00105   Animator timeline_animator_;
00106 
00107   AbstractView* view_;
00108   std::string focused_app_icon_;
00109   nux::Layout* layout_;
00110   uint monitor_index_;
00111   std::string last_search_;
00112 
00113   std::function<AbstractView*(void)> view_function_;
00114 };
00115 
00116 } // namespace hud
00117 } // namespace unity
00118 
00119 #endif // UNITYSHELL_HUD_CONTROLLER_H