Back to index

unity  6.0.0
DashController.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 UNITY_DASH_CONTROLLER_H_
00020 #define UNITY_DASH_CONTROLLER_H_
00021 
00022 #include <memory>
00023 
00024 #include <gdk/gdk.h>
00025 #include <UnityCore/GLibSignal.h>
00026 
00027 #include <NuxCore/Property.h>
00028 #include <NuxGraphics/GraphicsEngine.h>
00029 #include <Nux/Nux.h>
00030 #include <Nux/BaseWindow.h>
00031 
00032 #include "DashView.h"
00033 #include "unity-shared/Animator.h"
00034 #include "unity-shared/Introspectable.h"
00035 #include "unity-shared/UBusWrapper.h"
00036 
00037 namespace unity
00038 {
00039 namespace dash
00040 {
00041 
00042 class Controller : public unity::debug::Introspectable
00043 {
00044 public:
00045   typedef std::shared_ptr<Controller> Ptr;
00046 
00047   Controller();
00048 
00049   nux::BaseWindow* window() const;
00050 
00051   gboolean CheckShortcutActivation(const char* key_string);
00052   std::vector<char> GetAllShortcuts();
00053 
00054   nux::Property<int> launcher_width;
00055   nux::Property<bool> use_primary;
00056 
00057   sigc::signal<void> on_realize;
00058 
00059   void HideDash(bool restore_focus = true);
00060 
00061 protected:
00062   std::string GetName() const;
00063   void AddProperties(GVariantBuilder* builder);
00064 
00065 private:
00066   void EnsureDash();
00067   void SetupWindow();
00068   void SetupDashView();
00069   void SetupRelayoutCallbacks();
00070   void RegisterUBusInterests();
00071 
00072   nux::Geometry GetIdealWindowGeometry();
00073   int GetIdealMonitor();
00074   void Relayout(GdkScreen*screen=NULL);
00075 
00076   void OnMouseDownOutsideWindow(int x, int y, unsigned long bflags, unsigned long kflags);
00077   void OnScreenUngrabbed();
00078   void OnExternalShowDash(GVariant* variant);
00079   void OnExternalHideDash(GVariant* variant);
00080   void OnActivateRequest(GVariant* variant);
00081 
00082   void ShowDash();
00083 
00084   void StartShowHideTimeline();
00085   void OnViewShowHideFrame(double progress);
00086 
00087   static void OnWindowConfigure(int width, int height, nux::Geometry& geo, void* data);
00088 
00089 private:
00090   nux::ObjectPtr<nux::BaseWindow> window_;
00091   int monitor_;
00092 
00093   bool visible_;
00094   bool need_show_;
00095   DashView* view_;
00096 
00097   sigc::connection screen_ungrabbed_slot_;
00098   glib::SignalManager sig_manager_;
00099   glib::TimeoutSeconds ensure_timeout_;
00100   Animator timeline_animator_;
00101   UBusManager ubus_manager_;
00102 };
00103 
00104 
00105 }
00106 }
00107 #endif