~om26er/ubuntu/oneiric/unity/sru-778256

« back to all changes in this revision

Viewing changes to plugins/unityshell/src/QuicklistView.cpp

  • Committer: Didier Roche
  • Date: 2011-07-21 16:17:59 UTC
  • mfrom: (55.813.3 upstream)
  • Revision ID: didier.roche@canonical.com-20110721161759-osmh94x428t2bf2b
* New upstream release.
* debian/control:
  - build-dep on libnotify-dev
  - bump libnux-1.0-dev dep for ABI break

Show diffs side-by-side

added added

removed removed

Lines of Context:
48
48
#define NUX_KP_LEFT  0xFF96
49
49
#define NUX_KP_RIGHT 0xFF98
50
50
 
51
 
NUX_IMPLEMENT_OBJECT_TYPE (QuicklistView);
 
51
NUX_IMPLEMENT_OBJECT_TYPE(QuicklistView);
52
52
 
53
 
QuicklistView::QuicklistView ()
 
53
QuicklistView::QuicklistView()
54
54
{
55
 
  _name = g_strdup ("Quicklist");
 
55
  _name = g_strdup("Quicklist");
56
56
  _texture_bg = 0;
57
57
  _texture_mask = 0;
58
58
  _texture_outline = 0;
60
60
 
61
61
  _anchorX   = 0;
62
62
  _anchorY   = 0;
63
 
  _labelText = TEXT ("QuicklistView 1234567890");
 
63
  _labelText = TEXT("QuicklistView 1234567890");
64
64
 
65
65
  _anchor_width   = 10;
66
66
  _anchor_height  = 18;
68
68
  _padding        = 13;
69
69
  _top_size       = 4;
70
70
 
71
 
  SetGeometry (nux::Geometry (0, 0, 1, 1));
72
 
  _hlayout         = new nux::HLayout (TEXT(""), NUX_TRACKER_LOCATION);
73
 
  _vlayout         = new nux::VLayout (TEXT(""), NUX_TRACKER_LOCATION);
74
 
  _item_layout     = new nux::VLayout (TEXT(""), NUX_TRACKER_LOCATION);
75
 
  _default_item_layout = new nux::VLayout (TEXT(""), NUX_TRACKER_LOCATION);
76
 
  
77
 
  _left_space = new nux::SpaceLayout (_padding + _anchor_width + _corner_radius, _padding + _anchor_width + _corner_radius, 1, 1000);
78
 
  _right_space = new nux::SpaceLayout (_padding + _corner_radius, _padding + _corner_radius, 1, 1000);
79
 
 
80
 
  _top_space = new nux::SpaceLayout (1, 1000, _padding + _corner_radius, _padding + _corner_radius);
81
 
  _bottom_space = new nux::SpaceLayout (1, 1000, _padding + _corner_radius, _padding + _corner_radius);
82
 
 
83
 
  _vlayout->AddLayout (_top_space, 0);
84
 
 
85
 
  _vlayout->AddLayout (_item_layout, 0);
86
 
  
87
 
  _vlayout->AddLayout (_default_item_layout, 0);
88
 
 
89
 
  _vlayout->AddLayout (_bottom_space, 0);
90
 
 
91
 
  _hlayout->AddLayout (_left_space, 0);
92
 
  _hlayout->AddLayout (_vlayout, 0, nux::eCenter, nux::eFull);
93
 
  _hlayout->AddLayout (_right_space, 0);
94
 
 
95
 
  SetWindowSizeMatchLayout (true);
96
 
  SetLayout (_hlayout);
97
 
  
98
 
  OnMouseDownOutsideArea.connect (sigc::mem_fun (this, &QuicklistView::RecvMouseDownOutsideOfQuicklist));
99
 
  OnMouseDown.connect (sigc::mem_fun (this, &QuicklistView::RecvMouseDown));
100
 
  OnMouseUp.connect (sigc::mem_fun (this, &QuicklistView::RecvMouseUp));
101
 
  OnMouseClick.connect (sigc::mem_fun (this, &QuicklistView::RecvMouseClick));
102
 
  OnMouseMove.connect (sigc::mem_fun (this, &QuicklistView::RecvMouseMove));
103
 
  OnMouseDrag.connect (sigc::mem_fun (this, &QuicklistView::RecvMouseDrag));
104
 
  OnKeyPressed.connect (sigc::mem_fun (this, &QuicklistView::RecvKeyPressed));
105
 
  OnStartFocus.connect (sigc::mem_fun (this, &QuicklistView::RecvStartFocus));
106
 
  OnEndFocus.connect   (sigc::mem_fun (this, &QuicklistView::RecvEndFocus));
 
71
  SetGeometry(nux::Geometry(0, 0, 1, 1));
 
72
  _hlayout         = new nux::HLayout(TEXT(""), NUX_TRACKER_LOCATION);
 
73
  _vlayout         = new nux::VLayout(TEXT(""), NUX_TRACKER_LOCATION);
 
74
  _item_layout     = new nux::VLayout(TEXT(""), NUX_TRACKER_LOCATION);
 
75
  _default_item_layout = new nux::VLayout(TEXT(""), NUX_TRACKER_LOCATION);
 
76
 
 
77
  _left_space = new nux::SpaceLayout(_padding + _anchor_width + _corner_radius, _padding + _anchor_width + _corner_radius, 1, 1000);
 
78
  _right_space = new nux::SpaceLayout(_padding + _corner_radius, _padding + _corner_radius, 1, 1000);
 
79
 
 
80
  _top_space = new nux::SpaceLayout(1, 1000, _padding + _corner_radius, _padding + _corner_radius);
 
81
  _bottom_space = new nux::SpaceLayout(1, 1000, _padding + _corner_radius, _padding + _corner_radius);
 
82
 
 
83
  _vlayout->AddLayout(_top_space, 0);
 
84
 
 
85
  _vlayout->AddLayout(_item_layout, 0);
 
86
 
 
87
  _vlayout->AddLayout(_default_item_layout, 0);
 
88
 
 
89
  _vlayout->AddLayout(_bottom_space, 0);
 
90
 
 
91
  _hlayout->AddLayout(_left_space, 0);
 
92
  _hlayout->AddLayout(_vlayout, 0, nux::eCenter, nux::eFull);
 
93
  _hlayout->AddLayout(_right_space, 0);
 
94
 
 
95
  SetWindowSizeMatchLayout(true);
 
96
  SetLayout(_hlayout);
 
97
 
 
98
  OnMouseDownOutsideArea.connect(sigc::mem_fun(this, &QuicklistView::RecvMouseDownOutsideOfQuicklist));
 
99
  OnMouseDown.connect(sigc::mem_fun(this, &QuicklistView::RecvMouseDown));
 
100
  OnMouseUp.connect(sigc::mem_fun(this, &QuicklistView::RecvMouseUp));
 
101
  OnMouseClick.connect(sigc::mem_fun(this, &QuicklistView::RecvMouseClick));
 
102
  OnMouseMove.connect(sigc::mem_fun(this, &QuicklistView::RecvMouseMove));
 
103
  OnMouseDrag.connect(sigc::mem_fun(this, &QuicklistView::RecvMouseDrag));
 
104
  OnKeyEvent.connect(sigc::mem_fun(this, &QuicklistView::RecvKeyPressed));
 
105
  OnStartKeyboardReceiver.connect(sigc::mem_fun(this, &QuicklistView::RecvStartFocus));
 
106
  OnStopKeyboardReceiver.connect(sigc::mem_fun(this, &QuicklistView::RecvEndFocus));
107
107
 
108
108
  _mouse_down = false;
109
109
  _enable_quicklist_for_testing = false;
110
110
  _compute_blur_bkg = true;
111
111
 
112
112
  _current_item_index = 0;
 
113
 
 
114
  SetAcceptKeyNavFocus(true);
113
115
}
114
116
 
115
117
void
116
 
QuicklistView::RecvStartFocus ()
 
118
QuicklistView::RecvStartFocus()
117
119
{
118
 
  PushToFront ();
 
120
  PushToFront();
119
121
}
120
122
 
121
123
void
122
 
QuicklistView::RecvEndFocus ()
 
124
QuicklistView::RecvEndFocus()
123
125
{
124
126
}
125
127
 
126
128
bool
127
 
QuicklistView::IsMenuItemSeperator (int index)
 
129
QuicklistView::IsMenuItemSeperator(int index)
128
130
{
129
131
  QuicklistMenuItem* menu_item = NULL;
130
132
  DbusmenuMenuitem*  item   = NULL;
134
136
  if (index < 0)
135
137
    return false;
136
138
 
137
 
  menu_item = GetNthItems (index);
 
139
  menu_item = GetNthItems(index);
138
140
  if (!menu_item)
139
141
    return false;
140
 
  
 
142
 
141
143
  item = menu_item->_menuItem;
142
144
  if (!item)
143
145
    return false;
144
146
 
145
 
  label = dbusmenu_menuitem_property_get (item, DBUSMENU_MENUITEM_PROP_LABEL);
 
147
  label = dbusmenu_menuitem_property_get(item, DBUSMENU_MENUITEM_PROP_LABEL);
146
148
  if (!label)
147
149
    result = true;
148
150
  else
152
154
}
153
155
 
154
156
void
155
 
QuicklistView::RecvKeyPressed (unsigned int  key_sym,
156
 
                               unsigned long key_code,
157
 
                               unsigned long key_state)
 
157
QuicklistView::RecvKeyPressed(nux::GraphicsEngine& GfxContext,
 
158
                              unsigned long    eventType,
 
159
                              unsigned long    key_sym,
 
160
                              unsigned long    key_state,
 
161
                              const char*      character,
 
162
                              unsigned short   keyCount)
158
163
{
159
164
  switch (key_sym)
160
165
  {
161
 
    // up (highlight previous menu-item)
 
166
      // up (highlight previous menu-item)
162
167
    case NUX_VK_UP:
163
168
    case NUX_KP_UP:
164
 
      // protect against edge-case of first item being a separator 
165
 
      if (_current_item_index == 1 && IsMenuItemSeperator (0))
 
169
      // protect against edge-case of first item being a separator
 
170
      if (_current_item_index == 1 && IsMenuItemSeperator(0))
166
171
        break;
167
172
 
168
173
      if (_current_item_index > 0)
169
174
      {
170
 
        GetNthItems (_current_item_index)->_prelight = false;
 
175
        GetNthItems(_current_item_index)->_prelight = false;
171
176
        _current_item_index--;
172
177
 
173
 
        while (IsMenuItemSeperator (_current_item_index))
 
178
        while (IsMenuItemSeperator(_current_item_index))
174
179
          _current_item_index--;
175
180
 
176
 
        GetNthItems (_current_item_index)->_prelight = true;
177
 
        QueueDraw ();
 
181
        GetNthItems(_current_item_index)->_prelight = true;
 
182
        QueueDraw();
178
183
      }
179
 
    break;
 
184
      break;
180
185
 
181
 
    // down (highlight next menu-item)
 
186
      // down (highlight next menu-item)
182
187
    case NUX_VK_DOWN:
183
188
    case NUX_KP_DOWN:
184
 
      // protect against edge-case of last item being a separator 
185
 
      if (_current_item_index == (GetNumItems () - 1) && IsMenuItemSeperator (GetNumItems ()))
 
189
      // protect against edge-case of last item being a separator
 
190
      if (_current_item_index == (GetNumItems() - 1) && IsMenuItemSeperator(GetNumItems()))
186
191
        break;
187
192
 
188
 
      if (_current_item_index < GetNumItems () - 1)
 
193
      if (_current_item_index < GetNumItems() - 1)
189
194
      {
190
 
        GetNthItems (_current_item_index)->_prelight = false;
 
195
        GetNthItems(_current_item_index)->_prelight = false;
191
196
        _current_item_index++;
192
197
 
193
 
        while (IsMenuItemSeperator (_current_item_index))
 
198
        while (IsMenuItemSeperator(_current_item_index))
194
199
          _current_item_index++;
195
200
 
196
 
        GetNthItems (_current_item_index)->_prelight = true;
197
 
        QueueDraw ();
 
201
        GetNthItems(_current_item_index)->_prelight = true;
 
202
        QueueDraw();
198
203
      }
199
 
    break;
 
204
      break;
200
205
 
201
 
    // left (close quicklist, go back to laucher key-nav)
 
206
      // left (close quicklist, go back to laucher key-nav)
202
207
    case NUX_VK_LEFT:
203
208
    case NUX_KP_LEFT:
204
209
      _current_item_index = 0;
205
 
      GetNthItems (_current_item_index)->_prelight = true;
206
 
      Hide ();
 
210
      GetNthItems(_current_item_index)->_prelight = true;
 
211
      Hide();
207
212
      // inform Launcher we switch back to Launcher key-nav
208
 
      ubus_server_send_message (ubus_server_get_default (),
209
 
                                UBUS_QUICKLIST_END_KEY_NAV,
210
 
                                NULL);
211
 
    break;
 
213
      ubus_server_send_message(ubus_server_get_default(),
 
214
                               UBUS_QUICKLIST_END_KEY_NAV,
 
215
                               NULL);
 
216
      break;
212
217
 
213
 
    // esc (close quicklist, exit key-nav)
 
218
      // esc (close quicklist, exit key-nav)
214
219
    case NUX_VK_ESCAPE:
215
220
      _current_item_index = 0;
216
 
      GetNthItems (_current_item_index)->_prelight = true;
217
 
      Hide ();
 
221
      GetNthItems(_current_item_index)->_prelight = true;
 
222
      Hide();
218
223
      // inform UnityScreen we leave key-nav completely
219
 
      ubus_server_send_message (ubus_server_get_default (),
220
 
                                UBUS_LAUNCHER_END_KEY_NAV,
221
 
                                NULL);
222
 
    break;
 
224
      ubus_server_send_message(ubus_server_get_default(),
 
225
                               UBUS_LAUNCHER_END_KEY_NAV,
 
226
                               NULL);
 
227
      break;
223
228
 
224
 
    // <SPACE>, <RETURN> (activate selected menu-item)          
 
229
      // <SPACE>, <RETURN> (activate selected menu-item)
225
230
    case NUX_VK_SPACE:
226
231
    case NUX_VK_ENTER:
227
232
    case NUX_KP_ENTER:
228
 
      if (_current_item_index >= 0 && _current_item_index < GetNumItems () &&
229
 
          GetNthItems (_current_item_index)->GetEnabled ())
 
233
      if (_current_item_index >= 0 && _current_item_index < GetNumItems() &&
 
234
          GetNthItems(_current_item_index)->GetEnabled())
230
235
      {
231
236
 
232
 
        dbusmenu_menuitem_handle_event (GetNthItems (_current_item_index)->_menuItem,
233
 
                                        "clicked",
234
 
                                        NULL,
235
 
                                        0);
 
237
        dbusmenu_menuitem_handle_event(GetNthItems(_current_item_index)->_menuItem,
 
238
                                       "clicked",
 
239
                                       NULL,
 
240
                                       0);
236
241
        _current_item_index = 0;
237
 
        GetNthItems (_current_item_index)->_prelight = true;
238
 
        Hide ();
 
242
        GetNthItems(_current_item_index)->_prelight = true;
 
243
        Hide();
239
244
      }
240
 
    break;
 
245
      break;
241
246
 
242
247
    default:
243
 
    break;
 
248
      break;
244
249
  }
245
250
}
246
251
 
