~hikiko/nux/arb-srgba-shader

« back to all changes in this revision

Viewing changes to Nux/ScrollView.cpp

  • Committer: Travis Watkins
  • Date: 2011-08-03 10:34:36 UTC
  • mfrom: (409 nux-logger-fix)
  • mto: (454.5.1 nux-gles)
  • mto: This revision was merged to the branch mainline in revision 501.
  • Revision ID: travis.watkins@linaro.org-20110803103436-biz9c9930l2refsi
merge with lp:nux

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
    _delta_y                        = 0;
45
45
 
46
46
    //GetPainter().CreateBackgroundTexture(m_BackgroundTexture);
47
 
    hscrollbar = new HScrollBar (NUX_TRACKER_LOCATION);
48
 
    vscrollbar = new VScrollBar (NUX_TRACKER_LOCATION);
 
47
    _hscrollbar = new HScrollBar (NUX_TRACKER_LOCATION);
 
48
    _vscrollbar = new VScrollBar (NUX_TRACKER_LOCATION);
 
49
    // _hscrollbar and _vscrollbar have to be parented so they are correctly
 
50
    // rendered and so that GetRootGeometry/GetAbsoluteGeometry returns the
 
51
    // correct Geometry. This is necessary in embedded mode.
 
52
    _hscrollbar->SetParentObject (this);
 
53
    _vscrollbar->SetParentObject (this);
 
54
 
 
55
    _hscrollbar->SetReconfigureParentLayoutOnGeometryChange(false);
 
56
    _vscrollbar->SetReconfigureParentLayoutOnGeometryChange(false);
49
57
 
50
58
    SetMinimumSize (30, 30);
51
59
    SetGeometry (Geometry (0, 0, 400, 200) );
52
60
 
53
 
    hscrollbar->OnScrollLeft.connect ( sigc::mem_fun (this, &ScrollView::ScrollLeft) );
54
 
    hscrollbar->OnScrollRight.connect ( sigc::mem_fun (this, &ScrollView::ScrollRight) );
55
 
    vscrollbar->OnScrollUp.connect ( sigc::mem_fun (this, &ScrollView::ScrollUp) );
56
 
    vscrollbar->OnScrollDown.connect ( sigc::mem_fun (this, &ScrollView::ScrollDown) );
 
61
    _hscrollbar->OnScrollLeft.connect ( sigc::mem_fun (this, &ScrollView::ScrollLeft) );
 
62
    _hscrollbar->OnScrollRight.connect ( sigc::mem_fun (this, &ScrollView::ScrollRight) );
 
63
    _vscrollbar->OnScrollUp.connect ( sigc::mem_fun (this, &ScrollView::ScrollUp) );
 
64
    _vscrollbar->OnScrollDown.connect ( sigc::mem_fun (this, &ScrollView::ScrollDown) );
57
65
 
58
 
    // hscrollbar and vscrollbar have to be parented so they are correctly
59
 
    // rendered and so that GetRootGeometry/GetAbsoluteGeometry returns the
60
 
    // correct Geometry. This is necessary in embedded mode.
61
 
    hscrollbar->SetParentObject (this);
62
 
    vscrollbar->SetParentObject (this);
 
66
    mouse_wheel.connect(sigc::mem_fun(this, &ScrollView::RecvMouseWheel));
 
67
    _vscrollbar->mouse_wheel.connect(sigc::mem_fun(this, &ScrollView::RecvMouseWheel));
63
68
 
64
69
    setTopBorder (4);
65
70
    setBorder (4);
74
79
 
75
80
    ChildFocusChanged.connect (sigc::mem_fun (this, &ScrollView::OnChildFocusChanged));
76
81
 
 
82
    SetAcceptMouseWheelEvent(true);
77
83
  }
78
84
 
79
 
  void
80
 
  ScrollView::SetVScrollBar (VScrollBar* newVScrollBar)
 
85
  // customization for Unity
 
86
  void ScrollView::SetVScrollBar (VScrollBar* newVScrollBar)
