Remove dependency to std::vector and property::value from property notification API
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / public-api / controls / scroll-bar / scroll-bar.h
1 #ifndef __DALI_TOOLKIT_SCROLL_BAR_H__
2 #define __DALI_TOOLKIT_SCROLL_BAR_H__
3
4 /*
5  * Copyright (c) 2015 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // EXTERNAL INCLUDES
22 #include <dali/public-api/common/dali-vector.h>
23
24 // INTERNAL INCLUDES
25 #include <dali-toolkit/public-api/controls/scrollable/scroll-component.h>
26
27 namespace Dali
28 {
29
30 namespace Toolkit
31 {
32
33 // Forward declarations
34 class ScrollConnector;
35
36 namespace Internal DALI_INTERNAL
37 {
38 // Forward declarations
39
40 class ScrollBar;
41 }
42
43 /**
44  * ScrollBar is a UI component that can be added to the scrollable controls
45  * indicating the current scroll position of the scrollable content.
46  *
47  * Signals
48  * | %Signal Name             | Method                              |
49  * |--------------------------|-------------------------------------|
50  * | scroll-position-notified | @ref ScrollPositionNotifiedSignal() |
51  */
52 class DALI_IMPORT_API ScrollBar : public ScrollComponent
53 {
54 public:
55
56   /**
57    * @brief The start and end property ranges for this control.
58    */
59   enum PropertyRange
60   {
61     PROPERTY_START_INDEX = Control::CONTROL_PROPERTY_END_INDEX + 1,
62     PROPERTY_END_INDEX =   PROPERTY_START_INDEX + 1000              ///< Reserve property indices
63   };
64
65   /**
66    * @brief An enumeration of properties belonging to the ScrollBar class.
67    */
68   struct Property
69   {
70     enum
71     {
72       INDICATOR_HEIGHT_POLICY = PROPERTY_START_INDEX, ///< name "indicator-height-policy", @see SetIndicatorHeightPolicy(), type std::string
73       INDICATOR_FIXED_HEIGHT,                         ///< name "indicator-fixed-height",  @see SetIndicatorFixedHeight(),  type float
74       INDICATOR_SHOW_DURATION,                        ///< name "indicator-show-duration", @see SetIndicatorShowDuration(), type float
75       INDICATOR_HIDE_DURATION,                        ///< name "indicator-hide-duration", @see SetIndicatorHideDuration(), type float
76     };
77   };
78
79   // Signals
80   typedef Signal< void ( float ) > ScrollPositionNotifiedSignalType;
81
82 public:
83
84   /**
85    * @brief Indicator height policy.
86    */
87   enum IndicatorHeightPolicy
88   {
89     Variable = 0,  ///< Variable height changed dynamically according to the length of scroll content
90     Fixed          ///< Fixed height regardless of the length of scroll content
91   };
92
93   /**
94    * @brief Create an uninitialized ScrollBar; this can be initialized with ScrollBar::New()
95    * Calling member functions with an uninitialized Dali::Object is not allowed.
96    * or horizontally (false)
97    */
98   ScrollBar();
99
100   /**
101    * @brief Copy constructor.
102    */
103   ScrollBar( const ScrollBar& scrollBar );
104
105   /**
106    * @brief Assignment operator.
107    */
108   ScrollBar& operator=( const ScrollBar& scrollBar );
109
110   /**
111    * @brief Destructor
112    *
113    * This is non-virtual since derived Handle types must not contain data or virtual methods.
114    */
115   ~ScrollBar();
116
117   /**
118    * @brief Create an initialized ScrollBar
119    * @return A pointer to the created ScrollBar.
120    */
121   static ScrollBar New();
122
123   /**
124    * @brief Downcast an Object handle to ScrollBar. If handle points to a ScrollBar the
125    * downcast produces valid handle. If not the returned handle is left uninitialized.
126    * @param[in] handle Handle to an object
127    * @return handle to a ScrollBar or an uninitialized handle
128    */
129   static ScrollBar DownCast( BaseHandle handle );
130
131   /**
132    * @brief Sets the image for the indicator of scroll bar.
133    *
134    * @pre The scroll bar actor has been initialised.
135    *
136    * The indicator image is resized (stretched according to scale settings),
137    * to reflect the size of the scroll indicator and minimum/maximum limits
138    * of the scroll position.
139    *
140    * @param[in] image The image of indicator that moves to indicate the current scroll position.
141    */
142   void SetIndicatorImage( Image image );
143
144   /**
145    * @brief Gets the indicator of scroll bar.
146    *
147    * @pre The scroll bar actor has been initialised.
148    *
149    * @return The indicator indicates the current scroll position of the scrollable content.
150    */
151   Actor GetScrollIndicator();
152
153   /**
154    * @brief Sets the values to get notification when the current scroll position of the scrollable
155    * content goes above or below any of these values.
156    *
157    * @pre The scroll bar actor has been initialised.
158    *
159    * @param[in] positions List of values to receive notifications for when the current scroll position crosses them
160    */
161   void SetPositionNotifications( const Dali::Vector<float>& positions );
162
163   /**
164    * @brief Sets the height policy of scroll indicator to have either variable or fixed height.
165    *
166    * @pre The scroll bar actor has been initialised.
167    *
168    * @param[in] policy The height policy of scroll indicator
169    */
170   void SetIndicatorHeightPolicy( IndicatorHeightPolicy policy );
171
172   /**
173    * @brief Gets the height policy of scroll indicator.
174    *
175    * @return The height policy of scroll indicator
176    */
177   IndicatorHeightPolicy GetIndicatorHeightPolicy();
178
179   /**
180    * @brief Sets the fixed height of scroll indicator.
181    * Normally the height of scroll indicator is changed dynamically according to the length of scroll content.
182    * However, when the height policy of scroll indicator is set to be fixed, the height will keep fixed
183    * regardless of the length of scroll content.
184    *
185    * @pre The scroll bar actor has been initialised.
186    *
187    * @param[in] height The fixed height of the scroll indicator
188    */
189   void SetIndicatorFixedHeight( float height );
190
191   /**
192    * @brief Gets the fix height of scroll indicator.
193    * @return The fixed height of the scroll indicator
194    */
195   float GetIndicatorFixedHeight();
196
197   /**
198    * @brief Sets the duration in second for the scroll indicator to become fully visible
199    *
200    * @pre The scroll bar actor has been initialised.
201    *
202    * @param[in] durationSeconds The duration for the scroll indicator to become fully visible
203    */
204   void SetIndicatorShowDuration( float durationSeconds );
205
206   /**
207    * @brief Gets the duration in second for the scroll indicator to become fully visible
208    * @return The duration for the scroll indicator to become fully visible
209    */
210   float GetIndicatorShowDuration();
211
212   /**
213    * @brief Sets the duration in second for the scroll indicator to become fully invisible
214    *
215    * @pre The scroll bar actor has been initialised.
216    *
217    * @param[in] durationSeconds The duration for the scroll indicator to become fully invisible
218    */
219   void SetIndicatorHideDuration( float durationSeconds );
220
221   /**
222    * @brief Gets the duration in second for the scroll indicator to become fully invisible
223    * @return The duration for the scroll indicator to become fully invisible
224    */
225   float GetIndicatorHideDuration();
226
227   /**
228    * @brief Shows the scroll indicator
229    */
230   void Show();
231
232   /**
233    * @brief Hides the scroll indicator
234    */
235   void Hide();
236
237   /**
238    * @brief Signal emitted when the current scroll position of the scrollable content goes above or below the values
239    * specified by SetPositionNotifications.
240    *
241    * A callback of the following type may be connected:
242    * @code
243    *   void YourCallbackName(float currentScrollPosition);
244    * @endcode
245    * @pre The Object has been initialized.
246    * @return The signal to connect to.
247    */
248   ScrollBar::ScrollPositionNotifiedSignalType& ScrollPositionNotifiedSignal();
249
250 public: // Not intended for application developers
251
252   /**
253    * Creates a handle using the Toolkit::Internal implementation.
254    * @param[in]  implementation  The Control implementation.
255    */
256   DALI_INTERNAL ScrollBar( Internal::ScrollBar& implementation );
257
258   /**
259    * Allows the creation of this Control from an Internal::CustomActor pointer.
260    * @param[in]  internal  A pointer to the internal CustomActor.
261    */
262   explicit DALI_INTERNAL ScrollBar( Dali::Internal::CustomActor* internal );
263 };
264
265 } // namespace Toolkit
266
267 } // namespace Dali
268
269 /**
270  * @}
271  */
272 #endif // __DALI_TOOLKIT_SCROLL_BAR_H__