247
 
QuicklistView::~QuicklistView ()
 
252
QuicklistView::~QuicklistView()
248
253
{
249
254
  if (_name)
250
 
    g_free (_name);
251
 
  
 
255
    g_free(_name);
 
256
 
252
257
  if (_texture_bg)
253
 
    _texture_bg->UnReference ();
254
 
  
 
258
    _texture_bg->UnReference();
 
259
 
255
260
  if (_texture_outline)
256
 
    _texture_outline->UnReference ();
257
 
  
258
 
    if (_texture_mask)
259
 
    _texture_mask->UnReference ();
260
 
  
 
261
    _texture_outline->UnReference();
 
262
 
 
263
  if (_texture_mask)
 
264
    _texture_mask->UnReference();
 
265
 
261
266
  std::list<QuicklistMenuItem*>::iterator it;
262
267
  for (it = _item_list.begin(); it != _item_list.end(); it++)
263
268
  {
264
269
    // Remove from introspection
265
 
    RemoveChild (*it);
 
270
    RemoveChild(*it);
266
271
    (*it)->UnReference();
267
272
  }
268
273
 
269
274
  for (it = _default_item_list.begin(); it != _default_item_list.end(); it++)
270
275
  {
271
276
    // Remove from introspection
272
 
    RemoveChild (*it);
 
277
    RemoveChild(*it);
273
278
    (*it)->UnReference();
274
279
  }
275
 
  
276
 
  _default_item_list.clear ();
277
 
  _item_list.clear ();
 
280
 
 
281
  _default_item_list.clear();
 
282
  _item_list.clear();
278
283
}
279
284
 
280
285
void
281
 
QuicklistView::EnableQuicklistForTesting (bool enable_testing)
 
286
QuicklistView::EnableQuicklistForTesting(bool enable_testing)
282
287
{
283
288
  _enable_quicklist_for_testing = enable_testing;
284
289
}
285
290
 
286
 
void QuicklistView::ShowQuicklistWithTipAt (int anchor_tip_x, int anchor_tip_y)
 
291
void QuicklistView::ShowQuicklistWithTipAt(int anchor_tip_x, int anchor_tip_y)
287
292
{
288
293
  _anchorX = anchor_tip_x;
289
294
  _anchorY = anchor_tip_y;
290
 
  
 
295
 
291
296
  if (!_enable_quicklist_for_testing)
292
297
  {
293
 
    if ((_item_list.size () != 0) || (_default_item_list.size () != 0))
 
298
    if ((_item_list.size() != 0) || (_default_item_list.size() != 0))
294
299
    {
295
 
      int offscreen_size = GetBaseY () +
296
 
                           GetBaseHeight () -
297
 
                           nux::GetWindow().GetWindowHeight ();
 
300
      int offscreen_size = GetBaseY() +
 
301
                           GetBaseHeight() -
 
302
                           nux::GetWindow().GetWindowHeight();
298
303
 
299
304
      if (offscreen_size > 0)
300
305
        _top_size = offscreen_size;
302
307
        _top_size = 4;
303
308
 
304
309
      int x = _anchorX - _padding;
305
 
      int y = _anchorY - _anchor_height/2 - _top_size - _corner_radius - _padding;
 
310
      int y = _anchorY - _anchor_height / 2 - _top_size - _corner_radius - _padding;
306
311
 
307
 
      SetBaseX (x);
308
 
      SetBaseY (y);
 
312
      SetBaseX(x);
 
313
      SetBaseY(y);
309
314
    }
310
315
    else
311
316
    {
312
317
      _top_size = 0;
313
318
      int x = _anchorX - _padding;
314
 
      int y = _anchorY - _anchor_height/2 - _top_size - _corner_radius - _padding;
 
319
      int y = _anchorY - _anchor_height / 2 - _top_size - _corner_radius - _padding;
315
320
 
316
 
      SetBaseX (x);
317
 
      SetBaseY (y);    
 
321
      SetBaseX(x);
 
322
      SetBaseY(y);
318
323
    }
319
324
  }
320
325
 
321
 
  Show ();
 
326
  Show();
322
327
}
323
328
 
324
 
void QuicklistView::ShowWindow (bool b, bool start_modal)
 
329
void QuicklistView::ShowWindow(bool b, bool start_modal)
325
330
{
326
 
  BaseWindow::ShowWindow (b, start_modal);
 
331
  BaseWindow::ShowWindow(b, start_modal);
327
332
}
328
333
 
329
 
void QuicklistView::Show ()
 
334
void QuicklistView::Show()
330
335
{
331
336
  if (!IsVisible())
332
337
  {
333
338
    // FIXME: ShowWindow shouldn't need to be called first
334
 
    ShowWindow (true);
335
 
    PushToFront ();
 
339
    ShowWindow(true);
 
340
    PushToFront();
336
341
    //EnableInputWindow (true, "quicklist", false, true);
337
342
    //SetInputFocus ();
338
 
    GrabPointer ();
339
 
    GrabKeyboard ();
340
 
    QueueDraw ();
 
343
    GrabPointer();
 
344
    GrabKeyboard();
 
345
    QueueDraw();
341
346
    _compute_blur_bkg = true;
342
347
  }
343
348
}
344
349
 
345
 
void QuicklistView::Hide ()
 
350
void QuicklistView::Hide()
346
351
{
347
352
  if (IsVisible() && !_enable_quicklist_for_testing)
348
353
  {
349
 
    CancelItemsPrelightStatus ();
350
 
    CaptureMouseDownAnyWhereElse (false);
351
 
    ForceStopFocus (1, 1);
352
 
    UnGrabPointer ();
353
 
    UnGrabKeyboard ();
 
354
    CancelItemsPrelightStatus();
 
355
    CaptureMouseDownAnyWhereElse(false);
 
356
    ForceStopFocus(1, 1);
 
357
    UnGrabPointer();
 
358
    UnGrabKeyboard();
354
359
    //EnableInputWindow (false);
355
 
    ShowWindow (false);
 
360
    ShowWindow(false);
356
361
  }
357
362
}
358
363
 
359
 
long QuicklistView::ProcessEvent (nux::IEvent& ievent, long TraverseInfo, long ProcessEventInfo)
 
