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