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