364
long QuicklistView::ProcessEvent(nux::IEvent& ievent, long TraverseInfo, long ProcessEventInfo)
360
365
{
361
366
  long ret = TraverseInfo;
362
367
  long ProcEvInfo = 0;
371
376
 
372
377
  if (ievent.e_event == nux::NUX_MOUSE_PRESSED)
373
378
  {
374
 
    if (!viewGeometry.IsPointInside (ievent.e_x - ievent.e_x_root, ievent.e_y - ievent.e_y_root) )
 
379
    if (!viewGeometry.IsPointInside(ievent.e_x - ievent.e_x_root, ievent.e_y - ievent.e_y_root))
375
380
    {
376
381
      ProcEvInfo = nux::eDoNotProcess;
377
382
    }
381
386
  // This is meant to be easier since the quicklist has a atypical way of working.
382
387
  if (m_layout)
383
388
  {
384
 
    ret = m_layout->ProcessEvent (window_event, ret, ProcEvInfo);
 
389
    ret = m_layout->ProcessEvent(window_event, ret, ProcEvInfo);
385
390
  }
386
 
  
387
 
  // The quicklist itself does not process the evvent. Instead we do some analysis of the event 
 
391
 
 
392
  // The quicklist itself does not process the evvent. Instead we do some analysis of the event
388
393
  // to detect the user action and perform the correct operation.
389
394
  if (ievent.e_event == nux::NUX_MOUSE_PRESSED)
390
395
  {
391
 
    if (GetGeometry ().IsPointInside (ievent.e_x, ievent.e_y))
 
396
    if (GetGeometry().IsPointInside(ievent.e_x, ievent.e_y))
392
397
    {
393
398
      _mouse_down = true;
394
399
    }
395
400
    else
396
401
    {
397
402
      _mouse_down = false;
398
 
      Hide ();
 
403
      Hide();
399
404
      return nux::eMouseEventSolved;
400
405
    }
401
406
  }
402
407
  else if ((ievent.e_event == nux::NUX_MOUSE_RELEASED) && _mouse_down)
403
408
  {
404
409
    _mouse_down = false;
405
 
    Hide ();
 
410
    Hide();
406
411
    return nux::eMouseEventSolved;
407
412
  }
408
413
 
409
 
  ret = OnEvent (ievent, ret, ProcessEventInfo);
 
414
  ret = OnEvent(ievent, ret, ProcessEventInfo);
410
415
 
411
 
  return ret;    
 
416
  return ret;
412
417
}
413
418
 
414
 
void QuicklistView::Draw (nux::GraphicsEngine& gfxContext, bool forceDraw)
 
419
void QuicklistView::Draw(nux::GraphicsEngine& gfxContext, bool forceDraw)
415
420
{
416
421
  // Get the geometry of the QuicklistView on the display
417
422
  nux::Geometry base = GetGeometry();
418
423
 
419
 
  // Get the background of the QuicklistView and apply some 
 
424
  // Get the background of the QuicklistView and apply some
420
425
  if (_compute_blur_bkg /* Refresh the blurred background*/)
421
426
  {
422
 
    nux::ObjectPtr<nux::IOpenGLFrameBufferObject> current_fbo = nux::GetGraphicsDisplay ()->GetGpuDevice ()->GetCurrentFrameBufferObject ();
423
 
    nux::GetGraphicsDisplay ()->GetGpuDevice ()->DeactivateFrameBuffer ();
424
 
  
425
 
    gfxContext.SetViewport (0, 0, gfxContext.GetWindowWidth (), gfxContext.GetWindowHeight ());
426
 
    gfxContext.SetScissor (0, 0, gfxContext.GetWindowWidth (), gfxContext.GetWindowHeight ());
427
 
    gfxContext.GetRenderStates ().EnableScissor (false);
428
 
 
429
 
    nux::ObjectPtr <nux::IOpenGLBaseTexture> bkg_texture = gfxContext.CreateTextureFromBackBuffer (base.x, base.y, base.width, base.height);
 
427
    nux::ObjectPtr<nux::IOpenGLFrameBufferObject> current_fbo = nux::GetGraphicsDisplay()->GetGpuDevice()->GetCurrentFrameBufferObject();
 
428
    nux::GetGraphicsDisplay()->GetGpuDevice()->DeactivateFrameBuffer();
 
429
 
 
430
    gfxContext.SetViewport(0, 0, gfxContext.GetWindowWidth(), gfxContext.GetWindowHeight());
 
431
    gfxContext.SetScissor(0, 0, gfxContext.GetWindowWidth(), gfxContext.GetWindowHeight());
 
432
    gfxContext.GetRenderStates().EnableScissor(false);
 
433
 
 
434
    nux::ObjectPtr <nux::IOpenGLBaseTexture> bkg_texture = gfxContext.CreateTextureFromBackBuffer(base.x, base.y, base.width, base.height);
430
435
 
431
436
    nux::TexCoordXForm texxform_bkg;
432
 
    bkg_blur_texture = gfxContext.QRP_GetBlurTexture (0, 0, base.width, base.height, bkg_texture, texxform_bkg, nux::color::White, 1.0f, 3);
 
437
    bkg_blur_texture = gfxContext.QRP_GetBlurTexture(0, 0, base.width, base.height, bkg_texture, texxform_bkg, nux::color::White, 1.0f, 3);
433
438
 
434
 
    if (current_fbo.IsValid ())
435
 
    { 
436
 
      current_fbo->Activate (true);
437
 
      gfxContext.Push2DWindow (current_fbo->GetWidth (), current_fbo->GetHeight ());
 
439
    if (current_fbo.IsValid())
 
440
    {
 
441
      current_fbo->Activate(true);
 
442
      gfxContext.Push2DWindow(current_fbo->GetWidth(), current_fbo->GetHeight());
438
443
    }
439
444
    else
440
445
    {
441
 
      gfxContext.SetViewport (0, 0, gfxContext.GetWindowWidth (), gfxContext.GetWindowHeight ());
442
 
      gfxContext.Push2DWindow (gfxContext.GetWindowWidth (), gfxContext.GetWindowHeight ());
443
 
      gfxContext.ApplyClippingRectangle ();
 
446
      gfxContext.SetViewport(0, 0, gfxContext.GetWindowWidth(), gfxContext.GetWindowHeight());
 
447
      gfxContext.Push2DWindow(gfxContext.GetWindowWidth(), gfxContext.GetWindowHeight());
 
448
      gfxContext.ApplyClippingRectangle();
444
449
    }
445
450
    _compute_blur_bkg = false;
446
451
  }
447
452
 
448
453
  // the elements position inside the window are referenced to top-left window
449
454
  // corner. So bring base to (0, 0).
450
 
  base.SetX (0);
451
 
  base.SetY (0);
452
 
  gfxContext.PushClippingRectangle (base);
 
455
  base.SetX(0);
 
456
  base.SetY(0);
 
457
  gfxContext.PushClippingRectangle(base);
453
458
 
454
459
  nux::TexCoordXForm texxform_blur_bkg;
455
460
  //texxform_blur_bkg.SetWrap(nux::TEXWRAP_CLAMP, nux::TEXWRAP_CLAMP);
457
462
 
458
463
  nux::TexCoordXForm texxform_bg;
459
464
  texxform_bg.SetWrap(nux::TEXWRAP_CLAMP, nux::TEXWRAP_CLAMP);
460
 
  texxform_bg.SetTexCoordType (nux::TexCoordXForm::OFFSET_COORD);
 
465
  texxform_bg.SetTexCoordType(nux::TexCoordXForm::OFFSET_COORD);
461
466
 
462
467
  nux::TexCoordXForm texxform_mask;
463
468
  texxform_mask.SetWrap(nux::TEXWRAP_CLAMP, nux::TEXWRAP_CLAMP);
464
 
  texxform_mask.SetTexCoordType (nux::TexCoordXForm::OFFSET_COORD);
 
469
  texxform_mask.SetTexCoordType(nux::TexCoordXForm::OFFSET_COORD);
465
470
 
466
 
  if (bkg_blur_texture.IsValid ())
 
471
  if (bkg_blur_texture.IsValid())
467
472
  {
468
 
    gfxContext.QRP_2TexMod (
 
473
    gfxContext.QRP_2TexMod(
469
474
      base.x,
470
475
      base.y,
471
476
      base.width,
478
483
      nux::color::White);
479
484
  }
480
485
 
481
 
  nux::GetGraphicsEngine ().GetRenderStates ().SetBlend (true);
482
 
  nux::GetGraphicsEngine ().GetRenderStates ().SetPremultipliedBlend (nux::SRC_OVER);
483
 
  gfxContext.QRP_2TexMod (base.x,
484
 
    base.y,
485
 
    base.width,
486
 
    base.height,
487
 
    _texture_bg->GetDeviceTexture(),
488
 
    texxform_bg,
489
 
    nux::Color(1.0f, 1.0f, 1.0f, 1.0f),
490
 
    _texture_mask->GetDeviceTexture(),
491
 
    texxform_mask,
492
 
    nux::Color(1.0f, 1.0f, 1.0f, 1.0f));
 
486
  nux::GetGraphicsEngine().GetRenderStates().SetBlend(true);
 
487
  nux::GetGraphicsEngine().GetRenderStates().SetPremultipliedBlend(nux::SRC_OVER);
 
488
  gfxContext.QRP_2TexMod(base.x,
 
489
                         base.y,
 
490
                         base.width,
 
491
                         base.height,
 
492
                         _texture_bg->GetDeviceTexture(),
 
493
                         texxform_bg,
 
494
                         nux::Color(1.0f, 1.0f, 1.0f, 1.0f),
 
495
                         _texture_mask->GetDeviceTexture(),
 
496
                         texxform_mask,
 
497
                         nux::Color(1.0f, 1.0f, 1.0f, 1.0f));
493
498
 
494
499
 
495
500
  nux::TexCoordXForm texxform;
496
501
  texxform.SetWrap(nux::TEXWRAP_CLAMP, nux::TEXWRAP_CLAMP);
497
 
  texxform.SetTexCoordType (nux::TexCoordXForm::OFFSET_COORD);
498
 
 
499
 
  nux::GetGraphicsEngine ().GetRenderStates ().SetBlend (true);
500
 
  nux::GetGraphicsEngine ().GetRenderStates ().SetPremultipliedBlend (nux::SRC_OVER);
501
 
  gfxContext.QRP_1Tex (base.x,
502
 
    base.y,
503
 
    base.width,
504
 
    base.height,
505
 
    _texture_outline->GetDeviceTexture(),
506
 
    texxform,
507
 
    nux::Color(1.0f, 1.0f, 1.0f, 1.0f));
508
 
 
509
 
  nux::GetGraphicsEngine().GetRenderStates().SetBlend (false);
 
502
  texxform.SetTexCoordType(nux::TexCoordXForm::OFFSET_COORD);
 
503
 
 
504
  nux::GetGraphicsEngine().GetRenderStates().SetBlend(true);
 
505
  nux::GetGraphicsEngine().GetRenderStates().SetPremultipliedBlend(nux::SRC_OVER);
 
506
  gfxContext.QRP_1Tex(base.x,
 
507
                      base.y,
 
508
                      base.width,
 
509
                      base.height,
 
510
                      _texture_outline->GetDeviceTexture(),
 
511
                      texxform,
 
512
                      nux::Color(1.0f, 1.0f, 1.0f, 1.0f));
 
513
 
 
514
  nux::GetGraphicsEngine().GetRenderStates().SetBlend(false);
510
515
 
511
516
  std::list<QuicklistMenuItem*>::iterator it;
512
517
  for (it = _item_list.begin(); it != _item_list.end(); it++)
521
526
      (*it)->ProcessDraw(gfxContext, forceDraw);
522
527
  }
523
528
 
524
 
  gfxContext.PopClippingRectangle ();
 
529
  gfxContext.PopClippingRectangle();
525
530
}
526
531
 
527
 
void QuicklistView::DrawContent (nux::GraphicsEngine& GfxContext, bool force_draw)
 
532
void QuicklistView::DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw)
528
533
{
529
534
 
530
535
}
531
536
 
532
 
void QuicklistView::PreLayoutManagement ()
 
537
void QuicklistView::PreLayoutManagement()
533
538
{
534
539
  int MaxItemWidth = 0;
535
540
  int TotalItemHeight = 0;
536
 
  
 
541
 
537
542
  std::list<QuicklistMenuItem*>::iterator it;
538
543
  for (it = _item_list.begin(); it != _item_list.end(); it++)
539
544
  {
540
545
    // Make sure item is in layout if it should be
541
 
    if (!(*it)->GetVisible()) {
 
546
    if (!(*it)->GetVisible())
 
547
    {
542
548
      _item_layout->RemoveChildObject(*it);
543
549
      continue;
544
550
    }
556
562
  for (it = _default_item_list.begin(); it != _default_item_list.end(); it++)
557
563
  {
558
564
    // Make sure item is in layout if it should be
559
 
    if (!(*it)->GetVisible()) {
 
565
    if (!(*it)->GetVisible())
 
566
    {
560
567
      _default_item_layout->RemoveChildObject(*it);
561
568
      continue;
562
569
    }
571
578
    TotalItemHeight += textHeight;
572
579
  }
573
580
 
574
 
  if(TotalItemHeight < _anchor_height)
 
581
  if (TotalItemHeight < _anchor_height)
575
582
  {
576
 
    _top_space->SetMinMaxSize(1, (_anchor_height - TotalItemHeight)/2 +1 + _padding + _corner_radius);
577
 
    _bottom_space->SetMinMaxSize(1, (_anchor_height - TotalItemHeight)/2 +1 + _padding + _corner_radius);
 
583
    _top_space->SetMinMaxSize(1, (_anchor_height - TotalItemHeight) / 2 + 1 + _padding + _corner_radius);
 
584
    _bottom_space->SetMinMaxSize(1, (_anchor_height - TotalItemHeight) / 2 + 1 + _padding + _corner_radius);
578
585
  }
579
586
  else
580
587
  {
581
588
    _top_space->SetMinMaxSize(_padding + _corner_radius, _padding + _corner_radius);
582
589
    _bottom_space->SetMinMaxSize(_padding + _corner_radius, _padding + _corner_radius);
583
 
   }
 
590
  }
584
591
 
585
592
  _item_layout->SetMinimumWidth(MaxItemWidth);
586
593
  _default_item_layout->SetMinimumWidth(MaxItemWidth);
587
594
 
588
 
  BaseWindow::PreLayoutManagement ();
 
595
  BaseWindow::PreLayoutManagement();
589
596
}
590
597
 
591
 
long QuicklistView::PostLayoutManagement (long LayoutResult)
 
598
long QuicklistView::PostLayoutManagement(long LayoutResult)
592
599
{
593
 
  long result = BaseWindow::PostLayoutManagement (LayoutResult);
594
 
  
595
 
  UpdateTexture ();
 
600
  long result = BaseWindow::PostLayoutManagement(LayoutResult);
 
601
 
 
602
  UpdateTexture();
596
603
 
597
604
  int x = _padding + _anchor_width + _corner_radius;
598
605
  int y = _padding + _corner_radius;
603
610
    if (!(*it)->GetVisible())
604
611
      continue;
605
612
 
606
 
    (*it)->SetBaseX (x);
607
 
    (*it)->SetBaseY (y);
 
613
    (*it)->SetBaseX(x);
 
614
    (*it)->SetBaseY(y);
608
615
 
609
 
    y += (*it)->GetBaseHeight ();
 
616
    y += (*it)->GetBaseHeight();
610
617
  }
611
618
 
612
619
  for (it = _default_item_list.begin(); it != _default_item_list.end(); it++)
614
621
    if (!(*it)->GetVisible())
615
622
      continue;
616
623
 
617
 
    (*it)->SetBaseX (x);
618
 
    (*it)->SetBaseY (y);
 
624
    (*it)->SetBaseX(x);
 
625
    (*it)->SetBaseY(y);
619
626
 
620
 
    y += (*it)->GetBaseHeight ();
 
627
    y += (*it)->GetBaseHeight();
621
628
  }
622
629
 
623
630
  // We must correct the width of line separators. The rendering of the separator can be smaller than the width of the
624
 
  // quicklist. The reason for that is, the quicklist width is determined by the largest entry it contains. That size is 
 
631
  // quicklist. The reason for that is, the quicklist width is determined by the largest entry it contains. That size is
625
632
  // only after MaxItemWidth is computed in QuicklistView::PreLayoutManagement.
626
 
  // The setting of the separator width is done here after the Layout cycle for this widget is over. The width of the separator 
 
633
  // The setting of the separator width is done here after the Layout cycle for this widget is over. The width of the separator
627
634
  // has bee set correctly during the layout cycle, but the cairo rendering still need to be adjusted.
628
 
  int separator_width = nux::Max<int>(_default_item_layout->GetBaseWidth (), _item_layout->GetBaseWidth ());
629
 
  
 
635
  int separator_width = nux::Max<int>(_default_item_layout->GetBaseWidth(), _item_layout->GetBaseWidth());
 
636
 
630
637
  for (it = _item_list.begin(); it != _item_list.end(); it++)
631
638
  {
632
 
    QuicklistMenuItem* item = (QuicklistMenuItem*) (*it);
633
 
    if (item->GetVisible() && item->CairoSurfaceWidth () != separator_width)
 
639
    QuicklistMenuItem* item = (QuicklistMenuItem*)(*it);
 
640
    if (item->GetVisible() && item->CairoSurfaceWidth() != separator_width)
634
641
    {
635
642
      // Compute textures of the item.
636
 
      item->UpdateTexture ();
 
643
      item->UpdateTexture();
637
644
    }
638
645
  }
639
 
  
 
646
 
640
647
  for (it = _default_item_list.begin(); it != _default_item_list.end(); it++)
641
648
  {
642
 
    QuicklistMenuItem* item = (QuicklistMenuItem*) (*it);
643
 
    if (item->GetVisible() && item->CairoSurfaceWidth () != separator_width)
 
649
    QuicklistMenuItem* item = (QuicklistMenuItem*)(*it);
 
650
    if (item->GetVisible() && item->CairoSurfaceWidth() != separator_width)
644
651
    {
645
652
      // Compute textures of the item.
646
 
      item->UpdateTexture ();
 
653
      item->UpdateTexture();
647
654
    }
648
655
  }
649
656
 
650
657
  return result;
651
658
}
652
659
 
653
 
void QuicklistView::RecvCairoTextChanged (QuicklistMenuItem* cairo_text)
 
660
void QuicklistView::RecvCairoTextChanged(QuicklistMenuItem* cairo_text)
654
661
{
655
662
  _cairo_text_has_changed = true;
656
663
}
657
664
 
658
 
void QuicklistView::RecvCairoTextColorChanged (QuicklistMenuItem* cairo_text)
659
 
{
660
 
  NeedRedraw ();
661
 
}
662
 
 
663
 
void QuicklistView::RecvItemMouseClick (QuicklistMenuItem* item, int x, int y)
664
 
{
665
 
  _mouse_down = false;
666
 
  if (IsVisible () && item->GetEnabled ())
667
 
  {
668
 
    // Check if the mouse was released over an item and emit the signal
669
 
    CheckAndEmitItemSignal (x + item->GetBaseX (), y + item->GetBaseY ());
670
 
 
671
 
    Hide ();
672
 
  }
673
 
}
674
 
 
675
 
void QuicklistView::CheckAndEmitItemSignal (int x, int y)
676
 
677
 
  nux::Geometry geo;
678
 
  std::list<QuicklistMenuItem*>::iterator it;
679
 
  for (it = _item_list.begin(); it != _item_list.end(); it++)
680
 
  {
681
 
    if (!(*it)->GetVisible())
682
 
      continue;
683
 
 
684
 
    geo = (*it)->GetGeometry ();
685
 
    geo.width = _item_layout->GetBaseWidth ();
686
 
    
687
 
    if (geo.IsPointInside (x, y))
688
 
    {
689
 
      // An action is performed: send the signal back to the application
690
 
      if ((*it)->_menuItem)
691
 
      {
692
 
        dbusmenu_menuitem_handle_event ((*it)->_menuItem, "clicked", NULL, 0);
693
 
      }
694
 
    }
695
 
  }
696
 
 
697
 
  for (it = _default_item_list.begin(); it != _default_item_list.end(); it++)
698
 
  {
699
 
    if (!(*it)->GetVisible())
700
 
      continue;
701
 
 
702
 
    geo = (*it)->GetGeometry ();
703
 
    geo.width = _default_item_layout->GetBaseWidth ();
704
 
    
705
 
    if (geo.IsPointInside (x, y))
706
 
    {
707
 
      // An action is performed: send the signal back to the application
708
 
      if ((*it)->_menuItem)
709
 
      {
710
 
        dbusmenu_menuitem_handle_event ((*it)->_menuItem, "clicked", NULL, 0);
711
 
      }
712
 
    }
713
 
  } 
714
 
}
715
 
 
716
 
