Merge "Remove obsolete and non functional SizeChanged signal from actor" into tizen
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / scroll-component / scroll-bar-internal-impl.h
1 #ifndef __DALI_TOOLKIT_INTERNAL_SCROLL_BAR_INTERNAL_H__
2 #define __DALI_TOOLKIT_INTERNAL_SCROLL_BAR_INTERNAL_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 // EXTERNAL INCLUDES
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>
25
26 // INTERNAL INCLUDES
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>
30
31 namespace Dali
32 {
33
34 namespace Toolkit
35 {
36
37 namespace Internal
38 {
39
40 /**
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.
43  */
44 class ScrollBarInternal : public ScrollComponentImpl
45 {
46
47 public:
48
49   /**
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)
54    */
55   ScrollBarInternal(Toolkit::Scrollable& container, bool vertical);
56
57   /**
58    * Virtual destructor
59    */
60   virtual ~ScrollBarInternal();
61
62   /**
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.
68    */
69   static Toolkit::ScrollBarInternal New(Toolkit::Scrollable& container, bool vertical);
70
71   /**
72    * Show ScrollBarInternal
73    */
74   void Show();
75
76   /**
77    * Hide ScrollBarInternal
78    */
79   void Hide();
80
81 private:
82
83   /**
84    * @copydoc Toolkit::Control::OnInitialize()
85    */
86   virtual void OnInitialize();
87
88   /**
89    * @copydoc Toolkit::ScrollComponent::OnDisconnect()
90    */
91   virtual void OnDisconnect();
92
93   /**
94    * Called when scrollbar is dragged.
95    * @param[in] actor Actor under touch
96    * @param[in] gesture The pan gesture data.
97    */
98   void OnPanGesture(Actor actor, PanGesture gesture);
99
100   /**
101    * Called when scrolling starts (scroll bars should extend out)
102    * @param[in] position current scroll position.
103    */
104   void OnStarted(const Vector3& position);
105
106   /**
107    * Called when scrolling ends (scroll bars should contract)
108    * @param[in] position current scroll position.
109    */
110   void OnCompleted(const Vector3& position);
111
112   /**
113    * Called when timer is finished. This time guarantee contract animation time.
114    * @return Timer is used or not.
115    */
116   bool OnContractDelayExpired(void);
117
118   /**
119    * Create timer. This timer used for wating contract.
120    */
121   void CreateTimer();
122
123   /**
124    * Destruct timer.
125    */
126   void DestructTimer();
127
128   /**
129    * Wait ContractTime
130    */
131   void WaitingContractDelay();
132
133 private:
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.
146 };
147
148 } // namespace Internal
149
150 // Helpers for public-api forwarding methods
151
152 inline Toolkit::Internal::ScrollBarInternal& GetImpl(Toolkit::ScrollBarInternal& scrollBar)
153 {
154   DALI_ASSERT_ALWAYS(scrollBar);
155
156   Dali::RefObject& handle = scrollBar.GetImplementation();
157
158   return static_cast<Toolkit::Internal::ScrollBarInternal&>(handle);
159 }
160
161 inline const Toolkit::Internal::ScrollBarInternal& GetImpl(const Toolkit::ScrollBarInternal& scrollBar)
162 {
163   DALI_ASSERT_ALWAYS(scrollBar);
164
165   const Dali::RefObject& handle = scrollBar.GetImplementation();
166
167   return static_cast<const Toolkit::Internal::ScrollBarInternal&>(handle);
168 }
169
170 } // namespace Toolkit
171
172 } // namespace Dali
173
174 #endif // __DALI_TOOLKIT_INTERNAL_SCROLL_BAR_INTERNAL_H__