Back to index

unity  6.0.0
PanelView.h
Go to the documentation of this file.
00001 // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
00002 /*
00003  * Copyright (C) 2010 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  */
00019 
00020 #ifndef PANEL_VIEW_H
00021 #define PANEL_VIEW_H
00022 
00023 #include <vector>
00024 #include <memory>
00025 
00026 #include <Nux/View.h>
00027 #include <Nux/TextureArea.h>
00028 #include <NuxGraphics/GraphicsEngine.h>
00029 #include <NuxGraphics/CairoGraphics.h>
00030 #include <gdk/gdkx.h>
00031 
00032 #include <UnityCore/DBusIndicators.h>
00033 
00034 #include "unity-shared/BackgroundEffectHelper.h"
00035 #include "unity-shared/Introspectable.h"
00036 #include "PanelMenuView.h"
00037 #include "PanelTray.h"
00038 #include "PanelIndicatorsView.h"
00039 #include "unity-shared/UBusWrapper.h"
00040 
00041 namespace unity
00042 {
00043 
00044 class PanelView : public unity::debug::Introspectable, public nux::View
00045 {
00046   NUX_DECLARE_OBJECT_TYPE(PanelView, nux::View);
00047 public:
00048   PanelView(NUX_FILE_LINE_PROTO);
00049   ~PanelView();
00050 
00051   void SetPrimary(bool primary);
00052   bool GetPrimary() const;
00053 
00054   void SetMonitor(int monitor);
00055   int GetMonitor() const;
00056 
00057   bool IsActive() const;
00058   bool FirstMenuShow() const;
00059 
00060   void SetOpacity(float opacity);
00061   void SetOpacityMaximizedToggle(bool enabled);
00062   void SetMenuShowTimings(int fadein, int fadeout, int discovery,
00063                           int discovery_fadein, int discovery_fadeout);
00064 
00065   Window GetTrayXid() const;
00066 
00067 protected:
00068   void Draw(nux::GraphicsEngine& GfxContext, bool force_draw);
00069   void DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw);
00070 
00071   // Introspectable methods
00072   std::string GetName() const;
00073   void AddProperties(GVariantBuilder* builder);
00074 
00075   void OnObjectAdded(indicator::Indicator::Ptr const& proxy);
00076   void OnObjectRemoved(indicator::Indicator::Ptr const& proxy);
00077   void OnIndicatorViewUpdated(PanelIndicatorEntryView* view);
00078   void OnMenuPointerMoved(int x, int y);
00079   void OnEntryActivateRequest(std::string const& entry_id);
00080   void OnEntryActivated(std::string const& entry_id, nux::Rect const& geo);
00081   void OnEntryShowMenu(std::string const& entry_id, unsigned int xid, int x, int y,
00082                        unsigned int button, unsigned int timestamp);
00083 
00084 private:
00085   void OnBackgroundUpdate(GVariant *data);
00086   void OnOverlayShown(GVariant *data);
00087   void OnOverlayHidden(GVariant *data);
00088 
00089   void UpdateBackground();
00090   void ForceUpdateBackground();
00091   bool TrackMenuPointer();
00092   void SyncGeometries();
00093   void AddPanelView(PanelIndicatorsView* child, unsigned int stretchFactor);
00094 
00095   indicator::DBusIndicators::Ptr _remote;
00096 
00097   // No ownership is taken for these views, that is done by the AddChild method.
00098   PanelMenuView* _menu_view;
00099   PanelTray* _tray;
00100   PanelIndicatorsView* _indicators;
00101 
00102   typedef std::unique_ptr<nux::AbstractPaintLayer> PaintLayerPtr;
00103   PaintLayerPtr _bg_layer;
00104   PaintLayerPtr _bg_darken_layer;
00105   nux::ObjectPtr<nux::BaseTexture> _panel_sheen;
00106   nux::HLayout* _layout;
00107 
00108   nux::Geometry _last_geo;
00109 
00110   nux::Color  _bg_color;
00111   bool        _is_dirty;
00112   bool        _opacity_maximized_toggle;
00113   bool        _needs_geo_sync;
00114   bool        _is_primary;
00115   bool        _overlay_is_open;
00116   float       _opacity;
00117   int         _monitor;
00118 
00119   std::string _active_overlay;
00120 
00121   nux::Point  _tracked_pointer_pos;
00122 
00123   std::vector<sigc::connection> _on_indicator_updated_connections;
00124   std::vector<sigc::connection> _maximized_opacity_toggle_connections;
00125   BackgroundEffectHelper _bg_effect_helper;
00126   nux::ObjectPtr<nux::IOpenGLBaseTexture> _bg_blur_texture;
00127   UBusManager _ubus_manager;
00128   glib::Source::UniquePtr _track_menu_pointer_timeout;
00129 };
00130 
00131 }
00132 
00133 #endif // PANEL_VIEW_H