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