1 #ifndef __DALI_TOOLKIT_INTERNAL_SCROLL_BAR_H__
2 #define __DALI_TOOLKIT_INTERNAL_SCROLL_BAR_H__
5 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
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
11 // http://floralicense.org/license/
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.
21 #include <dali-toolkit/public-api/controls/scrollable/scroll-component-impl.h>
22 #include <dali-toolkit/public-api/controls/scrollable/scroll-connector.h>
23 #include <dali-toolkit/public-api/controls/scroll-bar/scroll-bar.h>
36 typedef IntrusivePtr<ScrollBar> ScrollBarPtr;
39 * ScrollBar is a UI component that can be added to the scrollable controls
40 * indicating the current scroll position of the scrollable content.
42 class ScrollBar : public ScrollComponentImpl
47 typedef Toolkit::ScrollBar::ScrollPositionNotifiedSignalType ScrollPositionNotifiedSignalType;
52 * @copydoc Toolkit::ScrollBar::ScrollBar()
57 * @copydoc Toolkit::ScrollBar::~ScrollBar()
62 * @copydoc Toolkit::ScrollBar::New()
64 static Toolkit::ScrollBar New();
67 * @copydoc Toolkit::ScrollComponentImpl::OnScrollConnectorSet()
69 void OnScrollConnectorSet( Toolkit::ScrollConnector connector );
72 * @copydoc Toolkit::ScrollBar::SetBackgroundImage()
74 void SetBackgroundImage( Image image, const Vector4& border );
77 * @copydoc Toolkit::ScrollBar::SetIndicatorImage()
79 void SetIndicatorImage( Image image, const Vector4& border );
82 * @copydoc Toolkit::ScrollBar::GetScrollIndicator()
84 Actor GetScrollIndicator();
87 * @copydoc Toolkit::ScrollBar::SetPositionNotifications()
89 void SetPositionNotifications( const std::vector<float>& positions );
92 * @copydoc Toolkit::ScrollBar::Show()
97 * @copydoc Toolkit::ScrollBar::Hide()
102 * Signal emitted after the SetScrollDomain() method has been called.
104 ScrollPositionNotifiedSignalType& ScrollPositionNotifiedSignal()
106 return mScrollPositionNotifiedSignal;
109 private: // from ControlImpl
112 * @copydoc Toolkit::Control::OnInitialize
114 virtual void OnInitialize();
117 * @copydoc Toolkit::Control::OnPan
119 virtual void OnPan( PanGesture gesture );
124 * Apply constraints for background and indicator.
125 * These constraints are based on values from the scroll connector.
127 void ApplyConstraints();
130 * Callback when the start & end position and size of the scrollable content are changed.
131 * @param[in] minPosition The minimum position.
132 * @param[in] maxPosition The maximum position.
133 * @param[in] contentSize The size of scrollable content.
135 void OnScrollDomainChanged(float minPosition, float maxPosition, float contentSize);
138 * Callback when the current scroll position of the scrollable content goes above or
139 * below the values specified by SetPositionNotifications().
140 * @param[in] source the property notification that triggered this callback
142 void OnScrollPositionNotified(PropertyNotification& source);
145 * Process the pan gesture per predefined timeout until the gesture is finished.
146 * @return True if the timer should be kept running.
148 bool OnPanGestureProcessTick();
152 Constrainable mScrollPositionObject; ///< From mScrollConnector
154 ImageActor mBackground; ///< Background image of scroll bar.
155 ImageActor mIndicator; ///< Image of scroll indicator.
156 Animation mAnimation; ///< Scroll indicator Show/Hide Animation.
158 float mScrollStart; ///< Scroll Start position (start of drag)
159 Vector3 mGestureDisplacement; ///< Gesture Displacement.
161 bool mIsPanning; ///< Whether the scroll bar is being panned.
162 float mCurrentScrollPosition; ///< The current scroll position updated by the pan gesture
164 Timer mTimer; ///< The timer to process the pan gesture after the gesture is started.
166 Property::Index mPropertyIndicatorPosition; ///< Indicatore Position ("indicator-position")
168 PropertyNotification mPositionNotification; ///< Stores the property notification used for scroll position changes
170 ScrollPositionNotifiedSignalType mScrollPositionNotifiedSignal;
173 } // namespace Internal
175 // Helpers for public-api forwarding methods
177 inline Toolkit::Internal::ScrollBar& GetImpl(Toolkit::ScrollBar& scrollBar)
179 DALI_ASSERT_ALWAYS(scrollBar);
181 Dali::RefObject& handle = scrollBar.GetImplementation();
183 return static_cast<Toolkit::Internal::ScrollBar&>(handle);
186 inline const Toolkit::Internal::ScrollBar& GetImpl(const Toolkit::ScrollBar& scrollBar)
188 DALI_ASSERT_ALWAYS(scrollBar);
190 const Dali::RefObject& handle = scrollBar.GetImplementation();
192 return static_cast<const Toolkit::Internal::ScrollBar&>(handle);
195 } // namespace Toolkit
199 #endif // __DALI_TOOLKIT_INTERNAL_SCROLL_BAR_H__