Merge "Fix for lock up on Text Shadow ( not clearing up rendertask correctly )" into...
[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   /**
81    * @copydoc Toolkit::Internal::Button::OnButtonInitialize()
82    */
83   virtual void OnButtonInitialize();
84
85   /**
86    * @copydoc Toolkit::Internal::Button::OnLabelSet()
87    */
88   virtual void OnLabelSet();
89
90   /**
91    * @copydoc Toolkit::Internal::Button::OnSelected()
92    */
93   virtual void OnSelected( bool selected );
94
95   /**
96    * @copydoc Toolkit::Internal::Button::OnDisabled( bool disabled )
97    */
98   virtual void OnDisabled( bool disabled );
99
100 private:
101
102   /**
103    * Construct a new CheckBoxButton.
104    */
105   CheckBoxButton();
106
107   /**
108    * A reference counted object may only be deleted by calling Unreference()
109    */
110   virtual ~CheckBoxButton();
111
112 private:
113
114   /**
115    * Adds the actor to the button.
116    */
117   void AddChild( Actor& actor );
118
119   /**
120    * Removes the actor from the button.
121    */
122   void RemoveChild( Actor& actor );
123
124   /**
125    * Adds the actor to the check in animation.
126    * It creates a check in animation if needed and starts the check in animation.
127    * @param[in] actor The actor.
128    */
129   void StartCheckInAnimation( Actor& actor );
130
131   /**
132    * Stops the check in animation.
133    */
134   void StopCheckInAnimation();
135
136   // slots
137
138   /**
139    * Called when the check in animation finishes.
140    * It changes the check button paint state.
141    */
142   void CheckInAnimationFinished( Dali::Animation& source );
143
144 private:
145
146   // Undefined
147   CheckBoxButton( const CheckBoxButton& );
148
149   // Undefined
150   CheckBoxButton& operator=( const CheckBoxButton& );
151
152 private:
153   Animation                 mCheckInAnimation;  ///< Animation used in the state transitions.
154   ImageRegionEffect         mTickUVEffect;      ///< ImageRegionEffect to expand the tick across
155
156   PaintState                mPaintState;        ///< The paint state.
157 };
158
159 } // namespace Internal
160
161 // Helpers for public-api forwarding methods
162
163 inline Toolkit::Internal::CheckBoxButton& GetImplementation( Toolkit::CheckBoxButton& button )
164 {
165   DALI_ASSERT_ALWAYS( button );
166
167   Dali::RefObject& handle = button.GetImplementation();
168
169   return static_cast<Toolkit::Internal::CheckBoxButton&>( handle );
170 }
171
172 inline const Toolkit::Internal::CheckBoxButton& GetImplementation( const Toolkit::CheckBoxButton& button )
173 {
174   DALI_ASSERT_ALWAYS( button );
175
176   const Dali::RefObject& handle = button.GetImplementation();
177
178   return static_cast<const Toolkit::Internal::CheckBoxButton&>( handle );
179 }
180
181 } // namespace Toolkit
182
183 } // namespace Dali
184
185 #endif // __DALI_TOOLKIT_INTERNAL_CHECK_BOX_BUTTON_H__