Back to index

unity  6.0.0
PanelMenuView.h
Go to the documentation of this file.
00001 // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
00002 /*
00003  * Copyright (C) 2010-2012 Canonical Ltd
00004  *
00005  * This program is free software: you can redistribute it and/or modify
00006  * it under the terms of the GNU General Public License version 3 as
00007  * published by the Free Software Foundation.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00016  *
00017  * Authored by: Neil Jagdish Patel <neil.patel@canonical.com>
00018  *              Marco Trevisan <3v1n0@ubuntu.com>
00019  */
00020 
00021 #ifndef PANEL_MENU_VIEW_H
00022 #define PANEL_MENU_VIEW_H
00023 
00024 #include <UnityCore/GLibWrapper.h>
00025 #include <UnityCore/GLibSignal.h>
00026 #include <libbamf/libbamf.h>
00027 
00028 #include "PanelIndicatorsView.h"
00029 #include "unity-shared/StaticCairoText.h"
00030 #include "WindowButtons.h"
00031 #include "PanelTitlebarGrabAreaView.h"
00032 #include "unity-shared/PluginAdapter.h"
00033 #include "unity-shared/Animator.h"
00034 #include "unity-shared/UBusWrapper.h"
00035 
00036 namespace unity
00037 {
00038 
00039 class PanelMenuView : public PanelIndicatorsView
00040 {
00041 public:
00042   PanelMenuView();
00043   ~PanelMenuView();
00044 
00045   void SetMenuShowTimings(int fadein, int fadeout, int discovery,
00046                           int discovery_fadein, int discovery_fadeout);
00047 
00048   void SetMousePosition(int x, int y);
00049   void SetMonitor(int monitor);
00050 
00051   Window GetTopWindow() const;
00052   Window GetMaximizedWindow() const;
00053   bool GetControlsActive() const;
00054 
00055   void NotifyAllMenusClosed();
00056 
00057   virtual void AddIndicator(indicator::Indicator::Ptr const& indicator);
00058 
00059   virtual void OverlayShown();
00060   virtual void OverlayHidden();
00061 
00062 protected:
00063   std::string GetName() const;
00064   void AddProperties(GVariantBuilder* builder);
00065 
00066   virtual void Draw(nux::GraphicsEngine& GfxContext, bool force_draw);
00067   virtual void DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw);
00068   virtual void PreLayoutManagement();
00069   virtual nux::Area* FindAreaUnderMouse(const nux::Point& mouse_position,
00070                                         nux::NuxEventType event_type);
00071   virtual void OnEntryAdded(indicator::Entry::Ptr const& entry);
00072 
00073 private:
00074   void OnActiveChanged(PanelIndicatorEntryView* view, bool is_active);
00075   void OnViewOpened(BamfMatcher* matcher, BamfView* view);
00076   void OnViewClosed(BamfMatcher* matcher, BamfView* view);
00077   void OnApplicationClosed(BamfApplication* app);
00078   void OnActiveWindowChanged(BamfMatcher* matcher, BamfView* old_view, BamfView* new_view);
00079   void OnActiveAppChanged(BamfMatcher* matcher, BamfApplication* old_app, BamfApplication* new_app);
00080   void OnNameChanged(BamfView* bamf_view, gchar* new_name, gchar* old_name);
00081 
00082   void OnSpreadInitiate();
00083   void OnSpreadTerminate();
00084   void OnExpoInitiate();
00085   void OnExpoTerminate();
00086   void OnWindowMinimized(guint32 xid);
00087   void OnWindowUnminimized(guint32 xid);
00088   void OnWindowUnmapped(guint32 xid);
00089   void OnWindowMapped(guint32 xid);
00090   void OnWindowMaximized(guint32 xid);
00091   void OnWindowRestored(guint32 xid);
00092   void OnWindowMoved(guint32 xid);
00093   void OnWindowDecorated(guint32 xid);
00094   void OnWindowUndecorated(guint32 xid);
00095 
00096   void OnMaximizedActivate(int x, int y);
00097   void OnMaximizedRestore(int x, int y);
00098   void OnMaximizedLower(int x, int y);
00099   void OnMaximizedGrabStart(int x, int y);
00100   void OnMaximizedGrabMove(int x, int y);
00101   void OnMaximizedGrabEnd(int x, int y);
00102 
00103   void FullRedraw();
00104   void Refresh(bool force = false);
00105   void DrawTitle(cairo_t *cr_real, nux::Geometry const& geo, std::string const& label) const;
00106 
00107   void OnPanelViewMouseEnter(int x, int y, unsigned long mouse_button_state, unsigned long special_keys_state);
00108   void OnPanelViewMouseLeave(int x, int y, unsigned long mouse_button_state, unsigned long special_keys_state);
00109   void OnPanelViewMouseMove(int x, int y, int dx, int dy, unsigned long mouse_button_state, unsigned long special_keys_state);
00110 
00111   BamfWindow* GetBamfWindowForXid(Window xid) const;
00112 
00113   std::string GetActiveViewName(bool use_appname = false) const;
00114 
00115   void OnSwitcherShown(GVariant* data);
00116   void OnSwitcherSelectionChanged(GVariant* data);
00117   void OnLauncherKeyNavStarted(GVariant* data);
00118   void OnLauncherKeyNavEnded(GVariant* data);
00119   void OnLauncherSelectionChanged(GVariant* data);
00120 
00121   void UpdateShowNow(bool ignore);
00122 
00123   bool UpdateActiveWindowPosition();
00124   bool UpdateShowNowWithDelay();
00125   bool OnNewAppShow();
00126   bool OnNewAppHide();
00127 
00128   bool IsValidWindow(Window xid) const;
00129   bool IsWindowUnderOurControl(Window xid) const;
00130 
00131   bool DrawMenus() const;
00132   bool DrawWindowButtons() const;
00133 
00134   void OnFadeInChanged(double);
00135   void OnFadeOutChanged(double);
00136 
00137   glib::Object<BamfMatcher> _matcher;
00138 
00139   nux::TextureLayer* _title_layer;
00140   nux::HLayout* _menu_layout;
00141   nux::ObjectPtr<WindowButtons> _window_buttons;
00142   nux::ObjectPtr<PanelTitlebarGrabArea> _titlebar_grab_area;
00143   nux::ObjectPtr<nux::BaseTexture> _title_texture;
00144   nux::ObjectPtr<nux::IOpenGLBaseTexture> _gradient_texture;
00145 
00146   bool _is_inside;
00147   bool _is_grabbed;
00148   bool _is_maximized;
00149 
00150   PanelIndicatorEntryView* _last_active_view;
00151   glib::Object<BamfApplication> _new_application;
00152 
00153   std::map<Window, bool> _decor_map;
00154   std::set<Window> _maximized_set;
00155   std::list<glib::Object<BamfApplication>> _new_apps;
00156   std::string _panel_title;
00157   nux::Geometry _last_geo;
00158 
00159   bool _overlay_showing;
00160   bool _switcher_showing;
00161   bool _launcher_keynav;
00162   bool _show_now_activated;
00163   bool _we_control_active;
00164   bool _new_app_menu_shown;
00165 
00166   int _monitor;
00167   Window _active_xid;
00168   nux::Geometry _monitor_geo;
00169   const std::string _desktop_name;
00170 
00171   int _menus_fadein;
00172   int _menus_fadeout;
00173   int _menus_discovery;
00174   int _menus_discovery_fadein;
00175   int _menus_discovery_fadeout;
00176 
00177   glib::Signal<void, BamfMatcher*, BamfView*> _view_opened_signal;
00178   glib::Signal<void, BamfMatcher*, BamfView*> _view_closed_signal;
00179   glib::Signal<void, BamfMatcher*, BamfView*, BamfView*> _active_win_changed_signal;
00180   glib::Signal<void, BamfMatcher*, BamfApplication*, BamfApplication*> _active_app_changed_signal;
00181   glib::Signal<void, BamfView*, gchar*, gchar*> _view_name_changed_signal;
00182   sigc::connection _style_changed_connection;
00183 
00184   UBusManager _ubus_manager;
00185   glib::SourceManager _sources;
00186 
00187   Animator _fade_in_animator;
00188   Animator _fade_out_animator;
00189 };
00190 
00191 }
00192 
00193 #endif