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