void QuicklistView::RecvItemMouseRelease (QuicklistMenuItem* item, int x, int y)
717
 
{
718
 
  _mouse_down = false;
719
 
  
720
 
  
721
 
  if (IsVisible () && item->GetEnabled ())
722
 
  {
723
 
    // Check if the mouse was released over an item and emit the signal
724
 
    CheckAndEmitItemSignal (x + item->GetBaseX (), y + item->GetBaseY ());
725
 
    
726
 
    Hide ();
727
 
  }  
728
 
}
729
 
 
730
 
void QuicklistView::CancelItemsPrelightStatus ()
731
 
{
732
 
  std::list<QuicklistMenuItem*>::iterator it;
733
 
  for (it = _item_list.begin(); it != _item_list.end(); it++)
734
 
  {
735
 
    (*it)->_prelight = false;
736
 
  }
737
 
 
738
 
  for (it = _default_item_list.begin(); it != _default_item_list.end(); it++)
739
 
  {
740
 
    (*it)->_prelight = false;
741
 
  }
742
 
}
743
 
 
744
 
void QuicklistView::RecvItemMouseDrag (QuicklistMenuItem* item, int x, int y)
745
 
{
746
 
  nux::Geometry geo;
747
 
  std::list<QuicklistMenuItem*>::iterator it;
748
 
  for (it = _item_list.begin(); it != _item_list.end(); it++)
749
 
  {
750
 
    if (!(*it)->GetVisible())
751
 
      continue;
752
 
 
753
 
    geo = (*it)->GetGeometry ();
754
 
    geo.width = _item_layout->GetBaseWidth ();
755
 
    
756
 
    if (geo.IsPointInside (x + item->GetBaseX (), y + item->GetBaseY ()))
757
 
    {
758
 
      (*it)->_prelight = true;
759
 
    }
760
 
    else
761
 
    {
762
 
      (*it)->_prelight = false;
763
 
    }
764
 
  }
765
 
 
766
 
  for (it = _default_item_list.begin(); it != _default_item_list.end(); it++)
767
 
  {
768
 
    if (!(*it)->GetVisible())
769
 
      continue;
770
 
 
771
 
    geo = (*it)->GetGeometry ();
772
 
    geo.width = _default_item_layout->GetBaseWidth ();
773
 
    
774
 
    if (geo.IsPointInside (x + item->GetBaseX (), y + item->GetBaseY ()))
775
 
    {
776
 
      (*it)->_prelight = true;
777
 
    }
778
 
    else
779
 
    {
780
 
      (*it)->_prelight = false;
781
 
    }
782
 
  }
783
 
  
784
 
  NeedRedraw ();
785
 
}
786
 
 
787
 
void QuicklistView::RecvItemMouseEnter (QuicklistMenuItem* item)
788
 
{
789
 
  NeedRedraw ();
790
 
}
791
 
 
792
 
void QuicklistView::RecvItemMouseLeave (QuicklistMenuItem* item)
793
 
{
794
 
  NeedRedraw ();
795
 
}
796
 
 
797
 
void QuicklistView::RecvMouseDown (int x, int y, unsigned long button_flags, unsigned long key_flags)
 
665
void QuicklistView::RecvCairoTextColorChanged(QuicklistMenuItem* cairo_text)
 
666
{
 
667
  NeedRedraw();
 
668
}
 
669
 
 
670
void QuicklistView::RecvItemMouseClick(QuicklistMenuItem* item, int x, int y)
 
671
{
 
672
  _mouse_down = false;
 
673
  if (IsVisible() && item->GetEnabled())
 
674
  {
 
675
    // Check if the mouse was released over an item and emit the signal
 
676
    CheckAndEmitItemSignal(x + item->GetBaseX(), y + item->GetBaseY());
 
677
 
 
678
    Hide();
 
679
  }
 
680
}
 
681
 
 
682
void QuicklistView::CheckAndEmitItemSignal(int x, int y)
 
683
{
 
684
  nux::Geometry geo;
 
685
  std::list<QuicklistMenuItem*>::iterator it;
 
686
  for (it = _item_list.begin(); it != _item_list.end(); it++)
 
687
  {
 
688
    if (!(*it)->GetVisible())
 
689
      continue;
 
690
 
 
691
    geo = (*it)->GetGeometry();
 
692
    geo.width = _item_layout->GetBaseWidth();
 
693
 
 
694
    if (geo.IsPointInside(x, y))
 
695
    {
 
696
      // An action is performed: send the signal back to the application
 
697
      if ((*it)->_menuItem)
 
698
      {
 
699
        dbusmenu_menuitem_handle_event((*it)->_menuItem, "clicked", NULL, 0);
 
700
      }
 
701
    }
 
702
  }
 
703
 
 
704
  for (it = _default_item_list.begin(); it != _default_item_list.end(); it++)
 
705
  {
 
706
    if (!(*it)->GetVisible())
 
707
      continue;
 
708
 
 
709
    geo = (*it)->GetGeometry();
 
710
    geo.width = _default_item_layout->GetBaseWidth();
 
711
 
 
712
    if (geo.IsPointInside(x, y))
 
713
    {
 
714
      // An action is performed: send the signal back to the application
 
715
      if ((*it)->_menuItem)
 
716
      {
 
717
        dbusmenu_menuitem_handle_event((*it)->_menuItem, "clicked", NULL, 0);
 
718
      }
 
719
    }
 
720
  }
 
721
}
 
722
 
 
723
void QuicklistView::RecvItemMouseRelease(QuicklistMenuItem* item, int x, int y)
 
724
{
 
725
  _mouse_down = false;
 
726
 
 
727
 
 
728
  if (IsVisible() && item->GetEnabled())
 
729
  {
 
730
    // Check if the mouse was released over an item and emit the signal
 
731
    CheckAndEmitItemSignal(x + item->GetBaseX(), y + item->GetBaseY());
 
732
 
 
733
    Hide();
 
734
  }
 
735
}
 
736
 
 
737
void QuicklistView::CancelItemsPrelightStatus()
 
738
{
 
739
  std::list<QuicklistMenuItem*>::iterator it;
 
740
  for (it = _item_list.begin(); it != _item_list.end(); it++)
 
741
  {
 
742
    (*it)->_prelight = false;
 
743
  }
 
744
 
 
745
  for (it = _default_item_list.begin(); it != _default_item_list.end(); it++)
 
746
  {
 
747
    (*it)->_prelight = false;
 
748
  }
 
749
}
 
750
 
 
751
void QuicklistView::RecvItemMouseDrag(QuicklistMenuItem* item, int x, int y)
 
752
{
 
753
  nux::Geometry geo;
 
754
  std::list<QuicklistMenuItem*>::iterator it;
 
755
  for (it = _item_list.begin(); it != _item_list.end(); it++)
 
756
  {
 
757
    if (!(*it)->GetVisible())
 
758
      continue;
 
759
 
 
760
    geo = (*it)->GetGeometry();
 
761
    geo.width = _item_layout->GetBaseWidth();
 
762
 
 
763
    if (geo.IsPointInside(x + item->GetBaseX(), y + item->GetBaseY()))
 
764
    {
 
765
      (*it)->_prelight = true;
 
766
    }
 
767
    else
 
768
    {
 
769
      (*it)->_prelight = false;
 
770
    }
 
771
  }
 
772
 
 
773
  for (it = _default_item_list.begin(); it != _default_item_list.end(); it++)
 
774
  {
 
775
    if (!(*it)->GetVisible())
 
776
      continue;
 
777
 
 
778
    geo = (*it)->GetGeometry();
 
779
    geo.width = _default_item_layout->GetBaseWidth();
 
780
 
 
781
    if (geo.IsPointInside(x + item->GetBaseX(), y + item->GetBaseY()))
 
782
    {
 
783
      (*it)->_prelight = true;
 
784
    }
 
785
    else
 
786
    {
 
787
      (*it)->_prelight = false;
 
788
    }
 
789
  }
 
790
 
 
791
  NeedRedraw();
 
792
}
 
793
 
 
794
void QuicklistView::RecvItemMouseEnter(QuicklistMenuItem* item)
 
795
{
 
796
  NeedRedraw();
 
797
}
 
798
 
 
799
void QuicklistView::RecvItemMouseLeave(QuicklistMenuItem* item)
 
800
{
 
801
  NeedRedraw();
 
802
}
 
803
 
 
804
void QuicklistView::RecvMouseDown(int x, int y, unsigned long button_flags, unsigned long key_flags)
798
805
{
799
806
//     if (IsVisible ())
800
807
//     {
806
813
//     }
807
814
}
808
815
 
809
 
void QuicklistView::RecvMouseUp (int x, int y, unsigned long button_flags, unsigned long key_flags)
 
816
void QuicklistView::RecvMouseUp(int x, int y, unsigned long button_flags, unsigned long key_flags)
810
817
{
811
 
    // Check if the mouse was released over an item and emit the signal
812
 
    CheckAndEmitItemSignal (x, y);
 
818
  // Check if the mouse was released over an item and emit the signal
 
819
  CheckAndEmitItemSignal(x, y);
813
820
}
814
821
 
815
 
void QuicklistView::RecvMouseClick (int x, int y, unsigned long button_flags, unsigned long key_flags)
 
822
void QuicklistView::RecvMouseClick(int x, int y, unsigned long button_flags, unsigned long key_flags)
816
823
{
817
 
  if (IsVisible ())
 
824
  if (IsVisible())
818
825
  {
819
 
    Hide ();
 
826
    Hide();
820
827
  }
821
828
}
822
829
 
823
 
void QuicklistView::RecvMouseMove (int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags)
824
 
{
825
 
 
826
 
}
827
 
 
828
 
void QuicklistView::RecvMouseDrag (int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags)
829
 
{
830
 
 
831
 
}
832
 
  
833
 
void QuicklistView::RecvMouseDownOutsideOfQuicklist (int x, int y, unsigned long button_flags, unsigned long key_flags)
834
 
{
835
 
  Hide ();
836
 
}
837
 
 
838
 
void QuicklistView::RemoveAllMenuItem ()
 
830
void QuicklistView::RecvMouseMove(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags)
 
831
{
 
832
 
 
833
}
 
834
 
 
835
void QuicklistView::RecvMouseDrag(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags)
 
836
{
 
837
 
 
838
}
 
839
 
 
840
void QuicklistView::RecvMouseDownOutsideOfQuicklist(int x, int y, unsigned long button_flags, unsigned long key_flags)
 
841
{
 
842
  Hide();
 
843
}
 
