Back to index

unity  6.0.0
PanelIndicatorEntryView.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 (TreviƱo) <3v1n0@ubuntu.com>
00019  */
00020 
00021 #ifndef PANEL_INDICATOR_OBJECT_ENTRY_VIEW_H
00022 #define PANEL_INDICATOR_OBJECT_ENTRY_VIEW_H
00023 
00024 #include <Nux/TextureArea.h>
00025 #include <Nux/View.h>
00026 #include <NuxGraphics/CairoGraphics.h>
00027 #include <NuxGraphics/GraphicsEngine.h>
00028 
00029 #include <UnityCore/IndicatorEntry.h>
00030 #include <UnityCore/GLibWrapper.h>
00031 #include <UnityCore/GLibSignal.h>
00032 
00033 #include <gtk/gtk.h>
00034 
00035 #include "unity-shared/Introspectable.h"
00036 
00037 
00038 namespace unity
00039 {
00040 class PanelIndicatorEntryView : public nux::TextureArea, public debug::Introspectable
00041 {
00042 public:
00043   enum IndicatorEntryType {
00044     INDICATOR,
00045     MENU,
00046     OTHER
00047   };
00048 
00049   PanelIndicatorEntryView(indicator::Entry::Ptr const& proxy, int padding = 5,
00050                           IndicatorEntryType type = INDICATOR);
00051 
00052   virtual ~PanelIndicatorEntryView();
00053 
00054   IndicatorEntryType GetType() const;
00055   std::string GetEntryID() const;
00056   int GetEntryPriority() const;
00057 
00058   virtual std::string GetLabel() const;
00059   virtual bool IsLabelVisible() const;
00060   virtual bool IsLabelSensitive() const;
00061 
00062   virtual bool IsIconVisible() const;
00063   virtual bool IsIconSensitive() const;
00064 
00065   virtual void Activate(int button = 1);
00066   virtual void Unactivate();
00067 
00068   virtual void GetGeometryForSync(indicator::EntryLocationMap& locations);
00069 
00070   bool GetShowNow() const;
00071   bool IsSensitive() const;
00072   bool IsActive() const;
00073   bool IsVisible();
00074 
00075   void SetDisabled(bool disabled);
00076   bool IsDisabled();
00077 
00078   void SetOpacity(double alpha);
00079   double GetOpacity();
00080 
00081   void SetFocusedState(bool focused);
00082   bool IsFocused() const;
00083 
00084   void OverlayShown();
00085   void OverlayHidden();
00086 
00087   sigc::signal<void, PanelIndicatorEntryView*, bool> active_changed;
00088   sigc::signal<void, PanelIndicatorEntryView*> refreshed;
00089 
00090 protected:
00091   std::string GetName() const;
00092   void AddProperties(GVariantBuilder* builder);
00093 
00094   virtual void Draw(nux::GraphicsEngine& GfxContext, bool force_draw);
00095   virtual void DrawEntryPrelight(cairo_t* cr, unsigned int w, unsigned int h);
00096   virtual void DrawEntryContent(cairo_t* cr, unsigned int width, unsigned int height,
00097                                 glib::Object<GdkPixbuf> const& pixbuf,
00098                                 glib::Object<PangoLayout> const& layout);
00099 
00100   void Refresh();
00101   void SetActiveState(bool active, int button);
00102   virtual void ShowMenu(int button = 1);
00103 
00104   indicator::Entry::Ptr proxy_;
00105   unsigned int spacing_;
00106   unsigned int left_padding_;
00107   unsigned int right_padding_;
00108 
00109 private:
00110   void OnMouseDown(int x, int y, long button_flags, long key_flags);
00111   void OnMouseUp(int x, int y, long button_flags, long key_flags);
00112   void OnMouseWheel(int x, int y, int delta, unsigned long mouse_state, unsigned long key_state);
00113   void OnActiveChanged(bool is_active);
00114 
00115   glib::Object<GdkPixbuf> MakePixbuf();
00116 
00117   IndicatorEntryType type_;
00118   nux::ObjectPtr<nux::BaseTexture> entry_texture_;
00119   nux::Geometry cached_geo_;
00120   double opacity_;
00121   bool draw_active_;
00122   bool overlay_showing_;
00123   bool disabled_;
00124   bool focused_;
00125 };
00126 
00127 }
00128 
00129 #endif // PANEL_INDICATOR_OBJECT_ENTRY_VIEW_H