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 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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 #include <dali-toolkit/public-api/controls/scrollable/scroll-component-impl.h>
23 #include <dali-toolkit/public-api/controls/scrollable/scroll-connector.h>
24 #include <dali-toolkit/public-api/controls/scroll-bar/scroll-bar.h>
37 typedef IntrusivePtr<ScrollBar> ScrollBarPtr;
40 * ScrollBar is a UI component that can be added to the scrollable controls
41 * indicating the current scroll position of the scrollable content.
43 class ScrollBar : public ScrollComponentImpl
48 typedef Toolkit::ScrollBar::ScrollPositionNotifiedSignalType ScrollPositionNotifiedSignalType;
53 * @copydoc Toolkit::ScrollBar::ScrollBar()
58 * @copydoc Toolkit::ScrollBar::~ScrollBar()
63 * @copydoc Toolkit::ScrollBar::New()
65 static Toolkit::ScrollBar New();
68 * @copydoc Toolkit::ScrollComponentImpl::OnScrollConnectorSet()
70 void OnScrollConnectorSet( Toolkit::ScrollConnector connector );
73 * @copydoc Toolkit::ScrollBar::SetBackgroundImage()
75 void SetBackgroundImage( Image image, const Vector4& border );
78 * @copydoc Toolkit::ScrollBar::SetIndicatorImage()
80 void SetIndicatorImage( Image image, const Vector4& border );
83 * @copydoc Toolkit::ScrollBar::GetScrollIndicator()
85 Actor GetScrollIndicator();
88 * @copydoc Toolkit::ScrollBar::SetPositionNotifications()
90 void SetPositionNotifications( const std::vector<float>& positions );
93 * @copydoc Toolkit::ScrollBar::Show()
98 * @copydoc Toolkit::ScrollBar::Hide()
103 * Signal emitted after the SetScrollDomain() method has been called.
105 ScrollPositionNotifiedSignalType& ScrollPositionNotifiedSignal()
107 return mScrollPositionNotifiedSignal;
110 private: // from ControlImpl
113 * @copydoc Toolkit::Control::OnInitialize
115 virtual void OnInitialize();
118 * @copydoc Toolkit::Control::OnPan
120 virtual void OnPan( PanGesture gesture );
125 * Apply constraints for background and indicator.
126 * These constraints are based on values from the scroll connector.
128 void ApplyConstraints();
131 * Callback when the start & end position and size of the scrollable content are changed.
132 * @param[in] minPosition The minimum position.
133 * @param[in] maxPosition The maximum position.
134 * @param[in] contentSize The size of scrollable content.
136 void OnScrollDomainChanged(float minPosition, float maxPosition, float contentSize);
139 * Callback when the current scroll position of the scrollable content goes above or
140 * below the values specified by SetPositionNotifications().
141 * @param[in] source the property notification that triggered this callback
143 void OnScrollPositionNotified(PropertyNotification& source);
146 * Process the pan gesture per predefined timeout until the gesture is finished.
147 * @return True if the timer should be kept running.
149 bool OnPanGestureProcessTick();
153 Constrainable mScrollPositionObject; ///< From mScrollConnector
155 ImageActor mBackground; ///< Background image of scroll bar.
156 ImageActor mIndicator; ///< Image of scroll indicator.
157 Animation mAnimation; ///< Scroll indicator Show/Hide Animation.
159 float mScrollStart; ///< Scroll Start position (start of drag)
160 Vector3 mGestureDisplacement; ///< Gesture Displacement.
162 bool mIsPanning; ///< Whether the scroll bar is being panned.
163 float mCurrentScrollPosition; ///< The current scroll position updated by the pan gesture
165 Timer mTimer; ///< The timer to process the pan gesture after the gesture is started.
167 Property::Index mPropertyIndicatorPosition; ///< Indicatore Position ("indicator-position")
169 PropertyNotification mPositionNotification; ///< Stores the property notification used for scroll position changes
171 ScrollPositionNotifiedSignalType mScrollPositionNotifiedSignal;
174 } // namespace Internal
176 // Helpers for public-api forwarding methods
178 inline Toolkit::Internal::ScrollBar& GetImpl(Toolkit::ScrollBar& scrollBar)
180 DALI_ASSERT_ALWAYS(scrollBar);
182 Dali::RefObject& handle = scrollBar.GetImplementation();
184 return static_cast<Toolkit::Internal::ScrollBar&>(handle);
187 inline const Toolkit::Internal::ScrollBar& GetImpl(const Toolkit::ScrollBar& scrollBar)
189 DALI_ASSERT_ALWAYS(scrollBar);
191 const Dali::RefObject& handle = scrollBar.GetImplementation();
193 return static_cast<const Toolkit::Internal::ScrollBar&>(handle);
196 } // namespace Toolkit
200 #endif // __DALI_TOOLKIT_INTERNAL_SCROLL_BAR_H__