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