~vanvugt/unity/fix-865006

« back to all changes in this revision

Viewing changes to unity-shared/SearchBarSpinner.cpp

  • Committer: Andrea Azzarone
  • Date: 2012-06-12 08:23:23 UTC
  • mfrom: (2400 unity)
  • mto: This revision was merged to the branch mainline in revision 2404.
  • Revision ID: azzaronea@gmail.com-20120612082323-zdw8jxwjcia8vi71
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
SearchBarSpinner::SearchBarSpinner()
33
33
  : nux::View(NUX_TRACKER_LOCATION),
34
34
    _state(STATE_READY),
35
 
    _rotation(0.0f),
36
 
    _spinner_timeout(0),
37
 
    _frame_timeout(0)
 
35
    _rotation(0.0f)
38
36
{
39
37
  dash::Style& style = dash::Style::Instance();
40
38
 
47
45
  _2d_rotate.Rotate_z(0.0);
48
46
}
49
47
 
50
 
SearchBarSpinner::~SearchBarSpinner()
51
 
{
52
 
  if (_spinner_timeout)
53
 
    g_source_remove(_spinner_timeout);
54
 
 
55
 
  if (_frame_timeout)
56
 
    g_source_remove(_frame_timeout);
57
 
}
58
 
 
59
48
void
60
49
SearchBarSpinner::Draw(nux::GraphicsEngine& GfxContext, bool force_draw)
61
50
{
62
 
  nux::Geometry geo = GetGeometry();
 
51
  nux::Geometry const& geo = GetGeometry();
63
52
  nux::TexCoordXForm texxform;
64
53
 
65
54
  GfxContext.PushClippingRectangle(geo);
132
121
  GfxContext.PopClippingRectangle();
133
122
 
134
123
  if (_state == STATE_SEARCHING && !_frame_timeout)
135
 
    _frame_timeout = g_timeout_add(22, (GSourceFunc)SearchBarSpinner::OnFrame, this);
 
124
  {
 
125
    _frame_timeout.reset(new glib::Timeout(22, sigc::mem_fun(this, &SearchBarSpinner::OnFrameTimeout)));
 
126
  }
136
127
}
137
128
 
138
129
void
140
131
{
141
132
}
142
133
 
143
 
gboolean
144
 
SearchBarSpinner::OnTimeout(SearchBarSpinner* self)
145
 
{
146
 
  self->_state = STATE_READY;
147
 
  return FALSE;
148
 
}
149
 
 
150
 
gboolean
151
 
SearchBarSpinner::OnFrame(SearchBarSpinner* self)
152
 
{
153
 
  self->_rotation += 0.1f;
154
 
  if (self->_rotation >= 360.0f)
155
 
    self->_rotation = 0.0f;
156
 
 
157
 
  self->_2d_rotate.Rotate_z(self->_rotation);
158
 
  self->_frame_timeout = 0;
159
 
 
160
 
  self->QueueDraw();
161
 
  return FALSE;
 
134
bool
 
135
SearchBarSpinner::OnFrameTimeout()
 
136
{
 
137
  _rotation += 0.1f;
 
138
 
 
139
  if (_rotation >= 360.0f)
 
140
    _rotation = 0.0f;
 
141
 
 
142
  _2d_rotate.Rotate_z(_rotation);
 
143
  QueueDraw();
 
144
 
 
145
  _frame_timeout.reset();
 
146
  return false;
162
147
}
163
148
 
164
149
void
168
153
    return;
169
154
 
170
155
  _state = state;
171
 
 
172
 
  if (_spinner_timeout)
173
 
    g_source_remove(_spinner_timeout);
174
 
  _spinner_timeout = 0;
175
 
 
 
156
  _spinner_timeout.reset();
176
157
  _2d_rotate.Rotate_z(0.0f);
177
158
  _rotation = 0.0f;
178
159
 
179
160
  if (_state == STATE_SEARCHING)
180
161
  {
181
 
    _spinner_timeout = g_timeout_add_seconds(5, (GSourceFunc)SearchBarSpinner::OnTimeout, this);
 
162
    _spinner_timeout.reset(new glib::Timeout(5 * 1000, [&] () {
 
163
      _state = STATE_READY;
 
164
      return false;
 
165
    }));
182
166
  }
183
167
 
184
168
  QueueDraw();