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