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