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