X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fcontrols%2Fbuttons%2Fcheck-box-button-impl.cpp;h=6607c5cda33109dd8e5aa64c41be72591206947c;hb=28658e9b0c89fced72173c582b9c5635e07bd6f1;hp=0aa4e830c9d94bea77e5b25159b8697e263b5f1e;hpb=8269fc656ce5c08314e340932c2af762e7234628;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git 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 0aa4e83..6607c5c 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,8 +82,25 @@ CheckBoxButton::~CheckBoxButton() { } -void CheckBoxButton::OnButtonInitialize() +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( DepthIndex::DECORATION ); + } +} + +void CheckBoxButton::OnInitialize() +{ + Button::OnInitialize(); + // Wrap around all children Self().SetResizePolicy( ResizePolicy::FIT_TO_CHILDREN, Dimension::ALL_DIMENSIONS ); @@ -90,9 +108,12 @@ 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() +void CheckBoxButton::OnLabelSet( bool noPadding ) { Actor& label = GetLabelActor(); @@ -161,17 +182,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 ) - { - mTickUVEffect = CreateImageRegionEffect(); - } - mTickUVEffect.SetUniform("uBottomRight", Vector2( 0.0f, 1.0f ) ); - - ImageActor imageActor = ImageActor::DownCast( actor ); - if( imageActor ) + if( mSelectedImage != selectedImage ) { - imageActor.SetShaderEffect( mTickUVEffect ); + mSelectedImage = selectedImage; + SetTickUVEffect(); } } } @@ -182,17 +198,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 +218,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 +229,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 ); } } }