844
 
 
845
void QuicklistView::RemoveAllMenuItem()
839
846
{
840
847
  std::list<QuicklistMenuItem*>::iterator it;
841
848
  for (it = _item_list.begin(); it != _item_list.end(); it++)
842
849
  {
843
850
    // Remove from introspection
844
 
    RemoveChild (*it);
 
851
    RemoveChild(*it);
845
852
    (*it)->UnReference();
846
853
  }
847
 
  
 
854
 
848
855
  for (it = _default_item_list.begin(); it != _default_item_list.end(); it++)
849
856
  {
850
857
    // Remove from introspection
851
 
    RemoveChild (*it);
 
858
    RemoveChild(*it);
852
859
    (*it)->UnReference();
853
860
  }
854
 
  
855
 
  _item_list.clear ();
856
 
  _default_item_list.clear ();
857
 
  
858
 
  _item_layout->Clear ();
859
 
  _default_item_layout->Clear ();
 
861
 
 
862
  _item_list.clear();
 
863
  _default_item_list.clear();
 
864
 
 
865
  _item_layout->Clear();
 
866
  _default_item_layout->Clear();
860
867
  _cairo_text_has_changed = true;
861
 
  nux::GetGraphicsThread ()->AddObjectToRefreshList (this);
 
868
  nux::GetGraphicsThread()->AddObjectToRefreshList(this);
862
869
}
863
870
 
864
 
void QuicklistView::AddMenuItem (QuicklistMenuItem* item)
 
871
void QuicklistView::AddMenuItem(QuicklistMenuItem* item)
865
872
{
866
873
  if (item == 0)
867
874
    return;
868
875
 
869
 
  item->sigTextChanged.connect (sigc::mem_fun (this, &QuicklistView::RecvCairoTextChanged));
870
 
  item->sigColorChanged.connect (sigc::mem_fun (this, &QuicklistView::RecvCairoTextColorChanged));
871
 
  item->sigMouseClick.connect (sigc::mem_fun (this, &QuicklistView::RecvItemMouseClick));
872
 
  item->sigMouseReleased.connect (sigc::mem_fun (this, &QuicklistView::RecvItemMouseRelease));
873
 
  item->sigMouseEnter.connect (sigc::mem_fun (this, &QuicklistView::RecvItemMouseEnter));
874
 
  item->sigMouseLeave.connect (sigc::mem_fun (this, &QuicklistView::RecvItemMouseLeave));
875
 
  item->sigMouseDrag.connect (sigc::mem_fun (this, &QuicklistView::RecvItemMouseDrag));
876
 
   
877
 
  _item_list.push_back (item);
 
876
  item->sigTextChanged.connect(sigc::mem_fun(this, &QuicklistView::RecvCairoTextChanged));
 
877
  item->sigColorChanged.connect(sigc::mem_fun(this, &QuicklistView::RecvCairoTextColorChanged));
 
878
  item->sigMouseClick.connect(sigc::mem_fun(this, &QuicklistView::RecvItemMouseClick));
 
879
  item->sigMouseReleased.connect(sigc::mem_fun(this, &QuicklistView::RecvItemMouseRelease));
 
880
  item->sigMouseEnter.connect(sigc::mem_fun(this, &QuicklistView::RecvItemMouseEnter));
 
881
  item->sigMouseLeave.connect(sigc::mem_fun(this, &QuicklistView::RecvItemMouseLeave));
 
882
  item->sigMouseDrag.connect(sigc::mem_fun(this, &QuicklistView::RecvItemMouseDrag));
 
883
 
 
884
  _item_list.push_back(item);
878
885
  item->Reference();
879
886
  // Add to introspection
880
 
  AddChild (item);
881
 
  
 
887
  AddChild(item);
 
888
 
882
889
  _cairo_text_has_changed = true;
883
 
  nux::GetGraphicsThread ()->AddObjectToRefreshList (this);
884
 
  NeedRedraw ();
885
 
}
886
 
 
887
 
void QuicklistView::RenderQuicklistView ()
888
 
{
889
 
  
890
 
}
891
 
 
892
 
int QuicklistView::GetNumItems ()
893
 
{
894
 
  return _item_list.size () + _default_item_list.size ();
895
 
}
896
 
 
897
 
QuicklistMenuItem* QuicklistView::GetNthItems (int index)
898
 
{
899
 
  if (index < (int)_item_list.size ())
 
890
  nux::GetGraphicsThread()->AddObjectToRefreshList(this);
 
891
  NeedRedraw();
 
892
}
 
893
 
 
894
void QuicklistView::RenderQuicklistView()
 
895
{
 
896
 
 
897
}
 
898
 
 
899
int QuicklistView::GetNumItems()
 
900
{
 
901
  return _item_list.size() + _default_item_list.size();
 
902
}
 
903
 
 
904
QuicklistMenuItem* QuicklistView::GetNthItems(int index)
 
905
{
 
906
  if (index < (int)_item_list.size())
900
907
  {
901
908
    int i = 0;
902
909
    std::list<QuicklistMenuItem*>::iterator it;
907
914
    }
908
915
  }
909
916
 
910
 
  if (index < (int)_item_list.size () + (int)_default_item_list.size ())
 
917
  if (index < (int)_item_list.size() + (int)_default_item_list.size())
911
918
  {
912
919
    int i = 0;
913
 
    if (_item_list.size () > 0)
914
 
      i = _item_list.size () -1;
 
920
    if (_item_list.size() > 0)
 
921
      i = _item_list.size() - 1;
915
922
    std::list<QuicklistMenuItem*>::iterator it;
916
923
    for (it = _item_list.begin(); it != _item_list.end(); i++, it++)
917
924
    {
923
930
  return 0;
924
931
}
925
932
 
926
 
QuicklistMenuItemType QuicklistView::GetNthType  (int index)
 
933
QuicklistMenuItemType QuicklistView::GetNthType(int index)
927
934
{
928
 
  QuicklistMenuItem* item = GetNthItems (index);
 
935
  QuicklistMenuItem* item = GetNthItems(index);
929
936
  if (item)
930
 
    return item->GetItemType ();
 
937
    return item->GetItemType();
931
938
  return MENUITEM_TYPE_UNKNOWN;
932
939
}
933
940
 
934
 
std::list<QuicklistMenuItem*> QuicklistView::GetChildren ()
 
941
std::list<QuicklistMenuItem*> QuicklistView::GetChildren()
935
942
{
936
943
  std::list<QuicklistMenuItem*> l;
937
944
  return l;
938
945
}
939
946
 
940
 
void QuicklistView::DefaultToFirstItem ()
 
947
void QuicklistView::DefaultToFirstItem()
941
948
{
942
 
  if (GetNumItems () >= 1)
 
949
  if (GetNumItems() >= 1)
943
950
  {
944
 
    GetNthItems (0)->_prelight= true;
945
 
    QueueDraw ();
 
951
    GetNthItems(0)->_prelight = true;
 
952
    QueueDraw();
946
953
  }
947
954
}
948
 
  
949
 
void ql_tint_dot_hl (cairo_t* cr,
950
 
  gint    width,
951
 
  gint    height,
952
 
  gfloat  hl_x,
953
 
  gfloat  hl_y,
954
 
  gfloat  hl_size,
955
 
  gfloat* rgba_tint,
956
 
  gfloat* rgba_hl,
957
 
  gfloat* rgba_dot)
 
955
 
 
956
void ql_tint_dot_hl(cairo_t* cr,
 
957
                    gint    width,
 
958
                    gint    height,
 
959
                    gfloat  hl_x,
 
960
                    gfloat  hl_y,
 
961
                    gfloat  hl_size,
 
962
                    gfloat* rgba_tint,
 
963
                    gfloat* rgba_hl,
 
964
                    gfloat* rgba_dot)
958
965
{
959
966
  cairo_surface_t* dots_surf    = NULL;
960
967
  cairo_t*         dots_cr      = NULL;
962
969
  cairo_pattern_t* hl_pattern   = NULL;
963
970
 
964
971
  // create context for dot-pattern
965
 
  dots_surf = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 4, 4);
966
 
  dots_cr = cairo_create (dots_surf);
 
972
  dots_surf = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 4, 4);
 
973
  dots_cr = cairo_create(dots_surf);
967
974
 
968
975
  // clear normal context
969
 
  cairo_scale (cr, 1.0f, 1.0f);
970
 
  cairo_set_source_rgba (cr, 0.0f, 0.0f, 0.0f, 0.0f);
971
 
  cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR);
972
 
  cairo_paint (cr);
 
976
  cairo_scale(cr, 1.0f, 1.0f);
 
977
  cairo_set_source_rgba(cr, 0.0f, 0.0f, 0.0f, 0.0f);
 
978
  cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR);
 
979
  cairo_paint(cr);
973
980
 
974
981
  // prepare drawing for normal context
975
 
  cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
 
982
  cairo_set_operator(cr, CAIRO_OPERATOR_OVER);
976
983
 
977
984
  // create path in normal context
978
 
  cairo_rectangle (cr, 0.0f, 0.0f, (gdouble) width, (gdouble) height);  
 
985
  cairo_rectangle(cr, 0.0f, 0.0f, (gdouble) width, (gdouble) height);
979
986
 
980
987
  // fill path of normal context with tint
981
 
  cairo_set_source_rgba (cr,
982
 
    rgba_tint[0],
983
 
    rgba_tint[1],
984
 
    rgba_tint[2],
985
 
    rgba_tint[3]);
986
 
  cairo_fill_preserve (cr);
 
988
  cairo_set_source_rgba(cr,
 
989
                        rgba_tint[0],
 
990
                        rgba_tint[1],
 
991
                        rgba_tint[2],
 
992
                        rgba_tint[3]);
 
993
  cairo_fill_preserve(cr);
987
994
 
988
995
  // create pattern in dot-context
989
 
  cairo_set_operator (dots_cr, CAIRO_OPERATOR_CLEAR);
990
 
  cairo_paint (dots_cr);
991
 
  cairo_scale (dots_cr, 1.0f, 1.0f);
992
 
  cairo_set_operator (dots_cr, CAIRO_OPERATOR_OVER);
993
 
  cairo_set_source_rgba (dots_cr,
994
 
    rgba_dot[0],
995
 
    rgba_dot[1],
996
 
    rgba_dot[2],
997
 
    rgba_dot[3]);
998
 
  cairo_rectangle (dots_cr, 0.0f, 0.0f, 1.0f, 1.0f);
999
 
  cairo_fill (dots_cr);
1000
 
  cairo_rectangle (dots_cr, 2.0f, 2.0f, 1.0f, 1.0f);
1001
 
  cairo_fill (dots_cr);
1002
 
  dots_pattern = cairo_pattern_create_for_surface (dots_surf);
 
996
  cairo_set_operator(dots_cr, CAIRO_OPERATOR_CLEAR);
 
997
  cairo_paint(dots_cr);
 
998
  cairo_scale(dots_cr, 1.0f, 1.0f);
 
999
  cairo_set_operator(dots_cr, CAIRO_OPERATOR_OVER);
 
1000
  cairo_set_source_rgba(dots_cr,
 
1001
                        rgba_dot[0],
 
1002
                        rgba_dot[1],
 
1003
                        rgba_dot[2],
 
1004
                        rgba_dot[3]);
 
1005
  cairo_rectangle(dots_cr, 0.0f, 0.0f, 1.0f, 1.0f);
 
1006
  cairo_fill(dots_cr);
 
1007
  cairo_rectangle(dots_cr, 2.0f, 2.0f, 1.0f, 1.0f);
 
1008
  cairo_fill(dots_cr);
 
1009
  dots_pattern = cairo_pattern_create_for_surface(dots_surf);
1003
1010
 
1004
1011
  // fill path of normal context with dot-pattern
1005
 
  cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
1006
 
  cairo_set_source (cr, dots_pattern);
1007
 
  cairo_pattern_set_extend (dots_pattern, CAIRO_EXTEND_REPEAT);
1008
 
  cairo_fill_preserve (cr);
1009
 
  cairo_pattern_destroy (dots_pattern);
1010
 
  cairo_surface_destroy (dots_surf);
1011
 
  cairo_destroy (dots_cr);
 
1012
  cairo_set_operator(cr, CAIRO_OPERATOR_OVER);
 
1013
  cairo_set_source(cr, dots_pattern);
 
1014
  cairo_pattern_set_extend(dots_pattern, CAIRO_EXTEND_REPEAT);
 
1015
  cairo_fill_preserve(cr);
 
1016
  cairo_pattern_destroy(dots_pattern);
 
1017
  cairo_surface_destroy(dots_surf);
 
1018
  cairo_destroy(dots_cr);
1012
1019
 
1013
1020
  // draw highlight
1014
 
  cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
1015
 
  hl_pattern = cairo_pattern_create_radial (hl_x,
1016
 
    hl_y,
1017
 
    0.0f,
1018
 
    hl_x,
1019
 
    hl_y,
1020
 
    hl_size);
1021
 
  cairo_pattern_add_color_stop_rgba (hl_pattern,
1022
 
    0.0f,
1023
 
    rgba_hl[0],
1024
 
    rgba_hl[1],
1025
 
    rgba_hl[2],
1026
 
    rgba_hl[3]);
1027
 
  cairo_pattern_add_color_stop_rgba (hl_pattern, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f);
1028
 
  cairo_set_source (cr, hl_pattern);
1029
 
  cairo_fill (cr);
1030
 
  cairo_pattern_destroy (hl_pattern);
 
1021
  cairo_set_operator(cr, CAIRO_OPERATOR_OVER);
 
1022
  hl_pattern = cairo_pattern_create_radial(hl_x,
 
1023
                                           hl_y,
 
1024
                                           0.0f,
 
1025
                                           hl_x,
 
1026
                                           hl_y,
 
1027
                                           hl_size);
 
