Commit bb5db46ebda86545c722a49f2ad35615262d04a3

Authored by Richard Huang
1 parent dd1469ba

Updated demo for ScrollBar and ScrollView API changes

Change-Id: I126a9ea79d3784dbf3357f7b5fb2af6d145815a2
demo/dali-table-view.cpp
... ... @@ -140,7 +140,7 @@ public:
140 140  
141 141 // Bubbles X position moves parallax to horizontal
142 142 // panning by a scale factor unique to each bubble.
143   - position.x = mInitialX + ( inputs[0]->GetVector3().x * mScale );
  143 + position.x = mInitialX + ( inputs[0]->GetVector2().x * mScale );
144 144 }
145 145  
146 146 private:
... ... @@ -637,14 +637,14 @@ void DaliTableView::OnPressedAnimationFinished( Dali::Animation& source )
637 637 }
638 638 }
639 639  
640   -void DaliTableView::OnScrollStart( const Dali::Vector3& position )
  640 +void DaliTableView::OnScrollStart( const Dali::Vector2& position )
641 641 {
642 642 mScrolling = true;
643 643  
644 644 PlayAnimation();
645 645 }
646 646  
647   -void DaliTableView::OnScrollComplete( const Dali::Vector3& position )
  647 +void DaliTableView::OnScrollComplete( const Dali::Vector2& position )
