1 #ifndef __DALI_TOOLKIT_INTERNAL_SCROLL_BAR_INTERNAL_H__
2 #define __DALI_TOOLKIT_INTERNAL_SCROLL_BAR_INTERNAL_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/public-api/adaptor-framework/timer.h>
23 #include <dali/public-api/actors/image-actor.h>
24 #include <dali/public-api/animation/animation.h>
27 #include <dali-toolkit/public-api/controls/scrollable/scroll-component-impl.h>
28 #include <dali-toolkit/internal/controls/scrollable/scrollable-impl.h>
29 #include <dali-toolkit/internal/controls/scroll-component/scroll-bar-internal.h>
41 * ScrollBarInternal is a UI component that can be added to the sides of the ScrollView
42 * indicating the current scroll position within the domain.
44 class ScrollBarInternal : public ScrollComponentImpl
50 * ScrollBarInternal constructor.
51 * @param[in] container Reference to the container of scroll bar
52 * @param[in] vertical Whether ScrollBarInternal should be oriented vertically (true)
53 * or horizontally (false)
55 ScrollBarInternal(Toolkit::Scrollable& container, bool vertical);
60 virtual ~ScrollBarInternal();
63 * Create an initialized ScrollBarInternal
64 * @param[in] container Reference to the container of scroll bar
65 * @param[in] vertical Whether ScrollBarInternal should be oriented vertically (true)
66 * or horizontally (false)
67 * @return A pointer to the created ScrollBarInternal.
69 static Toolkit::ScrollBarInternal New(Toolkit::Scrollable& container, bool vertical);
72 * Show ScrollBarInternal
77 * Hide ScrollBarInternal
84 * @copydoc Toolkit::Control::OnInitialize()
86 virtual void OnInitialize();
89 * @copydoc Toolkit::ScrollComponent::OnDisconnect()
91 virtual void OnDisconnect();
94 * Called when scrollbar is dragged.
95 * @param[in] actor Actor under touch
96 * @param[in] gesture The pan gesture data.
98 void OnPanGesture(Actor actor, PanGesture gesture);
101 * Called when scrolling starts (scroll bars should extend out)
102 * @param[in] position current scroll position.
104 void OnStarted(const Vector3& position);
107 * Called when scrolling ends (scroll bars should contract)
108 * @param[in] position current scroll position.
110 void OnCompleted(const Vector3& position);
113 * Called when timer is finished. This time guarantee contract animation time.
114 * @return Timer is used or not.
116 bool OnContractDelayExpired(void);
119 * Create timer. This timer used for wating contract.
126 void DestructTimer();
131 void WaitingContractDelay();
134 Scrollable& mContainer; ///< Container of scroll bar
135 ImageActor mSlider; ///< Scroll Slider.
136 ImageActor mSliderWrap; ///< Scroll Slider (wrapped view).
137 Actor mHitArea; ///< Hit Area for dragging scroll slider.
138 PanGestureDetector mPanGesture; ///< Pan Gesture detector for dragging scrollbar.
139 Animation mAnimation; ///< Scroll Contract/Expand Animation.
140 bool mVertical; ///< Scroll Axis (Vertical or Horizontal)
141 Vector3 mAxisMask; ///< Scroll Axis mask (Vector3::YAXIS for vert. or Vector3::XAXIS for horiz.)
142 Vector3 mScrollStart; ///< Scroll Start position (start of drag)
143 Vector3 mGestureDisplacement; ///< Gesture Displacement.
144 bool mDragMode; ///< Flag indicating whether currently dragging or not.
145 Timer mTimer; ///< Timer guarantee contract delay time.
148 } // namespace Internal
150 // Helpers for public-api forwarding methods
152 inline Toolkit::Internal::ScrollBarInternal& GetImpl(Toolkit::ScrollBarInternal& scrollBar)
154 DALI_ASSERT_ALWAYS(scrollBar);
156 Dali::RefObject& handle = scrollBar.GetImplementation();
158 return static_cast<Toolkit::Internal::ScrollBarInternal&>(handle);
161 inline const Toolkit::Internal::ScrollBarInternal& GetImpl(const Toolkit::ScrollBarInternal& scrollBar)
163 DALI_ASSERT_ALWAYS(scrollBar);
165 const Dali::RefObject& handle = scrollBar.GetImplementation();
167 return static_cast<const Toolkit::Internal::ScrollBarInternal&>(handle);
170 } // namespace Toolkit
174 #endif // __DALI_TOOLKIT_INTERNAL_SCROLL_BAR_INTERNAL_H__