Merge remote-tracking branch 'origin/tizen' into new_text
[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 public: // From Button
56
57   /**
58    * @copydoc Toolkit::Internal::Button::SetSelectedImage( Actor image )
59    */
60   virtual void SetSelectedImage( Actor image );
61
62   /**
63    * @copydoc Toolkit::Internal::Button::SetBackgroundImage( Actor image )
64    */
65   virtual void SetBackgroundImage( Actor image );
66
67   /**
68    * @copydoc Toolkit::Internal::Button::SetDisabledSelectedImage( Actor image )
69    */
70   virtual void SetDisabledSelectedImage( Actor image );
71
72   /**
73    * @copydoc Toolkit::Internal::Button::SetDisabledBackgroundImage( Actor image )
74    */
75   virtual void SetDisabledBackgroundImage( Actor image );
76
77 private: // From Button
78
79   /**
80    * @copydoc Toolkit::Internal::Button::OnLabelSet()
81    */
82   virtual void OnLabelSet();
83
84   /**
85    * @copydoc Toolkit::Internal::Button::OnSelected()
86    */
87   virtual void OnSelected( bool selected );
88
89   /**
90    * @copydoc Toolkit::Internal::Button::OnDisabled( bool disabled )
91    */
92   virtual void OnDisabled( bool disabled );
93
94 private: // From Control
95
96   /**
97    * @copydoc Dali::Toolkit::Control::OnRelayout()
98    */
99   virtual void OnRelayout( const Vector2& size, ActorSizeContainer& container );
100
101 private:
102
103   /**
104    * Construct a new CheckBoxButton.
105    */
106   CheckBoxButton();
107
108   /**
109    * A reference counted object may only be deleted by calling Unreference()
110    */
111   virtual ~CheckBoxButton();
112
113 private:
114
115   /**
116    * Adds the actor to the button.
117    */
118   void AddChild( Actor& actor );
119
120   /**
121    * Removes the actor from the button.
122    */
123   void RemoveChild( Actor& actor );
124
125   /**
126    * Adds the actor to the check in animation.
127    * It creates a check in animation if needed and starts the check in animation.
128    * @param[in] actor The actor.
129    */
130   void StartCheckInAnimation( Actor& actor );
131
132   /**
133    * Stops the check in animation.
134    */
135   void StopCheckInAnimation();
136
137   // slots
138
139   /**
140    * Called when the check in animation finishes.
141    * It changes the check button paint state.
142    */
143   void CheckInAnimationFinished( Dali::Animation& source );
144
145 private:
146
147   // Undefined
148   CheckBoxButton( const CheckBoxButton& );
149
150   // Undefined
151   CheckBoxButton& operator=( const CheckBoxButton& );
152
153 private:
154   Animation                 mCheckInAnimation;  ///< Animation used in the state transitions.
155   ImageRegionEffect         mTickUVEffect;      ///< ImageRegionEffect to expand the tick across
156
157   PaintState                mPaintState;        ///< The paint state.
158 };
159
160 } // namespace Internal
161
162 // Helpers for public-api forwarding methods
163
164 inline Toolkit::Internal::CheckBoxButton& GetImplementation( Toolkit::CheckBoxButton& button )
165 {
166   DALI_ASSERT_ALWAYS( button );
167
168   Dali::RefObject& handle = button.GetImplementation();
169
170   return static_cast<Toolkit::Internal::CheckBoxButton&>( handle );
171 }
172
173 inline const Toolkit::Internal::CheckBoxButton& GetImplementation( const Toolkit::CheckBoxButton& button )
174 {
175   DALI_ASSERT_ALWAYS( button );
176
177   const Dali::RefObject& handle = button.GetImplementation();
178
179   return static_cast<const Toolkit::Internal::CheckBoxButton&>( handle );
180 }
181
182 } // namespace Toolkit
183
184 } // namespace Dali
185
186 #endif // __DALI_TOOLKIT_INTERNAL_CHECK_BOX_BUTTON_H__