From: Seungho, Baek Date: Mon, 16 Mar 2020 07:50:07 +0000 (+0900) Subject: Modify gaussian-blur-view example X-Git-Tag: dali_1.9.19~1^2 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-demo.git;a=commitdiff_plain;h=600298efc4cf2a684b92767700793f4807261525 Modify gaussian-blur-view example - Made not create new gaussian blur for every activation. Change-Id: I8d5377d804760286188212923e95fb4737bae274 Signed-off-by: Seungho, Baek --- diff --git a/examples/gaussian-blur-view/gaussian-blur-view-example.cpp b/examples/gaussian-blur-view/gaussian-blur-view-example.cpp index 87adb08..f0cc5a9 100644 --- a/examples/gaussian-blur-view/gaussian-blur-view-example.cpp +++ b/examples/gaussian-blur-view/gaussian-blur-view-example.cpp @@ -1,5 +1,5 @@ /* - * 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. @@ -42,7 +42,8 @@ public: GaussianBlurViewExample( Application& application ) : mApplication( application ), mExcessWidth( 0.0f ), - mStrength( 1.0f ) + mStrength( 1.0f ), + mActivate( false ) { mApplication.InitSignal().Connect( this, &GaussianBlurViewExample::Create ); } @@ -61,8 +62,6 @@ private: 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 ) @@ -102,46 +101,41 @@ private: 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; } @@ -172,6 +166,8 @@ private: float mExcessWidth; float mStrength; + + bool mActivate; }; int DALI_EXPORT_API main( int argc, char **argv )