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