~bitshifternz/unity/bug-750349-restore-state

« back to all changes in this revision

Viewing changes to src/PanelIndicatorObjectView.cpp

Import the work done so far with Compiz

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2010 Canonical Ltd
 
3
 *
 
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.
 
7
 *
 
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.
 
12
 *
 
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/>.
 
15
 *
 
16
 * Authored by: Neil Jagdish Patel <neil.patel@canonical.com>
 
17
 */
 
18
 
 
19
#include "Nux/Nux.h"
 
20
#include "Nux/HLayout.h"
 
21
#include "Nux/VLayout.h"
 
22
 
 
23
#include "NuxGraphics/GLThread.h"
 
24
#include "Nux/BaseWindow.h"
 
25
#include "Nux/WindowCompositor.h"
 
26
 
 
27
#include "PanelIndicatorObjectView.h"
 
28
 
 
29
#include "IndicatorObjectEntryProxy.h"
 
30
 
 
31
#include <glib.h>
 
32
 
 
33
PanelIndicatorObjectView::PanelIndicatorObjectView (IndicatorObjectProxy *proxy)
 
34
: View (NUX_TRACKER_LOCATION),
 
35
  _proxy (proxy),
 
36
  _entries ()
 
37
{
 
38
  printf ("IndicatorAdded: %s\n", _proxy->GetName ().c_str ());
 
39
  _layout = new nux::HLayout ("", NUX_TRACKER_LOCATION);
 
40
 
 
41
  SetCompositionLayout (_layout);
 
42
 
 
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));
 
46
}
 
47
 
 
48
PanelIndicatorObjectView::~PanelIndicatorObjectView ()
 
49
{
 
50
}
 
51
 
 
52
long
 
53
PanelIndicatorObjectView::ProcessEvent (nux::IEvent &ievent, long TraverseInfo, long ProcessEventInfo)
 
54
{
 
55
  long ret = TraverseInfo;
 
56
  ret = _layout->ProcessEvent (ievent, ret, ProcessEventInfo);
 
57
  return ret;
 
58
}
 
59
 
 
60
void
 
61
PanelIndicatorObjectView::Draw (nux::GraphicsContext& GfxContext, bool force_draw)
 
62
{
 
63
 
 
64
}
 
65
 
 
66
void
 
67
PanelIndicatorObjectView::DrawContent (nux::GraphicsContext &GfxContext, bool force_draw)
 
68
{
 
69
  GfxContext.PushClippingRectangle (GetGeometry() );
 
70
  _layout->ProcessDraw (GfxContext, force_draw);
 
71
  GfxContext.PopClippingRectangle();
 
72
}
 
73
 
 
74
void
 
75
PanelIndicatorObjectView::OnEntryAdded (IndicatorObjectEntryProxy *proxy)
 
76
{
 
77
  PanelIndicatorObjectEntryView *view = new PanelIndicatorObjectEntryView (proxy);
 
78
  _layout->AddView (view, 0, nux::eCenter, nux::eFull);
 
79
  _layout->SetContentDistribution (nux::eStackLeft);
 
80
 
 
81
  _entries.push_back (view);
 
82
 
 
83
  this->ComputeChildLayout ();
 
84
  NeedRedraw ();
 
85
  
 
86
}
 
87
 
 
88
void
 
89
PanelIndicatorObjectView::OnEntryMoved (IndicatorObjectEntryProxy *proxy)
 
90
{
 
91
  printf ("ERROR: Moving IndicatorObjectEntry not supported\n");
 
92
}
 
93
 
 
94
void
 
95
PanelIndicatorObjectView::OnEntryRemoved(IndicatorObjectEntryProxy *proxy)
 
96
{
 
97
  std::vector<PanelIndicatorObjectEntryView *>::iterator it;
 
98
  
 
99
  for (it = _entries.begin(); it != _entries.end(); it++)
 
100
  {
 
101
    PanelIndicatorObjectEntryView *view = static_cast<PanelIndicatorObjectEntryView *> (*it);
 
102
    if (view->_proxy == proxy)
 
103
      {
 
104
        _entries.erase (it);
 
105
        _layout->RemoveChildObject (view);
 
106
 
 
107
        break;
 
108
      }
 
109
  }
 
110
 
 
111
  this->ComputeChildLayout (); 
 
112
  NeedRedraw ();
 
113
}