2
* Copyright (C) 2010 Canonical Ltd
4
* This program is free software: you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License version 3 as
6
* published by the Free Software Foundation.
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details.
13
* You should have received a copy of the GNU General Public License
14
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16
* Authored by: Neil Jagdish Patel <neil.patel@canonical.com>
20
#include "Nux/HLayout.h"
21
#include "Nux/VLayout.h"
23
#include "NuxGraphics/GLThread.h"
24
#include "Nux/BaseWindow.h"
25
#include "Nux/WindowCompositor.h"
27
#include "PanelIndicatorObjectView.h"
29
#include "IndicatorObjectEntryProxy.h"
33
PanelIndicatorObjectView::PanelIndicatorObjectView (IndicatorObjectProxy *proxy)
34
: View (NUX_TRACKER_LOCATION),
38
printf ("IndicatorAdded: %s\n", _proxy->GetName ().c_str ());
39
_layout = new nux::HLayout ("", NUX_TRACKER_LOCATION);
41
SetCompositionLayout (_layout);
43
_proxy->OnEntryAdded.connect (sigc::mem_fun (this, &PanelIndicatorObjectView::OnEntryAdded));
44
_proxy->OnEntryMoved.connect (sigc::mem_fun (this, &PanelIndicatorObjectView::OnEntryMoved));
45
_proxy->OnEntryRemoved.connect (sigc::mem_fun (this, &PanelIndicatorObjectView::OnEntryRemoved));
48
PanelIndicatorObjectView::~PanelIndicatorObjectView ()
53
PanelIndicatorObjectView::ProcessEvent (nux::IEvent &ievent, long TraverseInfo, long ProcessEventInfo)
55
long ret = TraverseInfo;
56
ret = _layout->ProcessEvent (ievent, ret, ProcessEventInfo);
61
PanelIndicatorObjectView::Draw (nux::GraphicsContext& GfxContext, bool force_draw)
67
PanelIndicatorObjectView::DrawContent (nux::GraphicsContext &GfxContext, bool force_draw)
69
GfxContext.PushClippingRectangle (GetGeometry() );
70
_layout->ProcessDraw (GfxContext, force_draw);
71
GfxContext.PopClippingRectangle();
75
PanelIndicatorObjectView::OnEntryAdded (IndicatorObjectEntryProxy *proxy)
77
PanelIndicatorObjectEntryView *view = new PanelIndicatorObjectEntryView (proxy);
78
_layout->AddView (view, 0, nux::eCenter, nux::eFull);
79
_layout->SetContentDistribution (nux::eStackLeft);
81
_entries.push_back (view);
83
this->ComputeChildLayout ();
89
PanelIndicatorObjectView::OnEntryMoved (IndicatorObjectEntryProxy *proxy)
91
printf ("ERROR: Moving IndicatorObjectEntry not supported\n");
95
PanelIndicatorObjectView::OnEntryRemoved(IndicatorObjectEntryProxy *proxy)
97
std::vector<PanelIndicatorObjectEntryView *>::iterator it;
99
for (it = _entries.begin(); it != _entries.end(); it++)
101
PanelIndicatorObjectEntryView *view = static_cast<PanelIndicatorObjectEntryView *> (*it);
102
if (view->_proxy == proxy)
105
_layout->RemoveChildObject (view);
111
this->ComputeChildLayout ();