X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fcontrols%2Fbuttons%2Fcheck-box-button-impl.cpp;h=5bf5344fae42fd085f991a60ddacbef15b0c1310;hb=refs%2Fchanges%2F49%2F88249%2F1;hp=e468c0e39622762cc1d712e3aeaed0015d3eefb5;hpb=bd4f4c078bc02ca029fdbef266f6e7b5b79650e2;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 e468c0e..5bf5344 100644 --- a/dali-toolkit/internal/controls/buttons/check-box-button-impl.cpp +++ b/dali-toolkit/internal/controls/buttons/check-box-button-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2016 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,11 +19,13 @@ #include "check-box-button-impl.h" // EXTERNAL INCLUDES -#include #include #include //INTERNAL INCLUDES +#include +#include +#include #include namespace Dali @@ -40,8 +42,6 @@ namespace const float DISTANCE_BETWEEN_IMAGE_AND_LABEL( 5.0f ); const float ANIMATION_TIME( 0.26f ); // EFL checkbox tick time -// Required for the UV reveal shader to render the tick on top of the rest of the checkbox. -const float SHADER_DEPTH_OFFSET = 1.0f; BaseHandle Create() { @@ -83,8 +83,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 ); @@ -92,6 +109,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 ) @@ -163,19 +183,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 ) { - // Ensure the tick effect is rendered above the reset of the checkbox. - imageActor.SetSortModifier( SHADER_DEPTH_OFFSET ); - imageActor.SetShaderEffect( mTickUVEffect ); + mSelectedImage = selectedImage; + SetTickUVEffect(); } } } @@ -186,17 +199,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(); } } } @@ -211,12 +219,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 ); } @@ -225,9 +230,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 ); } } }