Back to index

unity  6.0.0
PanelIndicatorsView.h
Go to the documentation of this file.
00001 // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
00002 /*
00003  * Copyright (C) 2011 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: Marco Trevisan (TreviƱo) <mail@3v1n0.net>
00018  *              Neil Jagdish Patel <neil.patel@canonical.com>
00019  */
00020 
00021 #ifndef PANEL_INDICATORS_VIEW_H
00022 #define PANEL_INDICATORS_VIEW_H
00023 
00024 #include <Nux/View.h>
00025 #include <Nux/Layout.h>
00026 
00027 #include <UnityCore/Indicator.h>
00028 
00029 #include "PanelIndicatorEntryView.h"
00030 #include "unity-shared/Introspectable.h"
00031 
00032 namespace unity
00033 {
00034 
00035 class PanelIndicatorsView : public nux::View, public unity::debug::Introspectable
00036 {
00037   NUX_DECLARE_OBJECT_TYPE(PanelIndicatorsView, nux::View);
00038 public:
00039   PanelIndicatorsView();
00040   ~PanelIndicatorsView();
00041 
00042   void AddIndicator(indicator::Indicator::Ptr const& indicator);
00043   void RemoveIndicator(indicator::Indicator::Ptr const& indicator);
00044 
00045   enum IndicatorEntryPosition {
00046     AUTO = -1,
00047     START = nux::NUX_LAYOUT_BEGIN,
00048     END = nux::NUX_LAYOUT_END,
00049   };
00050 
00051   typedef PanelIndicatorEntryView::IndicatorEntryType IndicatorEntryType;
00052 
00053   PanelIndicatorEntryView* AddEntry(indicator::Entry::Ptr const& entry,
00054                                     int padding = 5,
00055                                     IndicatorEntryPosition pos = AUTO,
00056                                     IndicatorEntryType type = IndicatorEntryType::INDICATOR);
00057   void RemoveEntry(std::string const& entry_id);
00058 
00059   PanelIndicatorEntryView* ActivateEntryAt(int x, int y, int button = 1);
00060   PanelIndicatorEntryView* ActivateEntry(std::string const& entry_id, int button = 1);
00061   bool ActivateIfSensitive();
00062 
00063   virtual void OverlayShown();
00064   virtual void OverlayHidden();
00065 
00066   void SetOpacity(double opacity);
00067   double GetOpacity();
00068 
00069   void SetMaximumEntriesWidth(int max_width);
00070   void GetGeometryForSync(indicator::EntryLocationMap& locations);
00071 
00072   sigc::signal<void, PanelIndicatorEntryView*> on_indicator_updated;
00073 
00074 protected:
00075   std::string GetName() const;
00076   void AddProperties(GVariantBuilder* builder);
00077 
00078   typedef std::vector<indicator::Indicator::Ptr> Indicators;
00079   Indicators GetIndicators();
00080 
00081   virtual void Draw(nux::GraphicsEngine& GfxContext, bool force_draw);
00082   virtual void DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw);
00083 
00084   virtual void OnEntryAdded(indicator::Entry::Ptr const& entry);
00085   virtual void OnEntryRefreshed(PanelIndicatorEntryView* view);
00086   virtual void OnEntryRemoved(std::string const& entry_id);
00087 
00088   virtual void AddEntryView(PanelIndicatorEntryView* view,
00089                             IndicatorEntryPosition pos = AUTO);
00090   virtual void RemoveEntryView(PanelIndicatorEntryView* view);
00091 
00092   nux::HLayout* layout_;
00093   typedef std::map<std::string, PanelIndicatorEntryView*> Entries;
00094   Entries entries_;
00095 
00096 private:
00097   Indicators indicators_;
00098   double opacity_;
00099 
00100   std::map<indicator::Indicator::Ptr, std::vector<sigc::connection>> indicators_connections_;
00101 };
00102 
00103 }
00104 
00105 #endif // PANEL_INDICATORS_VIEW_H