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