648 648 {
649 649 mScrolling = false;
650 650  
... ...
demo/dali-table-view.h
... ... @@ -217,14 +217,14 @@ private: // Application callbacks & implementation
217 217 *
218 218 * @param[in] position The current position of the scroll contents.
219 219 */
220   - void OnScrollStart(const Dali::Vector3& position);
  220 + void OnScrollStart(const Dali::Vector2& position);
221 221  
222 222 /**
223 223 * Signal emitted when scrolling has completed.
224 224 *
225 225 * @param[in] position The current position of the scroll contents.
226 226 */
227   - void OnScrollComplete(const Dali::Vector3& position);
  227 + void OnScrollComplete(const Dali::Vector2& position);
228 228  
229 229 /**
230 230 * Signal emitted when any Sensitive Actor has been touched
... ...
examples/cluster/cluster-example.cpp
... ... @@ -691,8 +691,8 @@ public:
691 691  
692 692 // Apply new shader-effects.
693 693 // Move Y to origin incase we came from an effect where user could free pan in y axis.
694   - const Vector3 currentScrollPosition(mScrollView.GetCurrentScrollPosition());
695   - mScrollView.ScrollTo(Vector3(currentScrollPosition.x, 0.0f, 0.0f));
  694 + const Vector2 currentScrollPosition(mScrollView.GetCurrentScrollPosition());
  695 + mScrollView.ScrollTo(Vector2(currentScrollPosition.x, 0.0f));
696 696  
697 697 switch(type)
698 698 {
... ...
examples/image-scaling-irregular-grid/image-scaling-irregular-grid-example.cpp
... ... @@ -335,13 +335,11 @@ public:
335 335 mScrollView.ScrollStartedSignal().Connect( this, &ImageScalingIrregularGridController::OnScrollStarted );
336 336 mScrollView.ScrollCompletedSignal().Connect( this, &ImageScalingIrregularGridController::OnScrollCompleted );
337 337  
338   - mScrollView.EnableScrollComponent( Scrollable::VerticalScrollBar );
339   - mScrollView.EnableScrollComponent( Scrollable::HorizontalScrollBar );
340   -
341 338 mScrollView.SetAnchorPoint(AnchorPoint::CENTER);
342 339 mScrollView.SetParentOrigin(ParentOrigin::CENTER);
343 340  
344   - mScrollView.SetSize( stageSize );//Vector2( stageSize.width, fieldHeight ) );//stageSize );
  341 + mScrollView.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
  342 +
345 343 mScrollView.SetAxisAutoLock( true );
346 344 mScrollView.SetAxisAutoLockGradient( 1.0f );
347 345  
... ... @@ -351,7 +349,7 @@ public:
351 349 rulerX->SetDomain( RulerDomain( stageSize.width * -0.125f, stageSize.width * 1.125f ) ); //< Scroll slightly left/right of image field.
352 350 mScrollView.SetRulerX ( rulerX );
353 351  
354   - RulerPtr rulerY = new DefaultRuler(); //stageSize.height ); //< Snap in multiples of a screen / stage height
  352 + RulerPtr rulerY = new DefaultRuler(); //< Snap in multiples of a screen / stage height
355 353 rulerY->SetDomain( RulerDomain( - fieldHeight * 0.5f + stageSize.height * 0.5f - GRID_CELL_PADDING, fieldHeight * 0.5f + stageSize.height * 0.5f + GRID_CELL_PADDING ) );
356 354 mScrollView.SetRulerY ( rulerY );
357 355  
... ... @@ -359,8 +357,31 @@ public:
359 357 mScrollView.Add( imageField );
360 358 mGridActor = imageField;
361 359  
  360 + // Create the scroll bar
  361 + mScrollBarVertical = ScrollBar::New(Toolkit::ScrollBar::Vertical);
  362 + mScrollBarVertical.SetParentOrigin(ParentOrigin::TOP_RIGHT);
  363 + mScrollBarVertical.SetAnchorPoint(AnchorPoint::TOP_RIGHT);
  364 + mScrollBarVertical.SetResizePolicy(Dali::ResizePolicy::FILL_TO_PARENT, Dali::Dimension::HEIGHT);
  365 + mScrollBarVertical.SetResizePolicy(Dali::ResizePolicy::FIT_TO_CHILDREN, Dali::Dimension::WIDTH);
  366 + mScrollView.Add(mScrollBarVertical);
  367 +
  368 + mScrollBarHorizontal = ScrollBar::New(Toolkit::ScrollBar::Horizontal);
  369 + mScrollBarHorizontal.SetParentOrigin(ParentOrigin::BOTTOM_LEFT);
  370 + mScrollBarHorizontal.SetAnchorPoint(AnchorPoint::TOP_LEFT);
  371 + mScrollBarHorizontal.SetResizePolicy(Dali::ResizePolicy::FIT_TO_CHILDREN, Dali::Dimension::WIDTH);
  372 + mScrollBarHorizontal.SetOrientation(Quaternion(Radian( 1.5f * Math::PI ), Vector3::ZAXIS));
  373 + mScrollView.Add(mScrollBarHorizontal);
  374 +
  375 + mScrollView.OnRelayoutSignal().Connect( this, &ImageScalingIrregularGridController::OnScrollViewRelayout );
  376 +
362 377 // Scroll to top of grid so first images loaded are on-screen:
363   - mScrollView.ScrollTo( Vector3( 0, -1000000, 0 ) );
  378 + mScrollView.ScrollTo( Vector2( 0, -1000000 ) );
  379 + }
  380 +
  381 + void OnScrollViewRelayout(Actor actor)
  382 + {
  383 + // Make the height of the horizontal scroll bar to be the same as the width of scroll view.
  384 + mScrollBarHorizontal.SetSize(Vector2(0.0f, mScrollView.GetRelayoutSize( Dimension::WIDTH) ));
364 385 }
365 386  
366 387 /**
... ... @@ -549,7 +570,7 @@ public:
549 570 * note this state (mScrolling = true)
550 571 * @param[in] position Current Scroll Position
551 572 */
552   - void OnScrollStarted( const Vector3& position )
  573 + void OnScrollStarted( const Vector2& position )
553 574 {
554 575 mScrolling = true;
555 576 }
... ... @@ -559,7 +580,7 @@ public:
559 580 * note this state (mScrolling = false).
560 581 * @param[in] position Current Scroll Position
561 582 */
562   - void OnScrollCompleted( const Vector3& position )
  583 + void OnScrollCompleted( const Vector2& position )
563 584 {
564 585 mScrolling = false;
565 586 }
... ... @@ -573,6 +594,8 @@ private:
573 594 TextLabel mTitleActor; ///< The Toolbar's Title.
574 595 Actor mGridActor; ///< The container for the grid of images
575 596 ScrollView mScrollView; ///< ScrollView UI Component
  597 + ScrollBar mScrollBarVertical;
  598 + ScrollBar mScrollBarHorizontal;
576 599 bool mScrolling; ///< ScrollView scrolling state (true = scrolling, false = stationary)
577 600 std::map<unsigned, Dali::FittingMode::Type> mFittingModes; ///< Stores the current scaling mode of each image, keyed by image actor id.
578 601 std::map<unsigned, Vector2> mSizes; ///< Stores the current size of each image, keyed by image actor id.
... ...
examples/scroll-view/scroll-view-example.cpp
... ... @@ -630,7 +630,7 @@ private:
630 630 * note this state (mScrolling = true)
631 631 * @param[in] position Current Scroll Position
632 632 */
633   - void OnScrollStarted( const Vector3& position )
  633 + void OnScrollStarted( const Vector2& position )
634 634 {
635 635 mScrolling = true;
636 636 }
... ... @@ -640,7 +640,7 @@ private:
640 640 * note this state (mScrolling = false)
641 641 * @param[in] position Current Scroll Position
642 642 */
643   - void OnScrollCompleted( const Vector3& position )
  643 + void OnScrollCompleted( const Vector2& position )
644 644 {
645 645 mScrolling = false;
646 646 }
... ...