X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fcontrols%2Fbuttons%2Fcheck-box-button-impl.cpp;h=44d62a51a7a5c5d99af5ec0ebddf0b4ff064da70;hp=30aba5ecc03b111504d7ea31342ea69340925b7c;hb=8d522afed46c436b653f991b7e383fae80eee7df;hpb=4517298d9e2e87d3814ddd311233568ef10f7018 diff --git a/dali-toolkit/internal/controls/buttons/check-box-button-impl.cpp b/dali-toolkit/internal/controls/buttons/check-box-button-impl.cpp index 30aba5e..44d62a5 100644 --- a/dali-toolkit/internal/controls/buttons/check-box-button-impl.cpp +++ b/dali-toolkit/internal/controls/buttons/check-box-button-impl.cpp @@ -19,11 +19,12 @@ #include "check-box-button-impl.h" // EXTERNAL INCLUDES -#include #include #include //INTERNAL INCLUDES +#include +#include #include namespace Dali @@ -81,6 +82,21 @@ CheckBoxButton::~CheckBoxButton() { } +void CheckBoxButton::SetTickUVEffect() +{ + Toolkit::ImageView imageView = Toolkit::ImageView::DownCast( mSelectedImage ); + if( imageView ) + { + imageView.RegisterProperty( "uTextureRect", Vector4(0.f, 0.f, 1.f, 1.f ) ); + imageView.RegisterProperty( "uTopLeft", Vector2::ZERO ); + + Property::Map shaderMap = CreateImageRegionEffect(); + imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, shaderMap ); + + GetImpl( imageView ).SetDepthIndex( DECORATION_DEPTH_INDEX ); + } +} + void CheckBoxButton::OnButtonInitialize() { // Wrap around all children @@ -90,6 +106,9 @@ void CheckBoxButton::OnButtonInitialize() SetSelectedImage( SELECTED_BUTTON_IMAGE_DIR ); SetDisabledImage( DISABLED_UNSELECTED_BUTTON_IMAGE_DIR ); SetDisabledSelectedImage( DISABLED_SELECTED_BUTTON_IMAGE_DIR ); + + mSelectedImage = GetSelectedImage(); + SetTickUVEffect(); } void CheckBoxButton::OnLabelSet( bool noPadding ) @@ -161,17 +180,12 @@ void CheckBoxButton::PrepareForTranstionIn( Actor actor ) if( actor == selectedImage ) { actor.SetScale( Vector3( 0.0f, 1.0f, 1.0f ) ); + actor.RegisterProperty( "uBottomRight", Vector2( 0.0f, 1.0f ) ); - if( !mTickUVEffect ) + if( mSelectedImage != selectedImage ) { - mTickUVEffect = CreateImageRegionEffect(); - } - mTickUVEffect.SetUniform("uBottomRight", Vector2( 0.0f, 1.0f ) ); - - ImageActor imageActor = ImageActor::DownCast( actor ); - if( imageActor ) - { - imageActor.SetShaderEffect( mTickUVEffect ); + mSelectedImage = selectedImage; + SetTickUVEffect(); } } } @@ -182,17 +196,12 @@ void CheckBoxButton::PrepareForTranstionOut( Actor actor ) if( actor == selectedImage ) { actor.SetScale( Vector3::ONE ); + actor.RegisterProperty( "uBottomRight", Vector2::ONE ); - if( !mTickUVEffect ) + if( mSelectedImage != selectedImage ) { - mTickUVEffect = CreateImageRegionEffect(); - } - mTickUVEffect.SetUniform("uBottomRight", Vector2::ONE ); - - ImageActor imageActor = ImageActor::DownCast( actor ); - if( imageActor ) - { - imageActor.SetShaderEffect( mTickUVEffect ); + mSelectedImage = selectedImage; + SetTickUVEffect(); } } } @@ -207,12 +216,9 @@ void CheckBoxButton::OnTransitionIn( Actor actor ) Dali::Animation transitionAnimation = GetTransitionAnimation(); if( transitionAnimation ) { - DALI_ASSERT_DEBUG( mTickUVEffect ); - if( mTickUVEffect ) - { - // UV anim - transitionAnimation.AnimateTo( Property( mTickUVEffect, "uBottomRight" ), Vector2::ONE ); - } + // UV anim + transitionAnimation.AnimateTo( Property( actor, "uBottomRight" ), Vector2::ONE ); + // Actor size anim transitionAnimation.AnimateTo( Property( actor, Actor::Property::SCALE_X ), 1.0f ); } @@ -221,9 +227,9 @@ void CheckBoxButton::OnTransitionIn( Actor actor ) { //explicitly end the swipe animation actor.SetScale( Vector3::ONE ); - if( mTickUVEffect ) + if( mSelectedImage == selectedImage ) { - mTickUVEffect.SetUniform("uBottomRight", Vector2::ONE ); + actor.RegisterProperty( "uBottomRight", Vector2::ONE ); } } }