Revert to tizen branch.
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / buttons / check-box-button-impl.h
1 #ifndef __DALI_TOOLKIT_INTERNAL_CHECK_BOX_BUTTON_H__
2 #define __DALI_TOOLKIT_INTERNAL_CHECK_BOX_BUTTON_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/common/dali-vector.h>
23 #include <dali/public-api/animation/animation.h>
24
25 // INTERNAL INCLUDES
26 #include <dali-toolkit/public-api/controls/buttons/check-box-button.h>
27 #include <dali-toolkit/public-api/shader-effects/image-region-effect.h>
28
29 #include "button-impl.h"
30
31 namespace Dali
32 {
33
34 namespace Toolkit
35 {
36
37 namespace Internal
38 {
39
40 /**
41  * CheckBoxButton implementation class.
42  *
43  * \sa Dali::Toolkit::CheckBoxButton
44  */
45 class CheckBoxButton : public Button
46 {
47 public:
48
49   /**
50    * Create a new CheckBoxButton.
51    * @return A smart-pointer to the newly allocated CheckBoxButton.
52    */
53   static Dali::Toolkit::CheckBoxButton New();
54
55 private:
56
57   /**
58    * Construct a new CheckBoxButton.
59    */
60   CheckBoxButton();
61
62   /**
63    * A reference counted object may only be deleted by calling Unreference()
64    */
65   virtual ~CheckBoxButton();
66
67 private: // From Button
68
69
70   /**
71    * @copydoc Toolkit::Internal::Button::OnButtonInitialize()
72    */
73   virtual void OnButtonInitialize();
74
75   /**
76    * @copydoc Toolkit::Internal::Button::OnLabelSet()
77    */
78   virtual void OnLabelSet();
79
80   /**
81    * @copydoc Toolkit::Internal::Button::OnSelected()
82    */
83   virtual bool OnSelected();
84
85   /**
86    * @copydoc Toolkit::Internal::Button::OnDisabled()
87    */
88   virtual bool OnDisabled();
89
90   /**
91    * @copydoc Toolkit::Internal::Button::StopAllAnimations()
92    */
93   virtual void StopAllAnimations();
94
95 private:
96
97   /**
98    * Adds the actor to the transition animation.
99    * It creates a transition animation if needed and starts the animation.
100    * @param[in] actor The actor.
101    */
102   void StartTransitionAnimation( Actor& actor );
103
104   /**
105    * Stops the transition animation.
106    * @param[in] remove If true, removes the fadeout actor from root.
107    */
108   void StopTransitionAnimation( bool remove = true );
109
110   // slots
111
112   /**
113    * Called when the transition animation finishes.
114    */
115   void TransitionAnimationFinished( Dali::Animation& source );
116
117 private:
118
119   // Undefined
120   CheckBoxButton( const CheckBoxButton& );
121
122   // Undefined
123   CheckBoxButton& operator=( const CheckBoxButton& );
124
125 private:
126   Animation                 mTransitionAnimation;  ///< Animation used in the state transitions.
127   ImageRegionEffect         mTickUVEffect;         ///< ImageRegionEffect to expand the tick across
128 };
129
130 } // namespace Internal
131
132 // Helpers for public-api forwarding methods
133
134 inline Toolkit::Internal::CheckBoxButton& GetImplementation( Toolkit::CheckBoxButton& button )
135 {
136   DALI_ASSERT_ALWAYS( button );
137
138   Dali::RefObject& handle = button.GetImplementation();
139
140   return static_cast<Toolkit::Internal::CheckBoxButton&>( handle );
141 }
142
143 inline const Toolkit::Internal::CheckBoxButton& GetImplementation( const Toolkit::CheckBoxButton& button )
144 {
145   DALI_ASSERT_ALWAYS( button );
146
147   const Dali::RefObject& handle = button.GetImplementation();
148
149   return static_cast<const Toolkit::Internal::CheckBoxButton&>( handle );
150 }
151
152 } // namespace Toolkit
153
154 } // namespace Dali
155
156 #endif // __DALI_TOOLKIT_INTERNAL_CHECK_BOX_BUTTON_H__