Split dali-toolkit into Base & Optional
[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 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 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 image for the background of scroll indicator.
93    *
94    * @pre The scroll bar actor has been initialised.
95    *
96    * The background image is resized (stretched according to scale settings),
97    * to the size of the ScrollBar.
98    *
99    * @param[in] image The image to cover background
100    * @param[in] border The nine patch border for the image.
101    */
102  void SetBackgroundImage( Image image, const Vector4& border );
103
104   /**
105    * @brief Sets the image for the indicator of scroll bar.
106    *
107    * @pre The scroll bar actor has been initialised.
108    *
109    * The indicator image is resized (stretched according to scale settings),
110    * to reflect the size of the scroll indicator and minimum/maximum limits
111    * of the scroll position.
112    *
113    * @param[in] image The image of indicator that moves to indicate the current scroll position.
114    * @param[in] border The nine patch border for the image.
115    */
116   void SetIndicatorImage( Image image, const Vector4& border );
117
118   /**
119    * @brief Gets the indicator of scroll bar.
120    *
121    * @pre The scroll bar actor has been initialised.
122    *
123    * The indicator indicates the current scroll position of the scrollable content.
124    */
125   Actor GetScrollIndicator();
126
127   /**
128    * @brief Sets the values to get notification when the current scroll position of the scrollable
129    * content goes above or below any of these values.
130    *
131    * @pre The scroll bar actor has been initialised.
132    *
133    * @param[in] positions List of values to receive notifications for when the current scroll position crosses them
134    */
135   void SetPositionNotifications( const std::vector<float>& positions );
136
137   /**
138    * @brief Shows the scroll indicator
139    */
140   void Show();
141
142   /**
143    * @brief Hides the scroll indicator
144    */
145   void Hide();
146
147   /**
148    * @brief Signal emitted when the current scroll position of the scrollable content goes above or below the values
149    * specified by SetPositionNotifications.
150    *
151    * A callback of the following type may be connected:
152    * @code
153    *   void YourCallbackName(float currentScrollPosition);
154    * @endcode
155    * @pre The Object has been initialized.
156    * @return The signal to connect to.
157    */
158   ScrollBar::ScrollPositionNotifiedSignalType& ScrollPositionNotifiedSignal();
159
160 public: // Not intended for application developers
161
162   /**
163    * Creates a handle using the Toolkit::Internal implementation.
164    * @param[in]  implementation  The Control implementation.
165    */
166   ScrollBar( Internal::ScrollBar& implementation );
167
168   /**
169    * Allows the creation of this Control from an Internal::CustomActor pointer.
170    * @param[in]  internal  A pointer to the internal CustomActor.
171    */
172   ScrollBar( Dali::Internal::CustomActor* internal );
173 };
174
175 } // namespace Toolkit
176
177 } // namespace Dali
178
179 /**
180  * @}
181  */
182 #endif // __DALI_TOOLKIT_SCROLL_BAR_H__