1028
  cairo_pattern_add_color_stop_rgba(hl_pattern,
 
1029
                                    0.0f,
 
1030
                                    rgba_hl[0],
 
1031
                                    rgba_hl[1],
 
1032
                                    rgba_hl[2],
 
1033
                                    rgba_hl[3]);
 
1034
  cairo_pattern_add_color_stop_rgba(hl_pattern, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f);
 
1035
  cairo_set_source(cr, hl_pattern);
 
1036
  cairo_fill(cr);
 
1037
  cairo_pattern_destroy(hl_pattern);
1031
1038
}
1032
1039
 
1033
 
void ql_setup (cairo_surface_t** surf,
1034
 
  cairo_t**         cr,
1035
 
  gboolean          outline,
1036
 
  gint              width,
1037
 
  gint              height,
1038
 
  gboolean          negative)
 
1040
void ql_setup(cairo_surface_t** surf,
 
1041
              cairo_t**         cr,
 
1042
              gboolean          outline,
 
1043
              gint              width,
 
1044
              gint              height,
 
1045
              gboolean          negative)
1039
1046
{
1040
1047
//     // create context
1041
1048
//     if (outline)
1045
1052
//     *cr = cairo_create (*surf);
1046
1053
 
1047
1054
  // clear context
1048
 
  cairo_scale (*cr, 1.0f, 1.0f);
 
1055
  cairo_scale(*cr, 1.0f, 1.0f);
1049
1056
  if (outline)
1050
1057
  {
1051
 
    cairo_set_source_rgba (*cr, 0.0f, 0.0f, 0.0f, 0.0f);
1052
 
    cairo_set_operator (*cr, CAIRO_OPERATOR_CLEAR);
1053
 
  }  
 
1058
    cairo_set_source_rgba(*cr, 0.0f, 0.0f, 0.0f, 0.0f);
 
1059
    cairo_set_operator(*cr, CAIRO_OPERATOR_CLEAR);
 
1060
  }
1054
1061
  else
1055
1062
  {
1056
 
    cairo_set_operator (*cr, CAIRO_OPERATOR_OVER);
 
1063
    cairo_set_operator(*cr, CAIRO_OPERATOR_OVER);
1057
1064
    if (negative)
1058
 
      cairo_set_source_rgba (*cr, 0.0f, 0.0f, 0.0f, 0.0f);
 
1065
      cairo_set_source_rgba(*cr, 0.0f, 0.0f, 0.0f, 0.0f);
1059
1066
    else
1060
 
      cairo_set_source_rgba (*cr, 1.0f, 1.0f, 1.0f, 1.0f);
 
1067
      cairo_set_source_rgba(*cr, 1.0f, 1.0f, 1.0f, 1.0f);
1061
1068
  }
1062
 
  cairo_paint (*cr);
 
1069
  cairo_paint(*cr);
1063
1070
}
1064
1071
 
1065
 
void ql_compute_full_mask_path (cairo_t* cr,
1066
 
  gfloat   anchor_width,
1067
 
  gfloat   anchor_height,
1068
 
  gint     width,
1069
 
  gint     height,
1070
 
  gint     upper_size,
1071
 
  gfloat   radius,
1072
 
  guint    pad)
 
1072
void ql_compute_full_mask_path(cairo_t* cr,
 
1073
                               gfloat   anchor_width,
 
1074
                               gfloat   anchor_height,
 
1075
                               gint     width,
 
1076
                               gint     height,
 
1077
                               gint     upper_size,
 
1078
                               gfloat   radius,
 
1079
                               guint    pad)
1073
1080
{
1074
1081
  //     0  1        2  3
1075
1082
  //     +--+--------+--+
1098
1105
  int ZEROPOINT5 = 0.0f;
1099
1106
 
1100
1107
  gfloat HeightToAnchor = 0.0f;
1101
 
  HeightToAnchor = ((gfloat) height - 2.0f * radius - anchor_height -2*padding) / 2.0f;
 
1108
  HeightToAnchor = ((gfloat) height - 2.0f * radius - anchor_height - 2 * padding) / 2.0f;
1102
1109
  if (HeightToAnchor < 0.0f)
1103
1110
  {
1104
 
    g_warning ("Anchor-height and corner-radius a higher than whole texture!");
 
1111
    g_warning("Anchor-height and corner-radius a higher than whole texture!");
1105
1112
    return;
1106
1113
  }
1107
1114
 
1109
1116
  //gint upper_dynamic_size = upper_size;
1110
1117
  //gint lower_dynamic_size = dynamic_size - upper_dynamic_size;
1111
1118
 
1112
 
  if(upper_size >= 0)
 
1119
  if (upper_size >= 0)
1113
1120
  {
1114
 
    if(upper_size > height - 2.0f * radius - anchor_height -2 * padding)
 
1121
    if (upper_size > height - 2.0f * radius - anchor_height - 2 * padding)
1115
1122
    {
1116
1123
      //g_warning ("[_compute_full_mask_path] incorrect upper_size value");
1117
1124
      HeightToAnchor = 0;
1118
1125
    }
1119
1126
    else
1120
1127
    {
1121
 
      HeightToAnchor = height - 2.0f * radius - anchor_height -2 * padding - upper_size;
 
1128
      HeightToAnchor = height - 2.0f * radius - anchor_height - 2 * padding - upper_size;
1122
1129
    }
1123
1130
  }
1124
1131
  else
1125
1132
  {
1126
 
    HeightToAnchor = (height - 2.0f * radius - anchor_height -2*padding) / 2.0f;
 
1133
    HeightToAnchor = (height - 2.0f * radius - anchor_height - 2 * padding) / 2.0f;
1127
1134
  }
1128
1135
 
1129
 
  cairo_translate (cr, -0.5f, -0.5f);
 
1136
  cairo_translate(cr, -0.5f, -0.5f);
1130
1137
 
1131
1138
  // create path
1132
 
  cairo_move_to (cr, padding + anchor_width + radius + ZEROPOINT5, padding + ZEROPOINT5); // Point 1
1133
 
  cairo_line_to (cr, width - padding - radius, padding + ZEROPOINT5);   // Point 2
1134
 
  cairo_arc (cr,
1135
 
    width  - padding - radius + ZEROPOINT5,
1136
 
    padding + radius + ZEROPOINT5,
1137
 
    radius,
1138
 
    -90.0f * G_PI / 180.0f,
1139
 
    0.0f * G_PI / 180.0f);   // Point 4
1140
 
  cairo_line_to (cr,
1141
 
    (gdouble) width - padding + ZEROPOINT5,
1142
 
    (gdouble) height - radius - padding + ZEROPOINT5); // Point 5
1143
 
  cairo_arc (cr,
1144
 
    (gdouble) width - padding - radius + ZEROPOINT5,
1145
 
    (gdouble) height - padding - radius + ZEROPOINT5,
1146
 
    radius,
1147
 
    0.0f * G_PI / 180.0f,
1148
 
    90.0f * G_PI / 180.0f);  // Point 7
1149
 
  cairo_line_to (cr,
1150
 
    anchor_width + padding + radius + ZEROPOINT5,
1151
 
    (gdouble) height - padding + ZEROPOINT5); // Point 8
1152
 
 
1153
 
  cairo_arc (cr,
1154
 
    anchor_width + padding + radius + ZEROPOINT5,
1155
 
    (gdouble) height - padding - radius,
1156
 
    radius,
1157
 
    90.0f * G_PI / 180.0f,
1158
 
    180.0f * G_PI / 180.0f); // Point 10
1159
 
 
1160
 
  cairo_line_to (cr,
1161
 
    padding + anchor_width + ZEROPOINT5,
1162
 
    (gdouble) height - padding - radius - HeightToAnchor + ZEROPOINT5 );  // Point 11
1163
 
  cairo_line_to (cr,
1164
 
    padding + ZEROPOINT5,
1165
 
    (gdouble) height - padding - radius - HeightToAnchor - anchor_height / 2.0f + ZEROPOINT5); // Point 12
1166
 
  cairo_line_to (cr,
1167
 
    padding + anchor_width + ZEROPOINT5,
1168
 
    (gdouble) height - padding - radius - HeightToAnchor - anchor_height + ZEROPOINT5);  // Point 13
1169
 
 
1170
 
  cairo_line_to (cr, padding + anchor_width + ZEROPOINT5, padding + radius  + ZEROPOINT5);  // Point 14
1171
 
  cairo_arc (cr,
1172
 
    padding + anchor_width + radius + ZEROPOINT5,
1173
 
    padding + radius + ZEROPOINT5,
1174
 
    radius,
1175
 
    180.0f * G_PI / 180.0f,
1176
 
    270.0f * G_PI / 180.0f);
1177
 
 
1178
 
  cairo_close_path (cr);
 
1139
  cairo_move_to(cr, padding + anchor_width + radius + ZEROPOINT5, padding + ZEROPOINT5);  // Point 1
 
1140
  cairo_line_to(cr, width - padding - radius, padding + ZEROPOINT5);    // Point 2
 
1141
  cairo_arc(cr,
 
1142
            width  - padding - radius + ZEROPOINT5,
 
1143
            padding + radius + ZEROPOINT5,
 
1144
            radius,
 
1145
            -90.0f * G_PI / 180.0f,
 
1146
            0.0f * G_PI / 180.0f);   // Point 4
 
1147
  cairo_line_to(cr,
 
1148
                (gdouble) width - padding + ZEROPOINT5,
 
1149
                (gdouble) height - radius - padding + ZEROPOINT5); // Point 5
 
1150
  cairo_arc(cr,
 
1151
            (gdouble) width - padding - radius + ZEROPOINT5,
 
1152
            (gdouble) height - padding - radius + ZEROPOINT5,
 
1153
            radius,
 
1154
            0.0f * G_PI / 180.0f,
 
1155
            90.0f * G_PI / 180.0f);  // Point 7
 
1156
  cairo_line_to(cr,
 
1157
                anchor_width + padding + radius + ZEROPOINT5,
 
1158
                (gdouble) height - padding + ZEROPOINT5); // Point 8
 
1159
 
 
1160
  cairo_arc(cr,
 
1161
            anchor_width + padding + radius + ZEROPOINT5,
 
1162
            (gdouble) height - padding - radius,
 
1163
            radius,
 
1164
            90.0f * G_PI / 180.0f,
 
1165
            180.0f * G_PI / 180.0f); // Point 10
 
1166
 
 
1167
  cairo_line_to(cr,
 
1168
                padding + anchor_width + ZEROPOINT5,
 
1169
                (gdouble) height - padding - radius - HeightToAnchor + ZEROPOINT5);   // Point 11
 
1170
  cairo_line_to(cr,
 
1171
                padding + ZEROPOINT5,
 
1172
                (gdouble) height - padding - radius - HeightToAnchor - anchor_height / 2.0f + ZEROPOINT5); // Point 12
 
1173
  cairo_line_to(cr,
 
1174
                padding + anchor_width + ZEROPOINT5,
 
1175
                (gdouble) height - padding - radius - HeightToAnchor - anchor_height + ZEROPOINT5);  // Point 13
 
1176
 
 
1177
  cairo_line_to(cr, padding + anchor_width + ZEROPOINT5, padding + radius  + ZEROPOINT5);   // Point 14
 
1178
  cairo_arc(cr,
 
1179
            padding + anchor_width + radius + ZEROPOINT5,
 
1180
            padding + radius + ZEROPOINT5,
 
1181
            radius,
 
1182
            180.0f * G_PI / 180.0f,
 
1183
            270.0f * G_PI / 180.0f);
 
1184
 
 
1185
  cairo_close_path(cr);
1179
1186
}
1180
1187
 
1181
 
void ql_compute_mask (cairo_t* cr)
 
1188
void ql_compute_mask(cairo_t* cr)
1182
1189
{
1183
 
  cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR);
1184
 
  cairo_fill_preserve (cr);
 
1190
  cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR);
 
1191
  cairo_fill_preserve(cr);
1185
1192
}
1186
1193
 
1187
 
void ql_compute_outline (cairo_t* cr,
1188
 
                         gfloat   line_width,
1189
 
                         gfloat*  rgba_line,
1190
 
                         gfloat   size)
 
1194
void ql_compute_outline(cairo_t* cr,
 
1195
                        gfloat   line_width,
 
1196
                        gfloat*  rgba_line,
 
1197
                        gfloat   size)
1191
1198
{
1192
1199
  cairo_pattern_t* pattern = NULL;
1193
1200
  float            x       = 0.0f;
1194
1201
  float            y       = 0.0f;
1195
1202
  float            offset  = 2.5f * ANCHOR_WIDTH / size;
1196
1203
 
1197
 
  cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
1198
 
 
1199
 
  pattern = cairo_pattern_create_linear (x, y, size, y);
1200
 
  cairo_pattern_add_color_stop_rgba (pattern, 0.0f,
1201
 
    rgba_line[0],
1202
 
    rgba_line[1],
1203
 
    rgba_line[2],
1204
 
    rgba_line[3]);
1205
 
  cairo_pattern_add_color_stop_rgba (pattern, offset,
1206
 
    rgba_line[0],
1207
 
    rgba_line[1],
1208
 
    rgba_line[2],
1209
 
    rgba_line[3]);
1210
 
  cairo_pattern_add_color_stop_rgba (pattern, 1.1f * offset,
1211
 
    rgba_line[0] * 0.65f,
1212
 
    rgba_line[1] * 0.65f,
1213
 
    rgba_line[2] * 0.65f,
1214
 
    rgba_line[3]);
1215
 
  cairo_pattern_add_color_stop_rgba (pattern, 1.0f,
1216
 
    rgba_line[0] * 0.65f,
1217
 
    rgba_line[1] * 0.65f,
1218
 
    rgba_line[2] * 0.65f,
1219
 
    rgba_line[3]);
1220
 
  cairo_set_source (cr, pattern);
1221
 
  cairo_set_line_width (cr, line_width);
1222
 
  cairo_stroke (cr);
1223
 
  cairo_pattern_destroy (pattern);
1224
 
}
1225
 
 
1226
 