81
87
  {
82
 
    if (vscrollbar)
 
88
    if(_vscrollbar)
83
89
    {
84
 
      // disconnect old vscrollbar
85
 
      vscrollbar->OnScrollUp.connect (sigc::mem_fun (this,
 
90
      // disconnect old _vscrollbar
 
91
      _vscrollbar->OnScrollUp.connect (sigc::mem_fun (this,
86
92
                                                     &ScrollView::ScrollUp));
87
 
      vscrollbar->OnScrollDown.connect (sigc::mem_fun (this,
 
93
      _vscrollbar->OnScrollDown.connect (sigc::mem_fun (this,
88
94
                                                       &ScrollView::ScrollDown));
89
 
      if (vscrollbar->OwnsTheReference ())
90
 
      {
91
 
        vscrollbar->UnReference ();
92
 
      }
93
 
      else
94
 
      {
95
 
        vscrollbar->Dispose ();
96
 
      }
 
95
      _vscrollbar->UnReference ();
97
96
    }
98
97
 
99
 
    vscrollbar = newVScrollBar;
100
 
 
101
 
    vscrollbar->Reference ();
102
 
    vscrollbar->SetParentObject (this);
103
 
 
104
 
    // connect new vscrollbar
105
 
    vscrollbar->OnScrollUp.connect (sigc::mem_fun (this,
 
98
    _vscrollbar = newVScrollBar;
 
99
 
 
100
    _vscrollbar->Reference ();
 
101
    _vscrollbar->SetParentObject (this);
 
102
    _vscrollbar->SetReconfigureParentLayoutOnGeometryChange(false);
 
103
 
 
104
    // connect new _vscrollbar
 
105
    _vscrollbar->OnScrollUp.connect (sigc::mem_fun (this,
106
106
                                                   &ScrollView::ScrollUp));
107
 
    vscrollbar->OnScrollDown.connect (sigc::mem_fun (this,
 
107
    _vscrollbar->OnScrollDown.connect (sigc::mem_fun (this,
108
108
                                                     &ScrollView::ScrollDown));
109
109
  }
110
110
 
111
111
  ScrollView::~ScrollView()
112
112
  {
113
113
    // Delete all the interface object: This is a problem... The widget should be destroy by there associated parameters
114
 
    if (hscrollbar->OwnsTheReference ())
115
 
    {
116
 
      hscrollbar->UnReference ();
117
 
    }
118
 
    else
119
 
    {
120
 
      hscrollbar->Dispose ();
121
 
    }
122
 
 
123
 
    if (vscrollbar->OwnsTheReference ())
124
 
    {
125
 
      vscrollbar->UnReference ();
126
 
    }
127
 
    else
128
 
    {
129
 
      vscrollbar->Dispose ();
130
 
    }
 
114
    _hscrollbar->UnReference ();
 
115
    _vscrollbar->UnReference ();
131
116
  }
132
117
 
133
 
  void ScrollView::OnChildFocusChanged (Area *parent, Area *child)
 
118
  void ScrollView::OnChildFocusChanged (/*Area *parent,*/ Area *child)
134
119
  {
135
120
    if (child->IsView ())
136
121
    {
168
153
 
169
154
  }
170
155
 
171
 
 
172
156
  long ScrollView::ProcessEvent (Event &event, long TraverseInfo, long ProcessEventInfo)
173
157
  {
174
158
    long ret = TraverseInfo;
183
167
      }
184
168
    }
185
169
 
186
 
    if (event.e_event == NUX_MOUSEWHEEL)
 
170
    if (event.e_event == NUX_MOUSE_WHEEL)
187
171
    {
188
172
      // nux can't tell the difference between horizontal and vertical mouse wheel events
189
173
      // so we are only going to support vertical
198
182
    }
199
183
 
200
184
    if (m_vertical_scrollbar_enable)
201
 
      ret = vscrollbar->ProcessEvent (event, ret, ProcEvInfo);
 
185
      ret = _vscrollbar->ProcessEvent (event, ret, ProcEvInfo);
202
186
 
203
187
    if (m_horizontal_scrollbar_enable)
204
 
      ret = hscrollbar->ProcessEvent (event, ret, ProcEvInfo);
 
188
      ret = _hscrollbar->ProcessEvent (event, ret, ProcEvInfo);
205
189
 
206
190
    // The child layout get the Mouse down button only if the MouseDown happened inside the client view Area
207
191
    Geometry viewGeometry = Geometry (m_ViewX, m_ViewY, m_ViewWidth, m_ViewHeight);
224
208
      ret = m_CompositionLayout->ProcessEvent (mod_event, ret, ProcEvInfo);
225
209
    }
226
210
 
227
 
 
228
 
 
229
211
    ret = PostProcessEvent2 (event, ret, 0);
230
212
    return ret;
231
213
  }
232
214
 
 
215
  Area* ScrollView::FindAreaUnderMouse(const Point& mouse_position, NuxEventType event_type)
 
216
  {
 
217
    // Test if the mouse is inside the ScrollView.
 
218
    // The last parameter of TestMousePointerInclusion is a boolean used to test if the case
 
219
    // of mouse wheel events. If that boolean value is true, then TestMousePointerInclusion 
 
220
    // returns true only if the mouse pointer is over this area and the the area accepts
 
221
    // mouse wheel events (see Area::SetAcceptMouseWheelEvent)
 
222
    bool mouse_inside = TestMousePointerInclusionFilterMouseWheel(mouse_position, event_type);
 
223
 
 
224
    if(mouse_inside == false)
 
225
    {
 
226
      // The mouse pointer is not over this Area. return NULL.
 
227
      return NULL;
 
228
    }
 
229
 
 
230
    Area* found_area;
 
231
 
 
232
    // Recursively go over the ui element that are managed by this ScrollView and look
 
233
    // for the area that is below the mouse.
 
234
 
 
235
    // Test the vertical scrollbar
 
236
    found_area = _vscrollbar->FindAreaUnderMouse(mouse_position, event_type);
 
237
    NUX_RETURN_VALUE_IF_NOTNULL(found_area, found_area);
 
238
 
 
239
    // Test the horizontal scrollbar
 
240
    found_area = _hscrollbar->FindAreaUnderMouse(mouse_position, event_type);
 
241
    NUX_RETURN_VALUE_IF_NOTNULL(found_area, found_area);
 
242
 
 
243
    // If the code gets here, it means that no area has been found yet.
 
244
    // Test the layout of the ScrollView
 
245
    return View::FindAreaUnderMouse(mouse_position, event_type);
 
246
  }
 
247
 
233
248
  bool ScrollView::SetLayout (Layout *layout)
234
249
  {
235
250
    if(View::SetLayout(layout) == false)
249
264
    Geometry base = GetGeometry ();
250
265
 
251
266
    if (m_CompositionLayout)
252
 
      m_CompositionLayout->NeedRedraw();
 
267
      m_CompositionLayout->QueueDraw();
253
268
 
254
269
    GetPainter().PaintBackground (GfxContext, base);
255
270
 
256
271
    if (m_vertical_scrollbar_enable)
257
272
    {
258
 
      vscrollbar->NeedRedraw();
 
273
      _vscrollbar->QueueDraw();
259
274
    }
260
275
 
261
276
    if (m_horizontal_scrollbar_enable)
262
277
    {
263
 
      hscrollbar->NeedRedraw();
 
278
      _hscrollbar->QueueDraw();
264
279
    }
265
280
 
266
281
    GfxContext.PopClippingRectangle();
287
302
 
288
303
    if (m_vertical_scrollbar_enable)
289
304
    {
290
 
      vscrollbar->ProcessDraw (GfxContext, force_draw);
 
305
      _vscrollbar->ProcessDraw (GfxContext, force_draw);
291
306
    }
292
307
 
293
308
    if (m_horizontal_scrollbar_enable)
294
309
    {
295
 
      hscrollbar->ProcessDraw (GfxContext, force_draw);
 
310
      _hscrollbar->ProcessDraw (GfxContext, force_draw);
296
311
    }
297
312
 
298
313
    GfxContext.PopClippingRectangle();
359
374
 
360
375
  void ScrollView::PreLayoutManagement()
361
376
  {
 
377
    // Reset the client view to the top left corner of the container.
 
378
    _delta_x = _delta_y = 0;
362
379
    // Give the managed layout the same size and position as the Control.
363
380
 
364
381
    Geometry geo = GetGeometry();
365
 
    int ScrollBarWidth = vscrollbar->GetBaseWidth();
366
 
    int ScrollBarHeight = hscrollbar->GetBaseHeight();
 
382
    int ScrollBarWidth = _vscrollbar->GetBaseWidth();
 
383
    int ScrollBarHeight = _hscrollbar->GetBaseHeight();
367
384
 
368
385
    nuxAssertMsg (ScrollBarWidth > 0, TEXT ("[ScrollView::PreLayoutManagement] Invalid scrollbar width.") );
369
386
    nuxAssertMsg (ScrollBarHeight > 0, TEXT ("[ScrollView::PreLayoutManagement] Invalid scrollbar height.") );
423
440
      if (m_vertical_scrollbar_enable == false)
424
441
      {
425
442
        // If there is no vertical scrollbar, take all the width available.
426
 
        hscrollbar->SetBaseWidth (GetBaseWidth() - 2 * m_border);
 
443
        _hscrollbar->SetBaseWidth (GetBaseWidth() - 2 * m_border);
427
444
      }
428
445
      else
429
 
        hscrollbar->SetBaseWidth (GetBaseWidth() - ScrollBarWidth - 2 * m_border);
 
446
        _hscrollbar->SetBaseWidth (GetBaseWidth() - ScrollBarWidth - 2 * m_border);
430
447
 
431
 
      hscrollbar->SetBaseX (geo.x + m_border);
432
 
      hscrollbar->SetBaseY (geo.y + geo.GetHeight() - hscrollbar->GetBaseHeight() - m_border);
433
 
      hscrollbar->ComputeChildLayout();
 
448
      _hscrollbar->SetBaseX (geo.x + m_border);
 
449
      _hscrollbar->SetBaseY (geo.y + geo.GetHeight() - _hscrollbar->GetBaseHeight() - m_border);
 
450
      _hscrollbar->ComputeChildLayout();
434
451
    }
435
452
    else
436
453
    {
437
454
      // The horizontal scrollbar won't be visible but give it a proper size anyway.
438
 
      hscrollbar->SetBaseWidth (GetBaseWidth() - ScrollBarWidth - 2 * m_border);
439
 
      hscrollbar->SetBaseX (geo.x + m_border);
440
 
      hscrollbar->SetBaseY (geo.y + geo.GetHeight() - hscrollbar->GetBaseHeight() - m_border);
441
 
      hscrollbar->ComputeChildLayout();
 
455
      _hscrollbar->SetBaseWidth (GetBaseWidth() - ScrollBarWidth - 2 * m_border);
 
456
      _hscrollbar->SetBaseX (geo.x + m_border);
 
457
      _hscrollbar->SetBaseY (geo.y + geo.GetHeight() - _hscrollbar->GetBaseHeight() - m_border);
 
458
      _hscrollbar->ComputeChildLayout();
442
459
    }
443
460
 
444
461
 
448
465
      if (m_horizontal_scrollbar_enable == false)
449
466
      {
450
467
        // If there is no horizontal scrollbar, take all the width available.
451
 
        vscrollbar->SetBaseHeight (GetBaseHeight() - m_top_border - m_border);
 
468
        _vscrollbar->SetBaseHeight (GetBaseHeight() - m_top_border - m_border);
452
469
      }
453
470
      else
454
 
        vscrollbar->SetBaseHeight (GetBaseHeight() - ScrollBarHeight - m_top_border - m_border);
 
471
        _vscrollbar->SetBaseHeight (GetBaseHeight() - ScrollBarHeight - m_top_border - m_border);
455
472
 
456
 
      vscrollbar->SetBaseX (geo.x + geo.GetWidth() - ScrollBarWidth - m_border);
457
 
      vscrollbar->SetBaseY (geo.y + m_top_border);
458
 
      vscrollbar->ComputeChildLayout();
 
473
      _vscrollbar->SetBaseX (geo.x + geo.GetWidth() - ScrollBarWidth - m_border);
 
474
      _vscrollbar->SetBaseY (geo.y + m_top_border);
 
475
      _vscrollbar->ComputeChildLayout();
459
476
    }
460
477
    else
461
478
    {
462
479
      // The vertical scrollbar won't be visible but give it a proper size anyway.
463
 
      vscrollbar->SetBaseHeight (GetBaseHeight() - ScrollBarHeight - m_top_border - m_border);
464
 
      vscrollbar->SetBaseX (geo.x + geo.GetWidth() - ScrollBarWidth - m_border);
465
 
      vscrollbar->SetBaseY (geo.y + m_top_border);
466
 
      vscrollbar->ComputeChildLayout();
 
480
      _vscrollbar->SetBaseHeight (GetBaseHeight() - ScrollBarHeight - m_top_border - m_border);
 
481
      _vscrollbar->SetBaseX (geo.x + geo.GetWidth() - ScrollBarWidth - m_border);
 
482
      _vscrollbar->SetBaseY (geo.y + m_top_border);
 
483
      _vscrollbar->ComputeChildLayout();
467
484
    }
468
485
  }
469
486
 
484
501
    }
485
502
 
486
503
    if (m_horizontal_scrollbar_enable)
487
 
      ScrollBarHeight = hscrollbar->GetBaseHeight();
 
504
      ScrollBarHeight = _hscrollbar->GetBaseHeight();
488
505
 
489
506
    if (m_vertical_scrollbar_enable)
490
 
      ScrollBarWidth = vscrollbar->GetBaseWidth();
 
507
      ScrollBarWidth = _vscrollbar->GetBaseWidth();
491
508
 
492
 
    hscrollbar->SetContainerSize (GetBaseX() + m_border + m_ViewContentLeftMargin,
 
509
    _hscrollbar->SetContainerSize (GetBaseX() + m_border + m_ViewContentLeftMargin,
493
510
                                  GetBaseY() + m_top_border + m_ViewContentTopMargin,
494
511
                                  GetBaseWidth() - ScrollBarWidth - 2 * m_border - m_ViewContentRightMargin - m_ViewContentLeftMargin,
495
512
                                  GetBaseHeight() - ScrollBarHeight - m_top_border - m_border - m_ViewContentBottomMargin - m_ViewContentTopMargin);
498
515
    {
499
516
      if (m_CompositionLayout)
500
517
      {
501
 
        hscrollbar->SetContentSize (m_CompositionLayout->GetBaseX(), m_CompositionLayout->GetBaseY(),
 
518
        _hscrollbar->SetContentSize (m_CompositionLayout->GetBaseX(), m_CompositionLayout->GetBaseY(),
502
519
                                    m_CompositionLayout->GetBaseWidth(), m_CompositionLayout->GetBaseHeight() );
503
520
      }
504
521
      else
505
522
      {
506
 
        hscrollbar->SetContentSize (GetBaseX() + m_border + m_ViewContentLeftMargin,
 
523
        _hscrollbar->SetContentSize (GetBaseX() + m_border + m_ViewContentLeftMargin,
507
524
                                    GetBaseY() + m_top_border + m_ViewContentTopMargin, 0, 0);
508
525
      }
509
526
 
510
 
      hscrollbar->SetContentOffset (_delta_x, _delta_y);
 
527
      _hscrollbar->SetContentOffset (_delta_x, _delta_y);
511
528
    }
512
529
    else
513
530
    {
514
 
      hscrollbar->SetContentSize (GetBaseX() + m_border + m_ViewContentLeftMargin,
 
531
      _hscrollbar->SetContentSize (GetBaseX() + m_border + m_ViewContentLeftMargin,
515
532
                                  GetBaseY() + m_top_border + m_ViewContentTopMargin, 0, 0);
516
 
      hscrollbar->SetContentOffset (0, 0);
 
533
      _hscrollbar->SetContentOffset (0, 0);
517
534
    }
518
535
 
519
 
    vscrollbar->SetContainerSize (GetBaseX() + m_border + m_ViewContentLeftMargin,
 
536
    _vscrollbar->SetContainerSize (GetBaseX() + m_border + m_ViewContentLeftMargin,
520
537
                                  GetBaseY() + m_top_border + m_ViewContentTopMargin,
521
538
                                  GetBaseWidth() - ScrollBarWidth - 2 * m_border - m_ViewContentRightMargin - m_ViewContentLeftMargin,
522
539
                                  GetBaseHeight() - ScrollBarHeight - m_top_border - m_border - m_ViewContentBottomMargin - m_ViewContentTopMargin);
525
542
    {
526
543
      if (m_CompositionLayout)
527
544
      {
528
 
        vscrollbar->SetContentSize (m_CompositionLayout->GetBaseX(), m_CompositionLayout->GetBaseY(),
 
545
        _vscrollbar->SetContentSize (m_CompositionLayout->GetBaseX(), m_CompositionLayout->GetBaseY(),
529
546
                                    m_CompositionLayout->GetBaseWidth(), m_CompositionLayout->GetBaseHeight() );
530
547
      }
531
548
      else
532
549
      {
533
 
        vscrollbar->SetContentSize (GetBaseX() + m_border + m_ViewContentLeftMargin,
 
550
        _vscrollbar->SetContentSize (GetBaseX() + m_border + m_ViewContentLeftMargin,
534
551
                                    GetBaseY() + m_top_border + m_ViewContentTopMargin, 0, 0);
535
552
      }
536
553
 
537
 
      vscrollbar->SetContentOffset (_delta_x, _delta_y);
 
554
      _vscrollbar->SetContentOffset (_delta_x, _delta_y);
538
555
    }
539
556
    else
540
557
    {
541
 
      vscrollbar->SetContentSize (GetBaseX() + m_border + m_ViewContentLeftMargin,
 
558
      _vscrollbar->SetContentSize (GetBaseX() + m_border + m_ViewContentLeftMargin,
542
559
                                  GetBaseY() + m_top_border + m_ViewContentTopMargin, 0, 0);
543
 
      vscrollbar->SetContentOffset (0, 0);
 
560
      _vscrollbar->SetContentOffset (0, 0);
544
561
    }
545
562
 
546
563
    // I may not be necessary to call this function here since ComputePosition2 was called on ComputePosition2
559
576
    int ScrollbarHeight = 0;
560
577
 
561
578
    if (m_horizontal_scrollbar_enable)
562
 
      ScrollbarHeight = hscrollbar->GetBaseHeight();
 
579
      ScrollbarHeight = _hscrollbar->GetBaseHeight();
563
580
 
564
581
    if (m_vertical_scrollbar_enable)
565
 
      ScrollbarWidth = vscrollbar->GetBaseWidth();
 
582
      ScrollbarWidth = _vscrollbar->GetBaseWidth();
566
583
 
567
584
    // We want the controller to match the size of the content as defined in:
568
585
    //      m_ViewContentX
605
622
    if (m_horizontal_scrollbar_enable)
606
623
    {
607
624
      if (m_vertical_scrollbar_enable == false)
608
 
        hscrollbar->SetBaseWidth (GetBaseWidth() - 2 * m_border);
 
625
        _hscrollbar->SetBaseWidth (GetBaseWidth() - 2 * m_border);
609
626
      else
610
 
        hscrollbar->SetBaseWidth (GetBaseWidth() - ScrollbarWidth - 2 * m_border);
 
627
        _hscrollbar->SetBaseWidth (GetBaseWidth() - ScrollbarWidth - 2 * m_border);
611
628
 
612
 
      hscrollbar->SetBaseX (geo.x + m_border);
613
 
      hscrollbar->SetBaseY (geo.y + geo.GetHeight() - hscrollbar->GetBaseHeight() - m_border);
614
 
      hscrollbar->ComputeChildLayout();
 
629
      _hscrollbar->SetBaseX (geo.x + m_border);
 
630
      _hscrollbar->SetBaseY (geo.y + geo.GetHeight() - _hscrollbar->GetBaseHeight() - m_border);
 
631
      _hscrollbar->ComputeChildLayout();
615
632
 
616
633
      //---
617
 
      hscrollbar->SetContainerSize (GetBaseX() + m_border + m_ViewContentLeftMargin,
 
634
      _hscrollbar->SetContainerSize (GetBaseX() + m_border + m_ViewContentLeftMargin,
618
635
                                    GetBaseY() + m_top_border + m_ViewContentTopMargin,
619
636
                                    GetBaseWidth() - ScrollbarWidth - 2 * m_border - m_ViewContentRightMargin - m_ViewContentLeftMargin,
620
637
                                    GetBaseHeight() - ScrollbarHeight - m_top_border - m_border - m_ViewContentBottomMargin - m_ViewContentTopMargin);
621
638
 
622
639
      if (m_CompositionLayout)
623
640
      {
624
 
        hscrollbar->SetContentSize (m_CompositionLayout->GetBaseX(), m_CompositionLayout->GetBaseY(),
 
641
        _hscrollbar->SetContentSize (m_CompositionLayout->GetBaseX(), m_CompositionLayout->GetBaseY(),
625
642
                                    m_CompositionLayout->GetBaseWidth(), m_CompositionLayout->GetBaseHeight() );
626
643
      }
627
644
      else
628
645
      {
629
 
        hscrollbar->SetContentSize (GetBaseX() + m_border + m_ViewContentLeftMargin,
 
646
        _hscrollbar->SetContentSize (GetBaseX() + m_border + m_ViewContentLeftMargin,
630
647
                                    GetBaseY() + m_top_border + m_ViewContentTopMargin, 0, 0);
631
648
      }
632
649
 
633
 
      hscrollbar->SetContentOffset (_delta_x, _delta_y);
 
650
      _hscrollbar->SetContentOffset (_delta_x, _delta_y);
634
651
    }
635
652
    else
636
653
    {
637
 
      hscrollbar->SetBaseWidth (GetBaseWidth() - ScrollbarWidth - 2 * m_border);
638
 
      hscrollbar->SetBaseX (geo.x + m_border);
639
 
      hscrollbar->SetBaseY (geo.y + geo.GetHeight() - hscrollbar->GetBaseHeight() - m_border);
640
 
      hscrollbar->ComputeChildLayout();
 
654
      _hscrollbar->SetBaseWidth (GetBaseWidth() - ScrollbarWidth - 2 * m_border);
 
655
      _hscrollbar->SetBaseX (geo.x + m_border);
 
656
      _hscrollbar->SetBaseY (geo.y + geo.GetHeight() - _hscrollbar->GetBaseHeight() - m_border);
 
657
      _hscrollbar->ComputeChildLayout();
641
658
 
642
659
      //---
643
 
      hscrollbar->SetContainerSize (GetBaseX() + m_border + m_ViewContentLeftMargin,
 
660
      _hscrollbar->SetContainerSize (GetBaseX() + m_border + m_ViewContentLeftMargin,
644
661
                                    GetBaseY() + m_top_border + m_ViewContentTopMargin,
645
662
                                    GetBaseWidth() - ScrollbarWidth - 2 * m_border - m_ViewContentRightMargin - m_ViewContentLeftMargin,
646
663
                                    GetBaseHeight() - ScrollbarHeight - m_top_border - m_border - m_ViewContentBottomMargin - m_ViewContentTopMargin);
647
 
      hscrollbar->SetContentSize (GetBaseX() + m_border + m_ViewContentLeftMargin,
 
664
      _hscrollbar->SetContentSize (GetBaseX() + m_border + m_ViewContentLeftMargin,
648
665
                                  GetBaseY() + m_top_border + m_ViewContentTopMargin, 0, 0);
649
 
      hscrollbar->SetContentOffset (0, 0);
 
666
      _hscrollbar->SetContentOffset (0, 0);
650
667
    }
651
668
 
652
669
 
654
671
    if (m_vertical_scrollbar_enable)
655
672
    {
656
673
      if (m_horizontal_scrollbar_enable == false)
657
 
        vscrollbar->SetBaseHeight (GetBaseHeight() - m_top_border - m_border);
 
674
        _vscrollbar->SetBaseHeight (GetBaseHeight() - m_top_border - m_border);
658
675
      else
659
 
        vscrollbar->SetBaseHeight (GetBaseHeight() - ScrollbarHeight - m_top_border - m_border);
 
676
        _vscrollbar->SetBaseHeight (GetBaseHeight() - ScrollbarHeight - m_top_border - m_border);
660
677
 
661
 
      vscrollbar->SetBaseX (geo.x + geo.GetWidth() - ScrollbarWidth - m_border);
662
 
      vscrollbar->SetBaseY (geo.y + m_top_border);
663
 
      vscrollbar->ComputeChildLayout();
 
678
      _vscrollbar->SetBaseX (geo.x + geo.GetWidth() - ScrollbarWidth - m_border);
 
679
      _vscrollbar->SetBaseY (geo.y + m_top_border);
 
680
      _vscrollbar->ComputeChildLayout();
664
681
 
665
682
      //---
666
 
      vscrollbar->SetContainerSize (GetBaseX() + m_border + m_ViewContentLeftMargin,
 
683
      _vscrollbar->SetContainerSize (GetBaseX() + m_border + m_ViewContentLeftMargin,
667
684
                                    GetBaseY() + m_top_border + m_ViewContentTopMargin,
668
685
                                    GetBaseWidth() - ScrollbarWidth - 2 * m_border - m_ViewContentRightMargin - m_ViewContentLeftMargin,
669
686
                                    GetBaseHeight() - ScrollbarHeight - m_top_border - m_border - m_ViewContentBottomMargin - m_ViewContentTopMargin);
670
687
 
671
688
      if (m_CompositionLayout)
672
689
      {
673
 
        vscrollbar->SetContentSize (m_CompositionLayout->GetBaseX(), m_CompositionLayout->GetBaseY(),
 
690
        _vscrollbar->SetContentSize (m_CompositionLayout->GetBaseX(), m_CompositionLayout->GetBaseY(),
674
691
                                    m_CompositionLayout->GetBaseWidth(), m_CompositionLayout->GetBaseHeight() );
675
692
      }
676
693
      else
677
694
      {
678
 
        vscrollbar->SetContentSize (GetBaseX() + m_border + m_ViewContentLeftMargin,
 
695
        _vscrollbar->SetContentSize (GetBaseX() + m_border + m_ViewContentLeftMargin,
679
696
                                    GetBaseY() + m_top_border + m_ViewContentTopMargin, 0, 0);
680
697
      }
681
698
 
682
 
      vscrollbar->SetContentOffset (_delta_x, _delta_y);
 
699
      _vscrollbar->SetContentOffset (_delta_x, _delta_y);
683
700
    }
684
701
    else
685
702
    {
686
 
      vscrollbar->SetBaseHeight (GetBaseHeight() - ScrollbarHeight - m_top_border - m_border);
687
 
      vscrollbar->SetBaseX (geo.x + geo.GetWidth() - ScrollbarWidth - m_border);
688
 
      vscrollbar->SetBaseY (geo.y + m_top_border);
689
 
      vscrollbar->ComputeChildLayout();
 
703
      _vscrollbar->SetBaseHeight (GetBaseHeight() - ScrollbarHeight - m_top_border - m_border);
 
704
      _vscrollbar->SetBaseX (geo.x + geo.GetWidth() - ScrollbarWidth - m_border);
 
705
      _vscrollbar->SetBaseY (geo.y + m_top_border);
 
706
      _vscrollbar->ComputeChildLayout();
690
707
 
691
708
      //---
692
 
      vscrollbar->SetContainerSize (GetBaseX() + m_border + m_ViewContentLeftMargin,
 
709
      _vscrollbar->SetContainerSize (GetBaseX() + m_border + m_ViewContentLeftMargin,
693
710
                                    GetBaseY() + m_top_border + m_ViewContentTopMargin,
694
711
                                    GetBaseWidth() - ScrollbarWidth - 2 * m_border - m_ViewContentRightMargin - m_ViewContentLeftMargin,
695
712
                                    GetBaseHeight() - ScrollbarHeight - m_top_border - m_border - m_ViewContentBottomMargin - m_ViewContentTopMargin);
696
 
      vscrollbar->SetContentSize (GetBaseX() + m_border + m_ViewContentLeftMargin,
 
713
      _vscrollbar->SetContentSize (GetBaseX() + m_border + m_ViewContentLeftMargin,
697
714
                                  GetBaseY() + m_top_border + m_ViewContentTopMargin, 0, 0);
698
 
      vscrollbar->SetContentOffset (0, 0);
 
715
      _vscrollbar->SetContentOffset (0, 0);
699
716
    }
700
717
 
701
718
    if (m_CompositionLayout)
716
733
    int w = 0;
717
734
    int h = 0;
718
735
 
719
 
    w = vscrollbar->GetBaseWidth();
720
 
    h = hscrollbar->GetBaseHeight();
 
736
    w = _vscrollbar->GetBaseWidth();
 
737
    h = _hscrollbar->GetBaseHeight();
721
738
 
722
739
//    m_ViewX = GetX() + m_border;
723
740
//    m_ViewY = GetY() + m_top_border;
766
783
    if (m_horizontal_scrollbar_enable)
767
784
    {
768
785
      if (m_vertical_scrollbar_enable == false)
769
 
        hscrollbar->SetBaseWidth (GetBaseWidth() - 2 * m_border);
 
786
        _hscrollbar->SetBaseWidth (GetBaseWidth() - 2 * m_border);
770
787
      else
771
 
        hscrollbar->SetBaseWidth (GetBaseWidth() - w - 2 * m_border);
 
788
        _hscrollbar->SetBaseWidth (GetBaseWidth() - w - 2 * m_border);
772
789
 
773
 
      hscrollbar->SetBaseX (geo.x + m_border);
774
 
      hscrollbar->SetBaseY (geo.y + geo.GetHeight() - hscrollbar->GetBaseHeight() - m_border);
775
 
      hscrollbar->ComputeChildLayout();
 
790
      _hscrollbar->SetBaseX (geo.x + m_border);
 
791
      _hscrollbar->SetBaseY (geo.y + geo.GetHeight() - _hscrollbar->GetBaseHeight() - m_border);
 
792
      _hscrollbar->ComputeChildLayout();
776
793
    }
777
794
 
778
795
    // Vertical scrollbar Geometry
779
796
    if (m_vertical_scrollbar_enable)
780
797
    {
781
798
      if (m_horizontal_scrollbar_enable == false)
782
 
        vscrollbar->SetBaseHeight (GetBaseHeight() - m_top_border - m_border);
 
799
        _vscrollbar->SetBaseHeight (GetBaseHeight() - m_top_border - m_border);
783
800
      else
784
 
        vscrollbar->SetBaseHeight (GetBaseHeight() - h - m_top_border - m_border);
 
801
        _vscrollbar->SetBaseHeight (GetBaseHeight() - h - m_top_border - m_border);
785
802
 
786
 
      vscrollbar->SetBaseX (geo.x + geo.GetWidth() - w - m_border);
787
 
      vscrollbar->SetBaseY (geo.y + m_top_border);
788
 
      vscrollbar->ComputeChildLayout();
 
803
      _vscrollbar->SetBaseX (geo.x + geo.GetWidth() - w - m_border);
 
804
      _vscrollbar->SetBaseY (geo.y + m_top_border);
 
805
      _vscrollbar->ComputeChildLayout();
789
806
    }
790
807
 
791
808
    if (m_CompositionLayout)
799
816
      m_ViewContentY = m_ViewY;
800
817
    }
801
818
 
802
 
    vscrollbar->SetContentOffset (_delta_x, _delta_y);
803
 
    hscrollbar->SetContentOffset (_delta_x, _delta_y);
 
819
    _vscrollbar->SetContentOffset (_delta_x, _delta_y);
 
820
    _hscrollbar->SetContentOffset (_delta_x, _delta_y);
804
821
 
805
822
    if (m_CompositionLayout)
806
823
    {
824
841
 
825
842
    if (m_CompositionLayout)
826
843
    {
827
 
      hscrollbar->SetContentOffset (_delta_x, _delta_y);
828
 
      hscrollbar->NeedRedraw();
 
844
      _hscrollbar->SetContentOffset (_delta_x, _delta_y);
 
845
      _hscrollbar->QueueDraw();
829
846
    }
830
847
 
831
 
    NeedRedraw();
 
848
    QueueDraw();
832
849
  }
833
850
 
834
851
  void ScrollView::ScrollRight (float stepx, int mousedx)
846
863
 
847
864
    if (m_CompositionLayout)
848
865
    {
849
 
      hscrollbar->SetContentOffset (_delta_x, _delta_y);
850
 
      hscrollbar->NeedRedraw();
 
866
      _hscrollbar->SetContentOffset (_delta_x, _delta_y);
 
867
      _hscrollbar->QueueDraw();
851
868
    }
852
869
 
853
 
    NeedRedraw();
 
870
    QueueDraw();
854
871
  }
855
872
 
856
873
  void ScrollView::ScrollUp (float stepy, int mousedy)
868
885
 
869
886
    if (m_CompositionLayout)
870
887
    {
871
 
      vscrollbar->SetContentOffset (_delta_x, _delta_y);
872
 
      vscrollbar->NeedRedraw();
 
888
      _vscrollbar->SetContentOffset (_delta_x, _delta_y);
 
889
      _vscrollbar->QueueDraw();
873
890
    }
874
891
 
875
 
    NeedRedraw();
 
892
    QueueDraw();
876
893
  }
877
894
 
878
895
  void ScrollView::ScrollDown (float stepy, int mousedy)
890
907
 
891
908
    if (m_CompositionLayout)
892
909
    {
893
 
      vscrollbar->SetContentOffset (_delta_x, _delta_y);
894
 
      vscrollbar->NeedRedraw();
 
910
      _vscrollbar->SetContentOffset (_delta_x, _delta_y);
 
911
      _vscrollbar->QueueDraw();
895
912
    }
896
913
 
897
 
    NeedRedraw();
 
914
    QueueDraw();
898
915
  }
899
916
 
900
917
  void ScrollView::SetSizeMatchContent (bool b)
916
933
    if (m_CompositionLayout)
917
934
      m_CompositionLayout->Set2DTranslation (_delta_x, _delta_y, 0);
918
935
 
919
 
    hscrollbar->SetContentOffset (_delta_x, _delta_y);
920
 
    hscrollbar->NeedRedraw();
 
936
    _hscrollbar->SetContentOffset (_delta_x, _delta_y);
 
937
    _hscrollbar->QueueDraw();
921
938
 
922
 
    NeedRedraw();
 
939
    QueueDraw();
923
940
  }
924
941
 
925
942
  void ScrollView::ResetScrollToRight()
936
953
 
937
954
 
938
955
 
939
 
    hscrollbar->SetContentOffset (_delta_x, _delta_y);
940
 
    hscrollbar->NeedRedraw();
 
956
    _hscrollbar->SetContentOffset (_delta_x, _delta_y);
 
957
    _hscrollbar->QueueDraw();
941
958
 
942
 
    NeedRedraw();
 
959
    QueueDraw();
943
960
  }
944
961
 
945
962
  void ScrollView::ResetScrollToUp()
948
965
    if (m_CompositionLayout)
949
966
      m_CompositionLayout->Set2DTranslation (_delta_x, _delta_y, 0);
950
967
 
951
 
    vscrollbar->SetContentOffset (_delta_x, _delta_y);
952
 
    vscrollbar->NeedRedraw();
 
968
    _vscrollbar->SetContentOffset (_delta_x, _delta_y);
 
969
    _vscrollbar->QueueDraw();
953
970
 
954
 
    NeedRedraw();
 
971
    QueueDraw();
955
972
  }
956
973
 
957
974
  void ScrollView::ResetScrollToDown()
966
983
      _delta_y = 0;
967
984
    }
968
985
 
969
 
    vscrollbar->SetContentOffset (_delta_x, _delta_y);
970
 
    vscrollbar->NeedRedraw();
971
 
 
972
 
    NeedRedraw();
 
986
    _vscrollbar->SetContentOffset (_delta_x, _delta_y);
 
987
    _vscrollbar->QueueDraw();
 
988
 
 
989
    QueueDraw();
 
990
  }
 
991
 
 
992
  void ScrollView::RecvMouseWheel(int x, int y, int wheel_delta, long button_flags, unsigned long key_flags)
 
993
  {
 
994
    // nux can't tell the difference between horizontal and vertical mouse wheel events
 
995
    // so we are only going to support vertical
 
996
    if (wheel_delta < 0)
 
997
    {
 
998
      ScrollDown (abs (wheel_delta / NUX_MOUSEWHEEL_DELTA), m_MouseWheelScrollSize);
 
999
    }
 
1000
    else
 
1001
    {
 
1002
      ScrollUp (abs (wheel_delta / NUX_MOUSEWHEEL_DELTA), m_MouseWheelScrollSize);
 
1003
    }
 
1004
    QueueDraw();
 
1005
  }
 
1006
 
 
1007
  bool ScrollView::AcceptKeyNavFocus()
 
1008
  {
 
1009
    return false;
973
1010
  }
974
1011
}