Merge "Apply the new doxygen tagging rule for @SINCE" into devel/master
[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 // INTERNAL INCLUDES
22 #include <dali-toolkit/public-api/controls/control.h>
23
24 namespace Dali
25 {
26
27 namespace Toolkit
28 {
29
30 namespace Internal DALI_INTERNAL
31 {
32 // Forward declarations
33
34 class ScrollBar;
35 }
36 /**
37  * @addtogroup dali_toolkit_controls_scroll_bar
38  * @{
39  */
40
41 /**
42  * @brief ScrollBar is a UI component that can be linked to the scrollable objects
43  * indicating the current scroll position of the scrollable object.
44  *
45  * Signals
46  * | %Signal Name                  | Method                                     |
47  * |-------------------------------|--------------------------------------------|
48  * | panFinished                   | @ref PanFinishedSignal()                   |
49  * | scrollPositionIntervalReached | @ref ScrollPositionIntervalReachedSignal() |
50  * @SINCE_1_0.0
51  */
52 class DALI_IMPORT_API ScrollBar : public Control
53 {
54 public:
55
56   // Properties
57
58   /**
59    * @brief The start and end property ranges for this control.
60    * @SINCE_1_0.0
61    */
62   enum PropertyRange
63   {
64     PROPERTY_START_INDEX = Control::CONTROL_PROPERTY_END_INDEX + 1, ///< @SINCE_1_0.0
65     PROPERTY_END_INDEX =   PROPERTY_START_INDEX + 1000              ///< Reserve property indices @SINCE_1_0.0
66   };
67
68   /**
69    * @brief An enumeration of properties belonging to the ScrollBar class.
70    * @SINCE_1_0.0
71    */
72   struct Property
73   {
74     enum
75     {
76       SCROLL_DIRECTION = PROPERTY_START_INDEX, ///< name "scrollDirection",          @see SetScrollDirection(),        type std::string @SINCE_1_0.0
77       INDICATOR_HEIGHT_POLICY,                 ///< name "indicatorHeightPolicy",    @see SetIndicatorHeightPolicy(),  type std::string @SINCE_1_0.0
78       INDICATOR_FIXED_HEIGHT,                  ///< name "indicatorFixedHeight",     @see SetIndicatorFixedHeight(),   type float @SINCE_1_0.0
79       INDICATOR_SHOW_DURATION,                 ///< name "indicatorShowDuration",    @see SetIndicatorShowDuration(),  type float @SINCE_1_0.0
80       INDICATOR_HIDE_DURATION,                 ///< name "indicatorHideDuration",    @see SetIndicatorHideDuration(),  type float @SINCE_1_0.0
81       SCROLL_POSITION_INTERVALS                ///< name "scrollPositionIntervals",  @see SetScrollPositionIntervals() type Property::Array @SINCE_1_0.0
82     };
83   };
84
85   // Signals
86
87   typedef Signal< void () > PanFinishedSignalType;
88   typedef Signal< void ( float ) > ScrollPositionIntervalReachedSignalType;
89
90 public:
91
92   /**
93    * @brief Direction.
94    * @SINCE_1_0.0
95    */
96   enum Direction
97   {
98     Vertical = 0,   ///< Scroll in the vertical direction @SINCE_1_0.0
99     Horizontal      ///< Scroll in the horizontal direction @SINCE_1_0.0
100   };
101
102   /**
103    * @brief Indicator height policy.
104    * @SINCE_1_0.0
105    */
106   enum IndicatorHeightPolicy
107   {
108     Variable = 0,  ///< Variable height changed dynamically according to the length of scroll content @SINCE_1_0.0
109     Fixed          ///< Fixed height regardless of the length of scroll content @SINCE_1_0.0
110   };
111
112   /**
113    * @brief Create an uninitialized ScrollBar; this can be initialized with ScrollBar::New()
114    * Calling member functions with an uninitialized Dali::Object is not allowed.
115    * @SINCE_1_0.0
116    */
117   ScrollBar();
118
119   /**
120    * @brief Copy constructor.
121    * @SINCE_1_0.0
122    */
123   ScrollBar( const ScrollBar& scrollBar );
124
125   /**
126    * @brief Assignment operator.
127    * @SINCE_1_0.0
128    */
129   ScrollBar& operator=( const ScrollBar& scrollBar );
130
131   /**
132    * @brief Destructor
133    *
134    * This is non-virtual since derived Handle types must not contain data or virtual methods.
135    * @SINCE_1_0.0
136    */
137   ~ScrollBar();
138
139   /**
140    * @brief Create an initialized ScrollBar
141    * @SINCE_1_0.0
142    * @param[in] direction The direction of scroll bar (either vertically or horizontally).
143    * @return A pointer to the created ScrollBar.
144    */
145   static ScrollBar New(Direction direction = Vertical);
146
147   /**
148    * @brief Downcast an Object handle to ScrollBar. If handle points to a ScrollBar the
149    * downcast produces valid handle. If not the returned handle is left uninitialized.
150    * @SINCE_1_0.0
151    * @param[in] handle Handle to an object
152    * @return handle to a ScrollBar or an uninitialized handle
153    */
154   static ScrollBar DownCast( BaseHandle handle );
155
156   /**
157    * @brief Set the source of the scroll position properties.
158    *
159    * * @pre The handle to the object owing the scroll properties has been initialised and the property index must be vaild.
160    *
161    * @SINCE_1_0.0
162    * @param[in] handle The handle of the object owing the scroll properties.
163    * @param[in] propertyScrollPosition The index of the scroll position property (The scroll position, type float).
164    * @param[in] propertyMinScrollPosition The index of the minimum scroll position property (The minimum scroll position, type float).
165    * @param[in] propertyMaxScrollPosition The index of the maximum scroll position property (The maximum scroll position, type float).
166    * @param[in] propertyScrollContentSize The index of the scroll content size property (The size of the scrollable content in actor coordinates, type float).
167    */
168   void SetScrollPropertySource( Handle handle, Dali::Property::Index propertyScrollPosition, Dali::Property::Index propertyMinScrollPosition, Dali::Property::Index propertyMaxScrollPosition, Dali::Property::Index propertyScrollContentSize );
169
170   /**
171    * @brief Sets the indicator of scroll bar.
172    *
173    * @SINCE_1_0.0
174    * @param[in] indicator The indicator that moves to indicate the current scroll position.
175    * @pre The scroll bar actor has been initialised.
176    *
177    */
178   void SetScrollIndicator( Actor indicator );
179
180   /**
181    * @brief Gets the indicator of scroll bar.
182    *
183    * @SINCE_1_0.0
184    * @return The indicator indicates the current scroll position of the scrollable content.
185    * @pre The scroll bar actor has been initialised.
186    *
187    */
188   Actor GetScrollIndicator();
189
190   /**
191    * @brief Sets the list of values to get notification when the current scroll position of the scrollable
192    * object goes above or below any of these values.
193    *
194    * @SINCE_1_0.0
195    * @param[in] positions List of values to receive notifications for when the current scroll position crosses them
196    * @pre The scroll bar actor has been initialised.
197    *
198    */
199   void SetScrollPositionIntervals( const Dali::Vector<float>& positions );
200
201   /**
202    * @brief Gets the list of values to receive notifications when the current scroll position of the scrollable
203    * object goes above or below any of these values.
204    *
205    * @SINCE_1_0.0
206    * @return The list of values to receive notifications for when the current scroll position crosses them
207    * @pre The scroll bar actor has been initialised.
208    *
209    */
210   Dali::Vector<float> GetScrollPositionIntervals() const;
211
212   /**
213    * @brief Sets the direction of scroll bar to scroll either vertically or horizontally.
214    *
215    * @SINCE_1_0.0
216    * @param[in] direction The direction of scroll bar (either vertically or horizontally).
217    * @pre The scroll bar actor has been initialised.
218    *
219    */
220   void SetScrollDirection( Direction direction );
221
222   /**
223    * @brief Gets the direction of scroll bar.
224    *
225    * @SINCE_1_0.0
226    * @return The direction of scroll bar.
227    */
228   Direction GetScrollDirection() const;
229
230   /**
231    * @brief Sets the height policy of scroll indicator to have either variable or fixed height.
232    *
233    * @SINCE_1_0.0
234    * @param[in] policy The height policy of scroll indicator
235    * @pre The scroll bar actor has been initialised.
236    *
237    */
238   void SetIndicatorHeightPolicy( IndicatorHeightPolicy policy );
239
240   /**
241    * @brief Gets the height policy of scroll indicator.
242    *
243    * @SINCE_1_0.0
244    * @return The height policy of scroll indicator
245    */
246   IndicatorHeightPolicy GetIndicatorHeightPolicy() const;
247
248   /**
249    * @brief Sets the fixed height of scroll indicator.
250    * Normally the height of scroll indicator is changed dynamically according to the length of scroll content.
251    * However, when the height policy of scroll indicator is set to be fixed, the height will keep fixed
252    * regardless of the length of scroll content.
253    *
254    * @SINCE_1_0.0
255    * @param[in] height The fixed height of the scroll indicator
256    * @pre The scroll bar actor has been initialised.
257    *
258    */
259   void SetIndicatorFixedHeight( float height );
260
261   /**
262    * @brief Gets the fix height of scroll indicator.
263    * @SINCE_1_0.0
264    * @return The fixed height of the scroll indicator
265    */
266   float GetIndicatorFixedHeight() const;
267
268   /**
269    * @brief Sets the duration in second for the scroll indicator to become fully visible
270    *
271    * @SINCE_1_0.0
272    * @param[in] durationSeconds The duration for the scroll indicator to become fully visible
273    * @pre The scroll bar actor has been initialised; durationSeconds must be zero or greater; zero means the indicator will be shown instantly.
274    *
275    */
276   void SetIndicatorShowDuration( float durationSeconds );
277
278   /**
279    * @brief Gets the duration in second for the scroll indicator to become fully visible
280    * @SINCE_1_0.0
281    * @return The duration for the scroll indicator to become fully visible
282    */
283   float GetIndicatorShowDuration() const;
284
285   /**
286    * @brief Sets the duration in second for the scroll indicator to become fully invisible
287    *
288    * @SINCE_1_0.0
289    * @param[in] durationSeconds The duration for the scroll indicator to become fully invisible
290    * @pre The scroll bar actor has been initialised; durationSeconds must be zero or greater; zero means the indicator will be hidden instantly.
291    *
292    */
293   void SetIndicatorHideDuration( float durationSeconds );
294
295   /**
296    * @brief Gets the duration in second for the scroll indicator to become fully invisible
297    * @SINCE_1_0.0
298    * @return The duration for the scroll indicator to become fully invisible
299    */
300   float GetIndicatorHideDuration() const;
301
302   /**
303    * @brief Shows the scroll indicator
304    * @SINCE_1_0.0
305    */
306   void ShowIndicator();
307
308   /**
309    * @brief Hides the scroll indicator
310    * @SINCE_1_0.0
311    */
312   void HideIndicator();
313
314 public: // Signals
315
316   /**
317    * @brief Signal emitted when panning is finished on the scroll indicator.
318    * Signal only emitted when the source of the scroll position properties are set.
319    *
320    * A callback of the following type may be connected:
321    * @code
322    *   void YourCallbackName();
323    * @endcode
324    * @SINCE_1_0.0
325    * @return The signal to connect to.
326    * @pre The Object has been initialized.
327    */
328   ScrollBar::PanFinishedSignalType& PanFinishedSignal();
329
330   /**
331    * @brief Signal emitted when the current scroll position of the scrollable content
332    * goes above or below the values specified by SCROLL_POSITION_INTERVALS property.
333    * Signal only emitted when the source of the scroll position properties are set.
334    *
335    * A callback of the following type may be connected:
336    * @code
337    *   void YourCallbackName(float currentScrollPosition);
338    * @endcode
339    * @SINCE_1_0.0
340    * @return The signal to connect to.
341    * @pre The Object has been initialized.
342    */
343   ScrollBar::ScrollPositionIntervalReachedSignalType& ScrollPositionIntervalReachedSignal();
344
345 public: // Not intended for application developers
346
347   /**
348    * @brief Creates a handle using the Toolkit::Internal implementation.
349    * @SINCE_1_0.0
350    * @param[in]  implementation  The Control implementation.
351    */
352   DALI_INTERNAL ScrollBar( Internal::ScrollBar& implementation );
353
354   /**
355    * @brief Allows the creation of this Control from an Internal::CustomActor pointer.
356    * @SINCE_1_0.0
357    * @param[in]  internal  A pointer to the internal CustomActor.
358    */
359   explicit DALI_INTERNAL ScrollBar( Dali::Internal::CustomActor* internal );
360 };
361
362 /**
363  * @}
364  */
365 } // namespace Toolkit
366
367 } // namespace Dali
368
369 #endif // __DALI_TOOLKIT_SCROLL_BAR_H__