Merge branch 'master' into tizen
[platform/core/uifw/dali-toolkit.git] / optional / dali-toolkit / internal / controls / selectors / rotating-selector-impl.h
1 #ifndef __DALI_TOOLKIT_INTERNAL_CUSTOM_CHECK_ACTOR_H__
2 #define __DALI_TOOLKIT_INTERNAL_CUSTOM_CHECK_ACTOR_H__
3
4 //
5 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
6 //
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
10 //
11 //     http://floralicense.org/license/
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 // INTERNAL INCLUDES
21 #include <dali/public-api/object/ref-object.h>
22
23 #include <dali-toolkit/public-api/controls/control-impl.h>
24 #include <dali-toolkit/public-api/controls/selectors/rotating-selector.h>
25
26 namespace Dali
27 {
28
29 namespace Toolkit
30 {
31
32 namespace Internal
33 {
34
35 class RotatingSelector;
36
37
38 /**
39  * RotatingSelector is a custom control for text aligning and multiline support
40  */
41 class RotatingSelector : public Control
42 {
43 public:
44
45   /**
46    * Create a new RotatingSelector.
47    * @return A smart-pointer to the newly allocated RotatingSelector.
48    */
49   static Dali::Toolkit::RotatingSelector New(Actor& unSelectedActor, Actor& selectedActor);
50
51   /**
52    * @copydoc Dali::Toolkit::RotatingSelector::SetSelected()
53    */
54   void SetSelected( bool toggle );
55
56   /**
57    * @copydoc Dali::Toolkit::RotatingSelector::IsSelected()
58    */
59   bool IsSelected() const {return mSelected;}
60
61   /**
62    * @copydoc Dali::Toolkit::RotatingSelector::SetSelectedActor()
63    */
64   void SetSelectedActor( Actor& selectedActor );
65
66   /**
67    * @copydoc Dali::Toolkit::RotatingSelector::GetSelectedActor()
68    */
69   Actor GetSelectedActor();
70
71   /**
72    * @copydoc Dali::Toolkit::RotatingSelector::SetUnSelectedActor()
73    */
74   void SetUnSelectedActor( Actor& unSelectedActor );
75
76   /**
77    * @copydoc Dali::Toolkit::RotatingSelector::GetUnSelectedActor()
78    */
79   Actor GetUnSelectedActor();
80
81   /**
82    * @copydoc Dali::Toolkit::RotatingSelector::SetSelectable()
83    */
84   void SetSelectable( bool selectable );
85
86   /**
87    * @copydoc Dali::Toolkit::RotatingSelector::IsSelectable()
88    */
89   bool IsSelectable()const {return mSelectable;}
90
91   /**
92    * @copydoc Dali::Toolkit::RotatingSelector::SelectedSignal()
93    */
94   Toolkit::RotatingSelector::SelectedSignalV2& SelectedSignal();
95
96   /**
97    * Connects a callback function with the object's signals.
98    * @param[in] object The object providing the signal.
99    * @param[in] tracker Used to disconnect the signal.
100    * @param[in] signalName The signal to connect to.
101    * @param[in] functor A newly allocated FunctorDelegate.
102    * @return True if the signal was connected.
103    * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
104    */
105   static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
106
107 private: // From Control
108
109   /**
110    * @copydoc Toolkit::Control::OnInitialize()
111    */
112   virtual void OnInitialize();
113
114   /**
115    * @copydoc Toolkit::Control::OnTouchEvent(const TouchEvent& event)
116    */
117   virtual bool OnTouchEvent( const TouchEvent& event );
118
119 protected:
120
121   /**
122    * Construct a new RotatingSelector.
123    */
124   RotatingSelector();
125
126   /**
127    * A reference counted object may only be deleted by calling Unreference()
128    */
129   virtual ~RotatingSelector();
130
131 private:
132
133   // Undefined
134   RotatingSelector(const RotatingSelector&);
135
136   // Undefined
137   RotatingSelector& operator=(const RotatingSelector& rhs);
138
139   void ToggleAndAnimateSelection();
140   void AnimationCompleted( Animation& animation );
141
142
143 private:
144
145   Actor mContainer;
146   bool  mSelected;
147   bool  mSelectable;
148
149   Actor mUnSelectedActor;
150   Actor mSelectedActor;
151   bool  mPressed;
152
153   Animation mRotateAnimation;
154
155   bool  mIsAnimating;
156
157   Toolkit::RotatingSelector::SelectedSignalV2 mCheckedSignalV2;
158 };
159
160 } // namespace Internal
161
162 // Helpers for public-api forwarding methods
163
164 inline Toolkit::Internal::RotatingSelector& GetImpl(Toolkit::RotatingSelector& RotatingSelector)
165 {
166   DALI_ASSERT_ALWAYS(RotatingSelector);
167
168   Dali::RefObject& handle = RotatingSelector.GetImplementation();
169
170   return static_cast<Toolkit::Internal::RotatingSelector&>(handle);
171 }
172
173 inline const Toolkit::Internal::RotatingSelector& GetImpl(const Toolkit::RotatingSelector& RotatingSelector)
174 {
175   DALI_ASSERT_ALWAYS(RotatingSelector);
176
177   const Dali::RefObject& handle = RotatingSelector.GetImplementation();
178
179   return static_cast<const Toolkit::Internal::RotatingSelector&>(handle);
180 }
181
182 } // namespace Toolkit
183
184 } // namespace Dali
185
186 #endif // __DALI_TOOLKIT_INTERNAL_ITEM_VIEW_H__