Updates after changes to Property::Map
[platform/core/uifw/dali-toolkit.git] / base / 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) 2014 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/dali.h>
23 #include <dali/public-api/common/vector-wrapper.h>
24
25 // INTERNAL INCLUDES
26 #include <dali-toolkit/public-api/controls/scrollable/scroll-component.h>
27
28 namespace Dali DALI_IMPORT_API
29 {
30
31 namespace Toolkit
32 {
33
34 // Forward declarations
35 class ScrollConnector;
36
37 namespace Internal DALI_INTERNAL
38 {
39 // Forward declarations
40
41 class ScrollBar;
42 }
43
44 /**
45  * ScrollBar is a UI component that can be added to the scrollable controls
46  * indicating the current scroll position of the scrollable content.
47  */
48 class ScrollBar : public ScrollComponent
49 {
50 public:
51
52   // Signals
53   static const char* const SCROLL_POSITION_NOTIFIED_SIGNAL_NAME;        ///< "scroll-position-notified" signal name
54   typedef SignalV2< void ( float ) > ScrollPositionNotifiedSignalType;
55
56   // Properties
57   static const Property::Index PROPERTY_INDICATOR_HEIGHT_POLICY;         ///< name "indicator-height-policy", @see SetIndicatorHeightPolicy(), type STRING
58   static const Property::Index PROPERTY_INDICATOR_FIXED_HEIGHT;          ///< name "indicator-fixed-height",  @see SetIndicatorFixedHeight(),  type FLOAT
59   static const Property::Index PROPERTY_INDICATOR_SHOW_DURATION;         ///< name "indicator-show-duration", @see SetIndicatorShowDuration(), type FLOAT
60   static const Property::Index PROPERTY_INDICATOR_HIDE_DURATION;         ///< name "indicator-hide-duration", @see SetIndicatorHideDuration(), type FLOAT
61
62 public:
63
64   /**
65    * @brief Indicator height policy.
66    */
67   enum IndicatorHeightPolicy
68   {
69     Variable = 0,  ///< Variable height changed dynamically according to the length of scroll content
70     Fixed          ///< Fixed height regardless of the length of scroll content
71   };
72
73   /**
74    * @brief Create an uninitialized ScrollBar; this can be initialized with ScrollBar::New()
75    * Calling member functions with an uninitialized Dali::Object is not allowed.
76    * or horizontally (false)
77    */
78   ScrollBar();
79
80   /**
81    * @brief Copy constructor.
82    */
83   ScrollBar( const ScrollBar& scrollBar );
84
85   /**
86    * @brief Assignment operator.
87    */
88   ScrollBar& operator=( const ScrollBar& scrollBar );
89
90   /**
91    * @brief Destructor
92    *
93    * This is non-virtual since derived Handle types must not contain data or virtual methods.
94    */
95   ~ScrollBar();
96
97   /**
98    * @brief Create an initialized ScrollBar
99    * @return A pointer to the created ScrollBar.
100    */
101   static ScrollBar New();
102
103   /**
104    * @brief Downcast an Object handle to ScrollBar. If handle points to a ScrollBar the
105    * downcast produces valid handle. If not the returned handle is left uninitialized.
106    * @param[in] handle Handle to an object
107    * @return handle to a ScrollBar or an uninitialized handle
108    */
109   static ScrollBar DownCast( BaseHandle handle );
110
111   /**
112    * @brief Sets the image for the indicator of scroll bar.
113    *
114    * @pre The scroll bar actor has been initialised.
115    *
116    * The indicator image is resized (stretched according to scale settings),
117    * to reflect the size of the scroll indicator and minimum/maximum limits
118    * of the scroll position.
119    *
120    * @param[in] image The image of indicator that moves to indicate the current scroll position.
121    */
122   void SetIndicatorImage( Image image );
123
124   /**
125    * @brief Gets the indicator of scroll bar.
126    *
127    * @pre The scroll bar actor has been initialised.
128    *
129    * @return The indicator indicates the current scroll position of the scrollable content.
130    */
131   Actor GetScrollIndicator();
132
133   /**
134    * @brief Sets the values to get notification when the current scroll position of the scrollable
135    * content goes above or below any of these values.
136    *
137    * @pre The scroll bar actor has been initialised.
138    *
139    * @param[in] positions List of values to receive notifications for when the current scroll position crosses them
140    */
141   void SetPositionNotifications( const std::vector<float>& positions );
142
143   /**
144    * @brief Sets the height policy of scroll indicator to have either variable or fixed height.
145    *
146    * @pre The scroll bar actor has been initialised.
147    *
148    * @param[in] policy The height policy of scroll indicator
149    */
150   void SetIndicatorHeightPolicy( IndicatorHeightPolicy policy );
151
152   /**
153    * @brief Gets the height policy of scroll indicator.
154    *
155    * @return The height policy of scroll indicator
156    */
157   IndicatorHeightPolicy GetIndicatorHeightPolicy();
158
159   /**
160    * @brief Sets the fixed height of scroll indicator.
161    * Normally the height of scroll indicator is changed dynamically according to the length of scroll content.
162    * However, when the height policy of scroll indicator is set to be fixed, the height will keep fixed
163    * regardless of the length of scroll content.
164    *
165    * @pre The scroll bar actor has been initialised.
166    *
167    * @param[in] height The fixed height of the scroll indicator
168    */
169   void SetIndicatorFixedHeight( float height );
170
171   /**
172    * @brief Gets the fix height of scroll indicator.
173    * @return The fixed height of the scroll indicator
174    */
175   float GetIndicatorFixedHeight();
176
177   /**
178    * @brief Sets the duration in second for the scroll indicator to become fully visible
179    *
180    * @pre The scroll bar actor has been initialised.
181    *
182    * @param[in] durationSeconds The duration for the scroll indicator to become fully visible
183    */
184   void SetIndicatorShowDuration( float durationSeconds );
185
186   /**
187    * @brief Gets the duration in second for the scroll indicator to become fully visible
188    * @return The duration for the scroll indicator to become fully visible
189    */
190   float GetIndicatorShowDuration();
191
192   /**
193    * @brief Sets the duration in second for the scroll indicator to become fully invisible
194    *
195    * @pre The scroll bar actor has been initialised.
196    *
197    * @param[in] durationSeconds The duration for the scroll indicator to become fully invisible
198    */
199   void SetIndicatorHideDuration( float durationSeconds );
200
201   /**
202    * @brief Gets the duration in second for the scroll indicator to become fully invisible
203    * @return The duration for the scroll indicator to become fully invisible
204    */
205   float GetIndicatorHideDuration();
206
207   /**
208    * @brief Shows the scroll indicator
209    */
210   void Show();
211
212   /**
213    * @brief Hides the scroll indicator
214    */
215   void Hide();
216
217   /**
218    * @brief Signal emitted when the current scroll position of the scrollable content goes above or below the values
219    * specified by SetPositionNotifications.
220    *
221    * A callback of the following type may be connected:
222    * @code
223    *   void YourCallbackName(float currentScrollPosition);
224    * @endcode
225    * @pre The Object has been initialized.
226    * @return The signal to connect to.
227    */
228   ScrollBar::ScrollPositionNotifiedSignalType& ScrollPositionNotifiedSignal();
229
230 public: // Not intended for application developers
231
232   /**
233    * Creates a handle using the Toolkit::Internal implementation.
234    * @param[in]  implementation  The Control implementation.
235    */
236   ScrollBar( Internal::ScrollBar& implementation );
237
238   /**
239    * Allows the creation of this Control from an Internal::CustomActor pointer.
240    * @param[in]  internal  A pointer to the internal CustomActor.
241    */
242   ScrollBar( Dali::Internal::CustomActor* internal );
243 };
244
245 } // namespace Toolkit
246
247 } // namespace Dali
248
249 /**
250  * @}
251  */
252 #endif // __DALI_TOOLKIT_SCROLL_BAR_H__