void ql_draw (cairo_t* cr,
1227
 
  gboolean outline,
1228
 
  gfloat   line_width,
1229
 
  gfloat*  rgba,
1230
 
  gboolean negative,
1231
 
  gboolean stroke)
1232
 
{
1233
 
  // prepare drawing
1234
 
  cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
1235
 
 
1236
 
  // actually draw the mask
1237
 
  if (outline)
1238
 
  {
1239
 
    cairo_set_line_width (cr, line_width);
1240
 
    cairo_set_source_rgba (cr, rgba[0], rgba[1], rgba[2], rgba[3]);
1241
 
  }
1242
 
  else
1243
 
  {
1244
 
    if (negative)
1245
 
      cairo_set_source_rgba (cr, 1.0f, 1.0f, 1.0f, 1.0f);
1246
 
    else
1247
 
      cairo_set_source_rgba (cr, 0.0f, 0.0f, 0.0f, 0.0f);
1248
 
  }
1249
 
 
1250
 
  // stroke or fill?
1251
 
  if (stroke)
1252
 
    cairo_stroke_preserve (cr);
1253
 
  else
1254
 
    cairo_fill_preserve (cr);
1255
 
}
1256
 
 
1257
 
void ql_finalize (cairo_t** cr,
1258
 
  gboolean  outline,
1259
 
  gfloat    line_width,
1260
 
  gfloat*   rgba,
1261
 
  gboolean  negative,
1262
 
  gboolean  stroke)
1263
 
{
1264
 
  // prepare drawing
1265
 
  cairo_set_operator (*cr, CAIRO_OPERATOR_SOURCE);
1266
 
 
1267
 
  // actually draw the mask
1268
 
  if (outline)
1269
 
  {
1270
 
    cairo_set_line_width (*cr, line_width);
1271
 
    cairo_set_source_rgba (*cr, rgba[0], rgba[1], rgba[2], rgba[3]);
1272
 
  }
1273
 
  else
1274
 
  {
1275
 
    if (negative)
1276
 
      cairo_set_source_rgba (*cr, 1.0f, 1.0f, 1.0f, 1.0f);
1277
 
    else
1278
 
      cairo_set_source_rgba (*cr, 0.0f, 0.0f, 0.0f, 0.0f);
1279
 
  }
1280
 
 
1281
 
  // stroke or fill?
1282
 
  if (stroke)
1283
 
    cairo_stroke (*cr);
1284
 
  else
1285
 
    cairo_fill (*cr);
 
1204
  cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
 
1205
 
 
1206
  pattern = cairo_pattern_create_linear(x, y, size, y);
 
1207
  cairo_pattern_add_color_stop_rgba(pattern, 0.0f,
 
1208
                                    rgba_line[0],
 
1209
                                    rgba_line[1],
 
1210
                                    rgba_line[2],
 
1211
                                    rgba_line[3]);
 
1212
  cairo_pattern_add_color_stop_rgba(pattern, offset,
 
1213
                                    rgba_line[0],
 
1214
                                    rgba_line[1],
 
1215
                                    rgba_line[2],
 
1216
                                    rgba_line[3]);
 
1217
  cairo_pattern_add_color_stop_rgba(pattern, 1.1f * offset,
 
1218
                                    rgba_line[0] * 0.65f,
 
1219
                                    rgba_line[1] * 0.65f,
 
1220
                                    rgba_line[2] * 0.65f,
 
1221
                                    rgba_line[3]);
 
1222
  cairo_pattern_add_color_stop_rgba(pattern, 1.0f,
 
1223
                                    rgba_line[0] * 0.65f,
 
1224
                                    rgba_line[1] * 0.65f,
 
1225
                                    rgba_line[2] * 0.65f,
 
1226
                                    rgba_line[3]);
 
1227
  cairo_set_source(cr, pattern);
 
1228
  cairo_set_line_width(cr, line_width);
 
1229
  cairo_stroke(cr);
 
1230
  cairo_pattern_destroy(pattern);
 
1231
}
 
1232
 
 
1233
void ql_draw(cairo_t* cr,
 
1234
             gboolean outline,
 
1235
             gfloat   line_width,
 
1236
             gfloat*  rgba,
 
1237
             gboolean negative,
 
1238
             gboolean stroke)
 
1239
{
 
1240
  // prepare drawing
 
1241
  cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
 
1242
 
 
1243
  // actually draw the mask
 
1244
  if (outline)
 
1245
  {
 
1246
    cairo_set_line_width(cr, line_width);
 
1247
    cairo_set_source_rgba(cr, rgba[0], rgba[1], rgba[2], rgba[3]);
 
1248
  }
 
1249
  else
 
1250
  {
 
1251
    if (negative)
 
1252
      cairo_set_source_rgba(cr, 1.0f, 1.0f, 1.0f, 1.0f);
 
1253
    else
 
1254
      cairo_set_source_rgba(cr, 0.0f, 0.0f, 0.0f, 0.0f);
 
1255
  }
 
1256
 
 
1257
  // stroke or fill?
 
1258
  if (stroke)
 
1259
    cairo_stroke_preserve(cr);
 
1260
  else
 
1261
    cairo_fill_preserve(cr);
 
1262
}
 
1263
 
 
1264
void ql_finalize(cairo_t** cr,
 
1265
                 gboolean  outline,
 
1266
                 gfloat    line_width,
 
1267
                 gfloat*   rgba,
 
1268
                 gboolean  negative,
 
1269
                 gboolean  stroke)
 
1270
{
 
1271
  // prepare drawing
 
1272
  cairo_set_operator(*cr, CAIRO_OPERATOR_SOURCE);
 
1273
 
 
1274
  // actually draw the mask
 
1275
  if (outline)
 
1276
  {
 
1277
    cairo_set_line_width(*cr, line_width);
 
1278
    cairo_set_source_rgba(*cr, rgba[0], rgba[1], rgba[2], rgba[3]);
 
1279
  }
 
1280
  else
 
1281
  {
 
1282
    if (negative)
 
1283
      cairo_set_source_rgba(*cr, 1.0f, 1.0f, 1.0f, 1.0f);
 
1284
    else
 
1285
      cairo_set_source_rgba(*cr, 0.0f, 0.0f, 0.0f, 0.0f);
 
1286
  }
 
1287
 
 
1288
  // stroke or fill?
 
1289
  if (stroke)
 
1290
    cairo_stroke(*cr);
 
1291
  else
 
1292
    cairo_fill(*cr);
1286
1293
}
1287
1294
 
