1 /*! \page scroll-view Example and Usage
3 We will start by showing the steps to creating a ScrollView, adding to the stage, and adding content to the ScrollView.
5 Then we look at some of the options to achieve commonly desired ScrollView effects, from ruler snap points to domains.
7 \section intro Simple ScrollView setup, and ruler configuration.
9 We declare a ScrollView component called myScrollView
12 Dali::Toolkit::ScrollView myScrollView;
15 A new ScrollView instance is then created by calling the following
17 myScrollView = ScrollView::New();
20 We then add it to the stage.
22 Stage::GetCurrent().Add(myScrollView);
25 Then we specify the size. We'll make it cover the entire stage
27 Stage stage = Dali::Stage::GetCurrent();
28 Size size = stage.GetSize();
29 myScrollView.SetSize( size );
32 Add Actors to this ScrollView
34 Toolkit::ImageView imageView = Toolkit::ImageView::New(DALI_IMAGE_DIR "button-background.png");
35 myScrollView.Add( imageView );
38 The ScrollView contents are now draggable by the user using touch (panning gestures).
40 To enforce horizontal-only scrolling, the Y-axis ruler can be disabled
42 RulerPtr rulerY = new DefaultRuler();
44 myScrollView.SetRulerY(rulerY);
47 To enable snapping, a FixedRuler can be applied to the X-axis, with snap points spaced to the width of the stage.
49 Stage stage = Dali::Stage::GetCurrent();
50 Size size = stage.GetSize();
51 RulerPtr rulerX = new FixedRuler(size.width);
52 myScrollView.SetRulerX(rulerX);
55 A domain can be applied to rulers to prevent scrolling beyond this boundary. In this case to 4 times the width of the stage, allowing for 4 pages to be scrolled.
57 Stage stage = Dali::Stage::GetCurrent();
58 Size size = stage.GetSize();
59 RulerPtr rulerX = new FixedRuler(size.width);
60 rulerX->SetDomain(RulerDomain(0.0f, size.width*4.0f));
61 myScrollView.SetRulerX(rulerX);
64 Ruler Domain Wrap Behaviour
65 ===== ====== ==== =========
67 Disabled Disabled No-Wrap "No Movement in axis"
68 Disabled Disabled Wrap "No Movement in axis"
69 Disabled Enabled No-Wrap "No Movement in axis"
70 Disabled Enable Wrap "No Movement in axis"
71 Enabled Disabled No-Wrap "Free Movement in axis"
72 Enabled Disabled Wrap "Free Movement in axis, but will wrap based on domain min-max"
73 Enabled Enabled No-Wrap "Movement limited to domain min-max"
74 Enabled Enabled Wrap "Movement limited to domain min-max"
76 @note It is important to note that Actors within ScrollView are controlled by constraints,
77 and thus undefined behaviour will occur when applying constraints to these Actors externally.
78 If you wish to apply additional constraints that may conflict with the ScrollView's constraints,
79 then it is recommended that you place the Actors within container Actors. So that the container
80 Actors are affected by the constraints.