~shnatsel/unity/old-school-dash

« back to all changes in this revision

Viewing changes to src/PlacesView.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2010-12-17 19:18:58 UTC
  • mto: This revision was merged to the branch mainline in revision 48.
  • Revision ID: james.westby@ubuntu.com-20101217191858-jh1uan93pr2wxjdl
Tags: upstream-3.2.8
ImportĀ upstreamĀ versionĀ 3.2.8

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: Gordon Allott <gord.allott@canonical.com>
 
17
 */
 
18
 
 
19
#include "config.h"
 
20
 
 
21
#include "Nux/Nux.h"
 
22
#include "NuxGraphics/GLThread.h"
 
23
#include "UBusMessages.h"
 
24
 
 
25
#include "PlacesView.h"
 
26
 
 
27
NUX_IMPLEMENT_OBJECT_TYPE (PlacesView);
 
28
 
 
29
PlacesView::PlacesView (NUX_FILE_LINE_DECL)
 
30
:   nux::BaseWindow("", NUX_FILE_LINE_PARAM)
 
31
{
 
32
  Hide ();
 
33
}
 
34
 
 
35
PlacesView::~PlacesView ()
 
36
{
 
37
 
 
38
}
 
39
 
 
40
long PlacesView::ProcessEvent(nux::IEvent &ievent, long TraverseInfo, long ProcessEventInfo)
 
41
{
 
42
  long ret = TraverseInfo;
 
43
  long ProcEvInfo = 0;
 
44
 
 
45
  nux::IEvent window_event = ievent;
 
46
  nux::Geometry base = GetGeometry();
 
47
  window_event.e_x_root = base.x;
 
48
  window_event.e_y_root = base.y;
 
49
 
 
50
  // The child layout get the Mouse down button only if the MouseDown happened inside the client view Area
 
51
  nux::Geometry viewGeometry = GetGeometry();
 
52
 
 
53
  if (ievent.e_event == nux::NUX_MOUSE_PRESSED)
 
54
  {
 
55
    if (!viewGeometry.IsPointInside (ievent.e_x - ievent.e_x_root, ievent.e_y - ievent.e_y_root) )
 
56
    {
 
57
      ProcEvInfo = nux::eDoNotProcess;
 
58
    }
 
59
  }
 
60
 
 
61
  // hide if outside our window
 
62
  if (ievent.e_event == nux::NUX_MOUSE_PRESSED)
 
63
  {
 
64
    if (!(GetGeometry ().IsPointInside (ievent.e_x, ievent.e_y)))
 
65
    {
 
66
      Hide ();
 
67
      return nux::eMouseEventSolved;
 
68
    }
 
69
  }
 
70
 
 
71
  return ret;
 
72
}
 
73
 
 
74
void PlacesView::Draw(nux::GraphicsEngine& GfxContext, bool force_draw)
 
75
{
 
76
  nux::Color *color = new nux::Color (0.9, 0.3, 0.1, 1.0);
 
77
  nux::GetPainter ().Paint2DQuadColor (GfxContext, GetGeometry (), *color);
 
78
}
 
79
 
 
80
 
 
81
void PlacesView::DrawContent (nux::GraphicsEngine &GfxContext, bool force_draw)
 
82
{
 
83
 
 
84
}
 
85
 
 
86
void PlacesView::PostDraw (nux::GraphicsEngine &GfxContext, bool force_draw)
 
87
{
 
88
 
 
89
}
 
90
 
 
91
void PlacesView::ShowWindow (bool b, bool start_modal)
 
92
{
 
93
  nux::BaseWindow::ShowWindow (b, start_modal);
 
94
}
 
95
 
 
96
void PlacesView::Show ()
 
97
{
 
98
  if (IsVisible ())
 
99
    return;
 
100
 
 
101
  // FIXME: ShowWindow shouldn't need to be called first
 
102
  ShowWindow (true, false);
 
103
  EnableInputWindow (true, 1);
 
104
  GrabPointer ();
 
105
  NeedRedraw ();
 
106
}
 
107
 
 
108
void PlacesView::Hide ()
 
109
{
 
110
  if (!IsVisible ())
 
111
    return;
 
112
 
 
113
  CaptureMouseDownAnyWhereElse (false);
 
114
  ForceStopFocus (1, 1);
 
115
  UnGrabPointer ();
 
116
  EnableInputWindow (false);
 
117
  ShowWindow (false, false);
 
118
}
 
119
 
 
120
 
 
121
/* Introspection */
 
122
const gchar *
 
123
PlacesView::GetName ()
 
124
{
 
125
  return "PlacesView";
 
126
}
 
127
 
 
128
void
 
129
PlacesView::AddProperties (GVariantBuilder *builder)
 
130
{
 
131
}