1288
1295
void
1289
 
  ql_compute_full_outline_shadow (
 
1296
ql_compute_full_outline_shadow(
1290
1297
  cairo_t* cr,
1291
1298
  cairo_surface_t* surf,
1292
1299
  gint    width,
1301
1308
  gint    padding_size,
1302
1309
  gfloat* rgba_line)
1303
1310
{
1304
 
  ql_setup (&surf, &cr, TRUE, width, height, FALSE);
1305
 
  ql_compute_full_mask_path (cr,
1306
 
    anchor_width,
1307
 
    anchor_height,
1308
 
    width,
1309
 
    height,
1310
 
    upper_size,
1311
 
    corner_radius,
1312
 
    padding_size);
 
1311
  ql_setup(&surf, &cr, TRUE, width, height, FALSE);
 
1312
  ql_compute_full_mask_path(cr,
 
1313
                            anchor_width,
 
1314
                            anchor_height,
 
1315
                            width,
 
1316
                            height,
 
1317
                            upper_size,
 
1318
                            corner_radius,
 
1319
                            padding_size);
1313
1320
 
1314
 
  ql_draw (cr, TRUE, line_width, rgba_shadow, FALSE, FALSE);
1315
 
  nux::CairoGraphics* dummy = new nux::CairoGraphics (CAIRO_FORMAT_A1, 1, 1);
1316
 
  dummy->BlurSurface (blur_coeff, surf);
 
1321
  ql_draw(cr, TRUE, line_width, rgba_shadow, FALSE, FALSE);
 
1322
  nux::CairoGraphics* dummy = new nux::CairoGraphics(CAIRO_FORMAT_A1, 1, 1);
 
1323
  dummy->BlurSurface(blur_coeff, surf);
1317
1324
  delete dummy;
1318
 
  ql_compute_mask (cr);
1319
 
  ql_compute_outline (cr, line_width, rgba_line, width);
 
1325
  ql_compute_mask(cr);
 
1326
  ql_compute_outline(cr, line_width, rgba_line, width);
1320
1327
}
1321
1328
 
1322
 
void ql_compute_full_mask (
 
1329
void ql_compute_full_mask(
1323
1330
  cairo_t* cr,
1324
1331
  cairo_surface_t* surf,
1325
1332
  gint     width,
1335
1342
  gint     padding_size,
1336
1343
  gfloat*  rgba)
1337
1344
{
1338
 
  ql_setup (&surf, &cr, outline, width, height, negative);
1339
 
  ql_compute_full_mask_path (cr,
1340
 
    anchor_width,
1341
 
    anchor_height,
1342
 
    width,
1343
 
    height,
1344
 
    upper_size,
1345
 
    radius,
1346
 
    padding_size);
1347
 
  ql_finalize (&cr, outline, line_width, rgba, negative, outline);
 
1345
  ql_setup(&surf, &cr, outline, width, height, negative);
 
1346
  ql_compute_full_mask_path(cr,
 
1347
                            anchor_width,
 
1348
                            anchor_height,
 
1349
                            width,
 
1350
                            height,
 
1351
                            upper_size,
 
1352
                            radius,
 
1353
                            padding_size);
 
1354
  ql_finalize(&cr, outline, line_width, rgba, negative, outline);
1348
1355
}
1349
1356
 
1350
 
void QuicklistView::UpdateTexture ()
 
1357
void QuicklistView::UpdateTexture()
1351
1358
{
1352
1359
  if (_cairo_text_has_changed == false)
1353
1360
    return;
1356
1363
 
1357
1364
  if (!_enable_quicklist_for_testing)
1358
1365
  {
1359
 
    if ((_item_list.size () != 0) || (_default_item_list.size () != 0))
 
1366
    if ((_item_list.size() != 0) || (_default_item_list.size() != 0))
1360
1367
    {
1361
 
      int offscreen_size = GetBaseY () +
1362
 
                           GetBaseHeight () -
1363
 
                           nux::GetWindow().GetWindowHeight ();
 
1368
      int offscreen_size = GetBaseY() +
 
1369
                           GetBaseHeight() -
 
1370
                           nux::GetWindow().GetWindowHeight();
1364
1371
 
1365
1372
      if (offscreen_size > 0)
1366
1373
        _top_size = offscreen_size;
1369
1376
 
1370
1377
      size_above_anchor = _top_size;
1371
1378
      int x = _anchorX - _padding;
1372
 
      int y = _anchorY - _anchor_height/2 - _top_size - _corner_radius - _padding;
 
1379
      int y = _anchorY - _anchor_height / 2 - _top_size - _corner_radius - _padding;
1373
1380
 
1374
 
      SetBaseX (x);
1375
 
      SetBaseY (y);
 
1381
      SetBaseX(x);
 
1382
      SetBaseY(y);
1376
1383
    }
1377
1384
    else
1378
1385
    {
1379
1386
      _top_size = 0;
1380
1387
      size_above_anchor = -1;
1381
1388
      int x = _anchorX - _padding;
1382
 
      int y = _anchorY - _anchor_height/2 - _top_size - _corner_radius - _padding;
 
1389
      int y = _anchorY - _anchor_height / 2 - _top_size - _corner_radius - _padding;
1383
1390
 
1384
 
      SetBaseX (x);
1385
 
      SetBaseY (y);    
 
1391
      SetBaseX(x);
 
1392
      SetBaseY(y);
1386
1393
    }
1387
1394
  }
1388
 
  
 
1395
 
1389
1396
  float blur_coef         = 6.0f;
1390
1397
 
1391
 
  nux::CairoGraphics* cairo_bg       = new nux::CairoGraphics (CAIRO_FORMAT_ARGB32, GetBaseWidth (), GetBaseHeight ());
1392
 
  nux::CairoGraphics* cairo_mask     = new nux::CairoGraphics (CAIRO_FORMAT_ARGB32, GetBaseWidth (), GetBaseHeight ());
1393
 
  nux::CairoGraphics* cairo_outline  = new nux::CairoGraphics (CAIRO_FORMAT_ARGB32, GetBaseWidth (), GetBaseHeight ());
 
1398
  nux::CairoGraphics* cairo_bg       = new nux::CairoGraphics(CAIRO_FORMAT_ARGB32, GetBaseWidth(), GetBaseHeight());
 
1399
  nux::CairoGraphics* cairo_mask     = new nux::CairoGraphics(CAIRO_FORMAT_ARGB32, GetBaseWidth(), GetBaseHeight());
 
1400
  nux::CairoGraphics* cairo_outline  = new nux::CairoGraphics(CAIRO_FORMAT_ARGB32, GetBaseWidth(), GetBaseHeight());
1394
1401
 
1395
 
  cairo_t *cr_bg      = cairo_bg->GetContext ();
1396
 
  cairo_t *cr_mask    = cairo_mask->GetContext ();
1397
 
  cairo_t *cr_outline = cairo_outline->GetContext ();
 
1402
  cairo_t* cr_bg      = cairo_bg->GetContext();
 
1403
  cairo_t* cr_mask    = cairo_mask->GetContext();
 
1404
  cairo_t* cr_outline = cairo_outline->GetContext();
1398
1405
 
1399
1406
  float   tint_color[4]    = {0.0f, 0.0f, 0.0f, 0.80f};
1400
1407
  float   hl_color[4]      = {1.0f, 1.0f, 1.0f, 0.65f};
1405
1412
//   float   anchor_width      = 10;
1406
1413
//   float   anchor_height     = 18;
1407
1414
 
1408
 
  ql_tint_dot_hl (cr_bg,
1409
 
    GetBaseWidth (),
1410
 
    GetBaseHeight (),
1411
 
    GetBaseWidth () / 2.0f,
1412
 
    0,
1413
 
    nux::Max<float>(GetBaseWidth () / 1.3f, GetBaseHeight () / 1.3f),
1414
 
    tint_color,
1415
 
    hl_color,
1416
 
    dot_color);
 
1415
  ql_tint_dot_hl(cr_bg,
 
1416
                 GetBaseWidth(),
 
1417
                 GetBaseHeight(),
 
1418
                 GetBaseWidth() / 2.0f,
 
1419
                 0,
 
1420
                 nux::Max<float>(GetBaseWidth() / 1.3f, GetBaseHeight() / 1.3f),
 
1421
                 tint_color,
 
1422
                 hl_color,
 
1423
                 dot_color);
1417
1424
 
1418
1425
  ql_compute_full_outline_shadow
1419
 
    (
 
1426
  (
1420
1427
    cr_outline,
1421
1428
    cairo_outline->GetSurface(),
1422
 
    GetBaseWidth (),
1423
 
    GetBaseHeight (),
 
1429
    GetBaseWidth(),
 
1430
    GetBaseHeight(),
1424
1431
    _anchor_width,
1425
1432
    _anchor_height,
1426
1433
    size_above_anchor,
1431
1438
    _padding,
1432
1439
    outline_color);
1433
1440
 
1434
 
  ql_compute_full_mask (
 
1441
  ql_compute_full_mask(
1435
1442
    cr_mask,
1436
1443
    cairo_mask->GetSurface(),
1437
 
    GetBaseWidth (),
 
1444
    GetBaseWidth(),
1438
1445
    GetBaseHeight(),
1439
1446
    _corner_radius,  // radius,
1440
1447
    16,             // shadow_radius,
1447
1454
    _padding,        // padding_size,
1448
1455
    mask_color);
1449
1456
 
1450
 
  cairo_destroy (cr_bg);
1451
 
  cairo_destroy (cr_outline);
1452
 
  cairo_destroy (cr_mask);
 
1457
  cairo_destroy(cr_bg);
 
1458
  cairo_destroy(cr_outline);
 
1459
  cairo_destroy(cr_mask);
1453
1460
 
1454
1461
  nux::NBitmapData* bitmap = cairo_bg->GetBitmap();
1455
1462
 
1456
1463
  if (_texture_bg)
1457
 
    _texture_bg->UnReference ();
1458
 
  _texture_bg = nux::GetGraphicsDisplay ()->GetGpuDevice ()->CreateSystemCapableTexture ();
 
1464
    _texture_bg->UnReference();
 
1465
  _texture_bg = nux::GetGraphicsDisplay()->GetGpuDevice()->CreateSystemCapableTexture();
1459
1466
  _texture_bg->Update(bitmap);
1460
1467
  delete bitmap;
1461
1468
 
1462
1469
  bitmap = cairo_mask->GetBitmap();
1463
1470
  if (_texture_mask)
1464
 
    _texture_mask->UnReference ();
1465
 
  _texture_mask = nux::GetGraphicsDisplay ()->GetGpuDevice ()->CreateSystemCapableTexture ();
 
1471
    _texture_mask->UnReference();
 
1472
  _texture_mask = nux::GetGraphicsDisplay()->GetGpuDevice()->CreateSystemCapableTexture();
1466
1473
  _texture_mask->Update(bitmap);
1467
1474
  delete bitmap;
1468
1475
 
1469
1476
  bitmap = cairo_outline->GetBitmap();
1470
1477
  if (_texture_outline)
1471
 
    _texture_outline->UnReference ();
1472
 
  _texture_outline = nux::GetGraphicsDisplay ()->GetGpuDevice ()->CreateSystemCapableTexture ();
 
1478
    _texture_outline->UnReference();
 
1479
  _texture_outline = nux::GetGraphicsDisplay()->GetGpuDevice()->CreateSystemCapableTexture();
1473
1480
  _texture_outline->Update(bitmap);
1474
1481
  delete bitmap;
1475
1482
 
1477
1484
  delete cairo_mask;
1478
1485
  delete cairo_outline;
1479
1486
  _cairo_text_has_changed = false;
1480
 
  
 
1487
 
1481
1488
  // Request a redraw, so this area will be added to Compiz list of dirty areas.
1482
 
  NeedRedraw ();
1483
 
}
1484
 
 
1485
 
void QuicklistView::PositionChildLayout (float offsetX, float offsetY)
1486
 
{
1487
 
}
1488
 
 
1489
 
void QuicklistView::LayoutWindowElements ()
1490
 
{
1491
 
}
1492
 
 
1493
 
void QuicklistView::NotifyConfigurationChange (int width, int height)
1494
 
{
1495
 
}
1496
 
 
1497
 
void QuicklistView::SetText (nux::NString text)
 
1489
  NeedRedraw();
 
1490
}
 
1491
 
 
1492
void QuicklistView::PositionChildLayout(float offsetX, float offsetY)
 
1493
{
 
1494
}
 
1495
 
 
1496
void QuicklistView::LayoutWindowElements()
 
1497
{
 
1498
}
 
1499
 
 
1500
void QuicklistView::NotifyConfigurationChange(int width, int height)
 
1501
{
 
1502
}
 
1503
 
 
1504
void QuicklistView::SetText(nux::NString text)
1498
1505
{
1499
1506
  if (_labelText == text)
1500
1507
    return;
1501
1508
 
1502
1509
  _labelText = text;
1503
 
  UpdateTexture ();
 
1510
  UpdateTexture();
1504
1511
}
1505
1512
 
1506
 
void QuicklistView::TestMenuItems (DbusmenuMenuitem* root)
 
1513
void QuicklistView::TestMenuItems(DbusmenuMenuitem* root)
1507
1514
{
1508
 
  RemoveAllMenuItem ();
1509
 
  
 
1515
  RemoveAllMenuItem();
 
1516
 
1510
1517
  if (root == 0)
1511
1518
    return;
1512
 
  
1513
 
  GList * child = NULL;
 
1519
 
 
1520
  GList* child = NULL;
1514
1521
  for (child = dbusmenu_menuitem_get_children(root); child != NULL; child = g_list_next(child))
1515
1522
  {
1516
 
    const gchar* type = dbusmenu_menuitem_property_get ((DbusmenuMenuitem*)child->data, DBUSMENU_MENUITEM_PROP_TYPE);
1517
 
    const gchar* toggle_type = dbusmenu_menuitem_property_get ((DbusmenuMenuitem*)child->data, DBUSMENU_MENUITEM_PROP_TOGGLE_TYPE);
1518
 
    
1519
 
    if (g_strcmp0 (type, DBUSMENU_CLIENT_TYPES_SEPARATOR) == 0)
1520
 
    {
1521
 
      QuicklistMenuItemSeparator* item = new QuicklistMenuItemSeparator ((DbusmenuMenuitem*)child->data, NUX_TRACKER_LOCATION);
1522
 
      AddMenuItem (item);
1523
 
    }
1524
 
    else if (g_strcmp0 (toggle_type, DBUSMENU_MENUITEM_TOGGLE_CHECK) == 0)    
1525
 
    {
1526
 
      QuicklistMenuItemCheckmark* item = new QuicklistMenuItemCheckmark ((DbusmenuMenuitem*)child->data, NUX_TRACKER_LOCATION);
1527
 
      AddMenuItem (item);
1528
 
    }
1529
 
    else if (g_strcmp0 (toggle_type, DBUSMENU_MENUITEM_TOGGLE_RADIO) == 0)    
1530
 
    {
1531
 
      QuicklistMenuItemRadio* item = new QuicklistMenuItemRadio ((DbusmenuMenuitem*)child->data, NUX_TRACKER_LOCATION);
1532
 
      AddMenuItem (item);
1533
 
    }
1534
 
    else //if (g_strcmp0 (type, DBUSMENU_MENUITEM_PROP_LABEL) == 0)    
1535
 
    {
1536
 
      QuicklistMenuItemLabel* item = new QuicklistMenuItemLabel ((DbusmenuMenuitem*)child->data, NUX_TRACKER_LOCATION);
1537
 
      AddMenuItem (item);
 
1523
    const gchar* type = dbusmenu_menuitem_property_get((DbusmenuMenuitem*)child->data, DBUSMENU_MENUITEM_PROP_TYPE);
 
1524
    const gchar* toggle_type = dbusmenu_menuitem_property_get((DbusmenuMenuitem*)child->data, DBUSMENU_MENUITEM_PROP_TOGGLE_TYPE);
 
1525
 
 
1526
    if (g_strcmp0(type, DBUSMENU_CLIENT_TYPES_SEPARATOR) == 0)
 
1527
    {
 
1528
      QuicklistMenuItemSeparator* item = new QuicklistMenuItemSeparator((DbusmenuMenuitem*)child->data, NUX_TRACKER_LOCATION);
 
1529
      AddMenuItem(item);
 
1530
    }
 
1531
    else if (g_strcmp0(toggle_type, DBUSMENU_MENUITEM_TOGGLE_CHECK) == 0)
 
1532
    {
 
1533
      QuicklistMenuItemCheckmark* item = new QuicklistMenuItemCheckmark((DbusmenuMenuitem*)child->data, NUX_TRACKER_LOCATION);
 
1534
      AddMenuItem(item);
 
1535
    }
 
1536
    else if (g_strcmp0(toggle_type, DBUSMENU_MENUITEM_TOGGLE_RADIO) == 0)
 
1537
    {
 
1538
      QuicklistMenuItemRadio* item = new QuicklistMenuItemRadio((DbusmenuMenuitem*)child->data, NUX_TRACKER_LOCATION);
 
1539
      AddMenuItem(item);
 
1540
    }
 
1541
    else //if (g_strcmp0 (type, DBUSMENU_MENUITEM_PROP_LABEL) == 0)
 
1542
    {
 
1543
      QuicklistMenuItemLabel* item = new QuicklistMenuItemLabel((DbusmenuMenuitem*)child->data, NUX_TRACKER_LOCATION);
 
1544
      AddMenuItem(item);
1538
1545
    }
1539
1546
  }
1540
1547
}
1541
1548
 
1542
1549
// Introspection
1543
1550
 
1544
 
const gchar* QuicklistView::GetName ()
1545
 
{
1546
 
  return g_strdup (_name);
1547
 
}
1548
 
 
1549
 
void QuicklistView::AddProperties (GVariantBuilder *builder)
1550
 
{
1551
 
  g_variant_builder_add (builder, "{sv}", "x", g_variant_new_int32  (GetBaseX ()));
1552
 
  g_variant_builder_add (builder, "{sv}", "y", g_variant_new_int32  (GetBaseY ()));
1553
 
  g_variant_builder_add (builder, "{sv}", "width", g_variant_new_int32 (GetBaseWidth ()));
1554
 
  g_variant_builder_add (builder, "{sv}", "height", g_variant_new_int32 (GetBaseHeight ()));
1555
 
  g_variant_builder_add (builder, "{sv}", "active", g_variant_new_boolean (IsVisible ()));
 
1551
const gchar* QuicklistView::GetName()
 
1552
{
 
1553
  return g_strdup(_name);
 
1554
}
 
1555
 
 
1556
void QuicklistView::AddProperties(GVariantBuilder* builder)
 
1557
{
 
1558
  g_variant_builder_add(builder, "{sv}", "x", g_variant_new_int32(GetBaseX()));
 
1559
  g_variant_builder_add(builder, "{sv}", "y", g_variant_new_int32(GetBaseY()));
 
1560
  g_variant_builder_add(builder, "{sv}", "width", g_variant_new_int32(GetBaseWidth()));
 
1561
  g_variant_builder_add(builder, "{sv}", "height", g_variant_new_int32(GetBaseHeight()));
 
1562
  g_variant_builder_add(builder, "{sv}", "active", g_variant_new_boolean(IsVisible()));
 
1563
}
 
1564
 
 
1565
//
 
1566
// Key navigation
 
1567
//
 
1568
bool
 
1569
QuicklistView::InspectKeyEvent(unsigned int eventType,
 
1570
                               unsigned int keysym,
 
1571
                               const char* character)
 
1572
{
 
1573
  // The Quicklist accepts all key inputs.
 
1574
  return true;
1556
1575
}
1557
1576