/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 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.
GaussianBlurViewExample( Application& application )
: mApplication( application ),
mExcessWidth( 0.0f ),
- mStrength( 1.0f )
+ mStrength( 1.0f ),
+ mActivate( false )
{
mApplication.InitSignal().Connect( this, &GaussianBlurViewExample::Create );
}
mImageView.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
mImageView.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
- stage.Add( mImageView );
-
float excessWidth = std::max( 0.0f, (BACKGROUND_IMAGE_WIDTH - stageSize.width) * 0.5f );
if( excessWidth > 0.0f )
mOffLabel.SetProperty( Actor::Property::VISIBLE, true );
onTop.Add( mOffLabel );
+ mGaussianBlurView = GaussianBlurView::New( 30, 8.0f, Pixel::RGBA8888, 0.5f, 0.5f, false );
+ mGaussianBlurView.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
+ mGaussianBlurView.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
+ mGaussianBlurView.SetProperty( Actor::Property::SIZE, stage.GetSize() );
+ stage.Add( mGaussianBlurView );
+
+ mGaussianBlurView.Add( mImageView );
+ mGaussianBlurView.SetProperty( mGaussianBlurView.GetBlurStrengthPropertyIndex(), mStrength );
+
stage.GetRootLayer().TouchSignal().Connect( this, &GaussianBlurViewExample::OnTouch );
}
bool OnTouch( Actor actor, const TouchData& touch )
{
- const PointState::Type state = touch.GetState( 0 );
+ const PointState::Type state = touch.GetState( 0 );
- if( PointState::DOWN == state )
+ if( PointState::DOWN == state )
+ {
+ if( !mActivate )
{
- Stage stage = Stage::GetCurrent();
-
- // Enable/disable blur effect
-
- if( !mGaussianBlurView )
- {
- mGaussianBlurView = GaussianBlurView::New( 30, 8.0f, Pixel::RGBA8888, 0.5f, 0.5f, false );
- mGaussianBlurView.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
- mGaussianBlurView.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
- mGaussianBlurView.SetProperty( Actor::Property::SIZE, stage.GetSize() );
- stage.Add( mGaussianBlurView );
-
- mGaussianBlurView.Add( mImageView );
- mGaussianBlurView.Activate();
+ mActivate = true;
+ mGaussianBlurView.Activate();
- mGaussianBlurView.SetProperty( mGaussianBlurView.GetBlurStrengthPropertyIndex(), mStrength );
-
- mOnLabel.SetProperty( Actor::Property::VISIBLE, true );
- mOffLabel.SetProperty( Actor::Property::VISIBLE, false );
- }
- else
- {
- stage.Add( mImageView );
-
- UnparentAndReset( mGaussianBlurView );
-
- mOnLabel.SetProperty( Actor::Property::VISIBLE, false );
- mOffLabel.SetProperty( Actor::Property::VISIBLE, true );
- }
+ mOnLabel.SetProperty( Actor::Property::VISIBLE, true );
+ mOffLabel.SetProperty( Actor::Property::VISIBLE, false );
+ }
+ else
+ {
+ mActivate = false;
+ mGaussianBlurView.Deactivate();
+ mOnLabel.SetProperty( Actor::Property::VISIBLE, false );
+ mOffLabel.SetProperty( Actor::Property::VISIBLE, true );
}
+ }
return true;
}
float mExcessWidth;
float mStrength;
+
+ bool mActivate;
};
int DALI_EXPORT_API main( int argc, char **argv )