#include "check-box-button-impl.h"
// EXTERNAL INCLUDES
-#include <dali/public-api/actors/image-actor.h>
#include <dali/public-api/object/type-registry.h>
#include <dali/public-api/images/resource-image.h>
//INTERNAL INCLUDES
+#include <dali-toolkit/internal/controls/image-view/image-view-impl.h>
+#include <dali-toolkit/devel-api/controls/control-depth-index-ranges.h>
#include <dali-toolkit/devel-api/shader-effects/image-region-effect.h>
namespace Dali
{
}
-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 );
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 )
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();
}
}
}
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();
}
}
}
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 );
}
{
//explicitly end the swipe animation
actor.SetScale( Vector3::ONE );
- if( mTickUVEffect )
+ if( mSelectedImage == selectedImage )
{
- mTickUVEffect.SetUniform("uBottomRight", Vector2::ONE );
+ actor.RegisterProperty( "uBottomRight", Vector2::ONE );
}
}
}