1 #ifndef __DALI_TOOLKIT_INTERNAL_CHECK_BOX_BUTTON_DEFAULT_PAINTER_H__
2 #define __DALI_TOOLKIT_INTERNAL_CHECK_BOX_BUTTON_DEFAULT_PAINTER_H__
5 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 #include <dali/public-api/images/image.h>
23 #include <dali/public-api/actors/actor.h>
24 #include <dali/public-api/math/vector2.h>
25 #include <dali/public-api/animation/animation.h>
26 #include <dali-toolkit/public-api/shader-effects/image-region-effect.h>
28 #include "check-box-button-painter-impl.h"
39 // Forward declarations
42 class CheckBoxButtonDefaultPainter;
46 typedef IntrusivePtr<CheckBoxButtonDefaultPainter> CheckBoxButtonDefaultPainterPtr;
49 * CheckBoxButtonDefaultPainter controls the Dali::Toolkit::CheckBoxButton appearance.
51 * This class inherits from Dali::Toolkit::Internal::CheckBoxButtonPainter and is registered in a
52 * Dali::Toolkit::Internal::CheckBoxButton object in order to receive the state changes.
54 class CheckBoxButtonDefaultPainter : public CheckBoxButtonPainter
60 * Set actors and animations to NULL.
62 CheckBoxButtonDefaultPainter();
67 * It clears all fade in or fade out animations.
69 ~CheckBoxButtonDefaultPainter();
71 /////////////////////////////////////////////////////////////////////////////
72 // ButtonPainter interface
73 /////////////////////////////////////////////////////////////////////////////
76 * @copydoc ButtonPainter::Initialize( Toolkit::Button& button )
78 virtual void Initialize( Toolkit::Button& button );
81 * @copydoc ButtonPainter::SetSize( Toolkit::Button& button, const Vector3& size )
83 virtual void SetSize( Toolkit::Button& button, const Vector3& size );
86 * @copydoc ButtonPainter::SetDisabled( Toolkit::Button& button, bool disabled )
88 virtual void SetDisabled( Toolkit::Button& button, bool disabled );
91 * @copydoc ButtonPainter::SetAnimationTime( float animationTime )
93 virtual void SetAnimationTime( float animationTime );
96 * @copydoc ButtonPainter::GetAnimationTime()
98 virtual float GetAnimationTime() const;
101 * @copydoc ButtonPainter::SetSelectedImage( Toolkit::Button& button, Actor image )
103 virtual void SetSelectedImage( Toolkit::Button& button, Actor image );
106 * @copydoc ButtonPainter::SetBackgroundImage( Toolkit::Button& button, Actor image )
108 virtual void SetBackgroundImage( Toolkit::Button& button, Actor image );
111 * @copydoc ButtonPainter::SetDisabledSelectedImage( Toolkit::Button& button, Actor image )
113 virtual void SetDisabledSelectedImage( Toolkit::Button& button, Actor image );
116 * @copydoc ButtonPainter::SetDisabledBackgroundImage( Toolkit::Button& button, Actor image )
118 virtual void SetDisabledBackgroundImage( Toolkit::Button& button, Actor image );
120 /////////////////////////////////////////////////////////////////////////////
121 // CheckBoxButtonPainter interface
122 /////////////////////////////////////////////////////////////////////////////
125 * This method is called when the Dali::Toolkit::Internal::CheckBoxButton in which this object is registered
128 * @param[inout] checkBox The Dali::Toolkit::CheckBoxButton in which this object is registered.
130 void Selected( Toolkit::Button& checkBox );
135 CheckBoxButtonDefaultPainter( const CheckBoxButtonDefaultPainter& );
138 CheckBoxButtonDefaultPainter& operator=( const CheckBoxButtonDefaultPainter& );
143 * Default check box button painter states.
147 UnselectedState, ///< The check box button is unselected.
148 SelectedState, ///< The check box button is selected.
149 DisabledUnselectedState, ///< The check box button is disabled and unselected.
150 DisabledSelectedState, ///< The check box button is disabled and selected.
151 UnselectedSelectedTransition, ///< The check box button is in transition from unselected to selected.
152 SelectedUnselectedTransition, ///< The check box button is in transition from selected to unselected.
153 UnselectedDisabledTransition, ///< The check box button is in transition from unselected to disabled.
154 DisabledUnselectedTransition, ///< The check box button is in transition from disabled to unselected.
155 SelectedDisabledTransition, ///< The check box button is in transition from selected to disabled.
156 DisabledSelectedTransition ///< The check box button is in transition from disabled to selected.
160 * Used in the FadeOut functions.
164 Background, ///< Fade out the background.
165 Foreground ///< Fade out the foreground.
170 * Apply size and position constraints to painter actors.
172 * @param[inout] actor The actor.
173 * @param[in] depth Depth position.
175 void ApplyConstraint( Actor& actor, float depth );
178 * Apply size constraint to check tick
180 * @param[inout] actor The actor.
181 * @param[in] depth Depth position.
183 void ApplySelectedConstraint( Actor& actor, float depth );
186 * Adds the actor to the fade in animation. It creates a fade in animation if needed.
188 * @param[in] actor The actor.
190 void AddToFadeInAnimation( const Actor& actor );
193 * Starts the check in animation.
195 * CheckBoxButtonDefaultPainter::CheckInAnimationFinished slot is called when the animation finishes.
197 void StartCheckInAnimation();
200 * Stops the check in animation.
202 void StopCheckInAnimation();
205 * Adds the actor to the fade out animation. It creates a fade out animation if needed.
207 * @param[in] actor The actor.
209 void AddToFadeOutAnimation( const Actor& actor );
212 * Starts the check out animation.
214 * CheckBoxButtonDefaultPainter::CheckOutAnimationFinished slot is called when the animation finishes.
216 * @param[inout] checkBox The button which holds images.
218 void StartCheckOutAnimation( Toolkit::CheckBoxButton& checkBox );
221 * Stops the fade out animation.
223 * It removes the actor stored in CheckBoxButtonDefaultPainter::mFadeOutBackgroundImage and
224 * CheckBoxButtonDefaultPainter::mFadeOutSelectedImage.
226 * @param[inout] checkBox The button which holds images.
227 * @param[in] remove If true, removes the fadeout actor from root.
229 void StopCheckOutAnimation( Toolkit::CheckBoxButton& checkBox, bool remove = true );
232 * It adds the actor to the root actor and to the fade in animation.
234 * @param[inout] checkBox The button which holds images.
235 * @param[inout] image The actor.
236 * @param[in] opacity The initial opacity.
238 void FadeInImage( Toolkit::CheckBoxButton& checkBox, Actor& image, float opacity = 0.f );
241 * It adds the actor fade out animation and stores it to be removed when the animation finishes.
243 * @param[inout] checkBox The button which holds images.
244 * @param[in] layer Defines if the actor is going to be stored in the mFadeOutBackgroundImage or mFadeOutSelectedImage member.
245 * @param[inout] image The actor.
246 * @param[in] opacity The initial opacity.
248 void FadeOutImage( Toolkit::CheckBoxButton& checkBox, ImageLayer layer, Actor& image, float opacity = 1.f );
251 * Adds the actor to the fade in animation. It creates a fade in animation if needed.
253 * @param[in] actor The actor.
255 void AddToCheckInAnimation( const Actor& actor );
258 * It adds the actor to the root actor and to the fade in animation.
260 * @param[inout] checkBox The button which holds images.
261 * @param[inout] image The actor.
263 void SetupSelectedAnimation( Toolkit::CheckBoxButton& checkBox, Actor& image );
266 * Signal end of check out animation
268 void EndCheckOutAnimation();
273 * Called when the fade out animation finishes.
275 * It changes the check button painter state and removes actors from the root.
277 void CheckOutAnimationFinished( Dali::Animation& source );
280 * Called when the fade in animation finishes.
282 * It changes the check button painter state.
284 void CheckInAnimationFinished( Dali::Animation& source );
287 bool mDisabled; ///< Stores the disabled property.
289 PaintState mPaintState; ///< The painter state.
291 Animation mCheckInAnimation; ///< Animation used in the state transitions.
292 Animation mCheckOutAnimation; ///< Animation used in the state transitions.
293 Internal::CheckBoxButton* mButton; ///< Temporary pointer used to remove fade out images from button.
294 float mAnimationTime; ///< The animation time.
296 ImageRegionEffect mTickUVEffect; ///< ImageRegionEffect to expand the tick across
298 Property::Index mPercentageParentSizeProperty; ///< Dynamic property on the image actor
301 } // namespace Internal
303 } // namespace Toolkit
307 #endif // __DALI_TOOLKIT_INTERNAL_CHECK_BOX_BUTTON_DEFAULT_PAINTER_H__