5adb04c425a9a643747e7c82950c91806c697653
[platform/core/uifw/dali-toolkit.git] / 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/control.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 Control
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 public:
53
54   /**
55    * @brief Create an uninitialized ScrollBar; this can be initialized with ScrollBar::New()
56    * Calling member functions with an uninitialized Dali::Object is not allowed.
57    * or horizontally (false)
58    */
59   ScrollBar();
60
61   /**
62    * @brief Copy constructor.
63    */
64   ScrollBar( const ScrollBar& scrollBar );
65
66   /**
67    * @brief Assignment operator.
68    */
69   ScrollBar& operator=( const ScrollBar& scrollBar );
70
71   /**
72    * @brief Virtual destructor.
73    * Dali::Object derived classes typically do not contain member data.
74    */
75   virtual ~ScrollBar();
76
77   /**
78    * @brief Create an initialized ScrollBar
79    * @return A pointer to the created ScrollBar.
80    */
81   static ScrollBar New();
82
83   /**
84    * @brief Downcast an Object handle to ScrollBar. If handle points to a ScrollBar the
85    * downcast produces valid handle. If not the returned handle is left uninitialized.
86    * @param[in] handle Handle to an object
87    * @return handle to a ScrollBar or an uninitialized handle
88    */
89   static ScrollBar DownCast( BaseHandle handle );
90
91   /**
92    * @brief Sets the scroll connector for the scroll bar.
93    *
94    * @pre The scroll bar actor has been initialised.
95    *
96    * @param[in] connector Scroll connector used to connect scrollable container with this ScrollBar
97    */
98  void SetScrollConnector( ScrollConnector connector );
99
100   /**
101    * @brief Sets the image for the background of scroll indicator.
102    *
103    * @pre The scroll bar actor has been initialised.
104    *
105    * The background image is resized (stretched according to scale settings),
106    * to the size of the ScrollBar.
107    *
108    * @param[in] image The image to cover background
109    * @param[in] border The nine patch border for the image.
110    */
111  void SetBackgroundImage( Image image, const Vector4& border );
112
113   /**
114    * @brief Sets the image for the indicator of scroll bar.
115    *
116    * @pre The scroll bar actor has been initialised.
117    *
118    * The indicator image is resized (stretched according to scale settings),
119    * to reflect the size of the scroll indicator and minimum/maximum limits
120    * of the scroll position.
121    *
122    * @param[in] image The image of indicator that moves to indicate the current scroll position.
123    * @param[in] border The nine patch border for the image.
124    */
125   void SetIndicatorImage( Image image, const Vector4& border );
126
127   /**
128    * @brief Gets the indicator of scroll bar.
129    *
130    * @pre The scroll bar actor has been initialised.
131    *
132    * The indicator indicates the current scroll position of the scrollable content.
133    */
134   Actor GetScrollIndicator();
135
136   /**
137    * @brief Sets the values to get notification when the current scroll position of the scrollable
138    * content goes above or below any of these values.
139    *
140    * @pre The scroll bar actor has been initialised.
141    *
142    * @param[in] positions List of values to receive notifications for when the current scroll position crosses them
143    */
144   void SetPositionNotifications( const std::vector<float>& positions );
145
146   /**
147    * @brief Shows the scroll indicator
148    */
149   void Show();
150
151   /**
152    * @brief Hides the scroll indicator
153    */
154   void Hide();
155
156   /**
157    * @brief Signal emitted when the current scroll position of the scrollable content goes above or below the values
158    * specified by SetPositionNotifications.
159    *
160    * A callback of the following type may be connected:
161    * @code
162    *   void YourCallbackName(float currentScrollPosition);
163    * @endcode
164    * @pre The Object has been initialized.
165    * @return The signal to connect to.
166    */
167   ScrollBar::ScrollPositionNotifiedSignalType& ScrollPositionNotifiedSignal();
168
169 public: // Not intended for application developers
170
171   /**
172    * Creates a handle using the Toolkit::Internal implementation.
173    * @param[in]  implementation  The Control implementation.
174    */
175   ScrollBar( Internal::ScrollBar& implementation );
176
177   /**
178    * Allows the creation of this Control from an Internal::CustomActor pointer.
179    * @param[in]  internal  A pointer to the internal CustomActor.
180    */
181   ScrollBar( Dali::Internal::CustomActor* internal );
182 };
183
184 } // namespace Toolkit
185
186 } // namespace Dali
187
188 /**
189  * @}
190  */
191 #endif // __DALI_TOOLKIT_SCROLL_BAR_H__