From: Adeel Kazmi Date: Thu, 5 Feb 2015 16:26:54 +0000 (-0800) Subject: Revert "BloomView & GaussianBlurView demo (for verification purpose only )" X-Git-Tag: submit/tizen/20150206.044231 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=179c5cd29acc6f5e94720b91fa11d0ebc43cb587;p=platform%2Fcore%2Fuifw%2Fdali-demo.git Revert "BloomView & GaussianBlurView demo (for verification purpose only )" This reverts commit 2e81ed4392078f0fe7497bb62e7151c84d54f707. Change-Id: Iaec9f80b51fbfd44e29950f798b5e90b3d1d5aee --- diff --git a/build/tizen/examples/Makefile.am b/build/tizen/examples/Makefile.am index a207c14..bb61a9c 100644 --- a/build/tizen/examples/Makefile.am +++ b/build/tizen/examples/Makefile.am @@ -37,9 +37,8 @@ bin_PROGRAMS = \ image-scaling-irregular-grid.example \ buttons.example \ text-view.example \ - logging.example \ - bloom-view.example \ - gaussian-blur-view.example + logging.example + daliimagedir = $(appdatadir)/images/ dalimodeldir = $(appdatadir)/models/ @@ -177,13 +176,3 @@ logging_example_SOURCES = $(examples_src_dir)/logging/logging-example.cpp logging_example_CXXFLAGS = $(EXAMPLE_CXXFLAGS) logging_example_DEPENDENCIES = $(EXAMPLE_DEPS) logging_example_LDADD = $(EXAMPLE_LDADD) - -bloom_view_example_SOURCES = $(examples_src_dir)/bloom-view/bloom-view-example.cpp -bloom_view_example_CXXFLAGS = $(EXAMPLE_CXXFLAGS) -bloom_view_example_DEPENDENCIES = $(EXAMPLE_DEPS) -bloom_view_example_LDADD = $(EXAMPLE_LDADD) - -gaussian_blur_view_example_SOURCES = $(examples_src_dir)/gaussian-blur-view/gaussian-blur-view-example.cpp -gaussian_blur_view_example_CXXFLAGS = $(EXAMPLE_CXXFLAGS) -gaussian_blur_view_example_DEPENDENCIES = $(EXAMPLE_DEPS) -gaussian_blur_view_example_LDADD = $(EXAMPLE_LDADD) diff --git a/com.samsung.dali-demo.xml b/com.samsung.dali-demo.xml index 00bb88d..14fe3a3 100644 --- a/com.samsung.dali-demo.xml +++ b/com.samsung.dali-demo.xml @@ -76,10 +76,4 @@ - - - - - - diff --git a/demo/images/GreyThinLine30x30-76x78.png b/demo/images/GreyThinLine30x30-76x78.png deleted file mode 100644 index 4ec3364..0000000 Binary files a/demo/images/GreyThinLine30x30-76x78.png and /dev/null differ diff --git a/demo/images/UI-Leather-DIFF.png b/demo/images/UI-Leather-DIFF.png deleted file mode 100644 index b04d0ac..0000000 Binary files a/demo/images/UI-Leather-DIFF.png and /dev/null differ diff --git a/demo/images/desktop_background_1440x2560.png b/demo/images/desktop_background_1440x2560.png deleted file mode 100644 index 738703d..0000000 Binary files a/demo/images/desktop_background_1440x2560.png and /dev/null differ diff --git a/examples/bloom-view/bloom-view-example.cpp b/examples/bloom-view/bloom-view-example.cpp deleted file mode 100644 index d47347e..0000000 --- a/examples/bloom-view/bloom-view-example.cpp +++ /dev/null @@ -1,526 +0,0 @@ -// -// Copyright (c) 2014 Samsung Electronics Co., Ltd. -// -// Licensed under the Flora License, Version 1.0 (the License); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://floralicense.org/license/ -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an AS IS BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -#include -#include - -using namespace Dali; -using namespace Dali::Toolkit; - -namespace -{ - -//#define ADD_REMOVE_FROM_STAGE_TEST - -const char* BACKGROUND_IMAGE_PATH = DALI_IMAGE_DIR "desktop_background_1440x2560.png"; -const char* UI_DIFFUSE_IMAGE( DALI_IMAGE_DIR "UI-Leather-DIFF.png" ); - -const Rect UI_PIXEL_AREA( 0, 0, 720, 1280 ); - -const Rect PANEL1_PIXEL_AREA( 0, 0, 720, 39 ); -const Rect PANEL2_PIXEL_AREA( 0, 39, 720, 100 ); - -const unsigned int NUM_MOVEMENT_ANIMATIONS = 2; - -// for animating bloom intensity on tap gesture -const float PULSE_BLOOM_INCREASE_ANIM_TIME = 1.175; -const float PULSE_BLOOM_DECREASE_ANIM_TIME = 2.4; -const float PULSE_BLOOM_TOTAL_ANIM_TIME = PULSE_BLOOM_INCREASE_ANIM_TIME + PULSE_BLOOM_DECREASE_ANIM_TIME; -const float PULSE_BLOOM_INTENSITY_DEFAULT = 1.0f; -const float PULSE_BLOOM_INTENSITY_INCREASE = 3.0f; - - - -// buttons -const char* BUTTON_BACKGROUND_IMAGE_PATH = DALI_IMAGE_DIR "GreyThinLine30x30-76x78.png"; - -// These values depend on the button background image -const Vector4 BUTTON_IMAGE_BORDER(16.0f, 16.0f, 16.0f, 20.0f); - - -const float UI_MARGIN = 4.0f; ///< Screen Margin for placement of UI buttons -const Vector3 BUTTON_SIZE_CONSTRAINT( 0.24f, 0.09f, 1.0f ); -const char * BUTTON_QUIT = "Quit"; - -} // namespace - - - -/** - * This example demonstrates a bloom effect. - */ -class TestApp : public ConnectionTracker -{ -public: - - TestApp( Application &application ) - : mApplication(application) - , mCurrentAnimation(0) - { - application.InitSignal().Connect(this, &TestApp::Create); - } - - ~TestApp() - { - } - -public: - - void Create(Application& application) - { - // Preload images - mDiffuseImage = Image::New( UI_DIFFUSE_IMAGE ); - - // Creation is deferred until images have loaded - mDiffuseImage.LoadingFinishedSignal().Connect( this, &TestApp::Create2 ); - } - -#ifdef ADD_REMOVE_FROM_STAGE_TEST - void Create2(Image loadedImage) - { - Stage stage = Stage::GetCurrent(); - Vector2 stageSize = stage.GetSize(); - - mStageRootActor = Actor::New(); - mStageRootActor.SetParentOrigin(ParentOrigin::CENTER); - mStageRootActor.SetSize(stageSize); - stage.Add(mStageRootActor); - - // Create the object that will perform the blooming work - mBloomView = Dali::Toolkit::BloomView::New(); - mBloomView.SetParentOrigin(ParentOrigin::CENTER); - mBloomView.SetSize(stageSize * 0.75f); - mStageRootActor.Add(mBloomView); - mBloomView.Activate(); - - // Create the background image - Image background = Image::New(BACKGROUND_IMAGE_PATH); - ImageActor backgroundImage = ImageActor::New(background); - backgroundImage.SetParentOrigin(ParentOrigin::CENTER); - backgroundImage.ApplyConstraint( Constraint::New( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) ); - - Layer backgroundLayer = Layer::New(); - backgroundLayer.ApplyConstraint( Constraint::New( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) ); - backgroundLayer.SetParentOrigin( ParentOrigin::CENTER ); - mBloomView.Add( backgroundLayer ); - backgroundLayer.Add( backgroundImage ); - - Layer foregroundLayer = Layer::New(); - foregroundLayer.ApplyConstraint( Constraint::New( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) ); - foregroundLayer.SetParentOrigin( ParentOrigin::CENTER ); - mBloomView.Add( foregroundLayer ); - - // Create visible actors - mObjectRootActor = Actor::New(); - mObjectRootActor.SetParentOrigin( ParentOrigin::CENTER ); - mObjectRootActor.ApplyConstraint( Constraint::New( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) ); - foregroundLayer.Add( mObjectRootActor ); - - ImageActor imageActor = ImageActor::New( mDiffuseImage ); - imageActor.SetParentOrigin( ParentOrigin::CENTER ); - imageActor.SetSize( stageSize * 0.75f); - mObjectRootActor.Add( imageActor ); - - imageActor = ImageActor::New( mDiffuseImage ); - imageActor.SetParentOrigin( ParentOrigin::CENTER ); - imageActor.SetSize( stageSize * 0.5f ); - imageActor.SetPosition(0.0f, 0.0f, 100.0f); - mObjectRootActor.Add( imageActor ); - - AnimateBloomView(); - PulseBloomIntensity(); - - // Gesture detection - mTapGestureDetector = TapGestureDetector::New(); - mTapGestureDetector.Attach( mStageRootActor ); - mTapGestureDetector.DetectedSignal().Connect( this, &TestApp::OnTap ); - } - - void AnimateBloomView() - { - if(mRotationAnimation) - { - mRotationAnimation.Stop(); - } - if(mResizeAnimation) - { - mResizeAnimation.Stop(); - } - if(mTranslationAnimation) - { - mTranslationAnimation.Stop(); - } - if(mBlurAnimation) - { - mBlurAnimation.Stop(); - } - - // ROTATE - float animDuration = 10.0f; - mRotationAnimation = Animation::New(animDuration); - mRotationAnimation.RotateBy(mBloomView, Degree(720), Vector3::YAXIS, AlphaFunctions::EaseInOut); - mRotationAnimation.SetEndAction( Animation::Discard ); - mRotationAnimation.SetLooping( true ); - mRotationAnimation.Play(); - - // BLUR - mBlurAnimation = Animation::New( 4.0f ); - mBlurAnimation.AnimateTo( Property( mBloomView, mBloomView.GetBlurStrengthPropertyIndex() ), 0.0f, AlphaFunctions::Linear, TimePeriod(0.0f, 0.5f) ); - mBlurAnimation.AnimateTo( Property( mBloomView, mBloomView.GetBlurStrengthPropertyIndex() ), 1.0f, AlphaFunctions::Linear, TimePeriod(2.0f, 0.5f) ); - mBlurAnimation.SetEndAction( Animation::Discard ); - mBlurAnimation.SetLooping( true ); - mBlurAnimation.Play(); - } -#else //#ifdef ADD_REMOVE_FROM_STAGE_TEST - - void Create2(Image loadedImage) - { - Stage stage = Stage::GetCurrent(); - Vector2 stageSize = stage.GetSize(); - - mStageRootActor = Actor::New(); - mStageRootActor.SetParentOrigin(ParentOrigin::CENTER); - mStageRootActor.SetSize(stageSize); - stage.Add(mStageRootActor); - - // Create the object that will perform the blooming work - mBloomView = Dali::Toolkit::BloomView::New(); - mBloomView.SetParentOrigin(ParentOrigin::CENTER); - mBloomView.SetSize(stageSize * 0.75f); - mStageRootActor.Add(mBloomView); - mBloomView.Activate(); - - // Create the Quit button - PushButton button; - button = CreateButton(BUTTON_QUIT, BUTTON_QUIT, BUTTON_SIZE_CONSTRAINT); - button.SetAnchorPoint(AnchorPoint::BOTTOM_RIGHT); - button.SetParentOrigin(ParentOrigin::BOTTOM_RIGHT); - button.SetPosition(-UI_MARGIN, -UI_MARGIN); - - // Create the background image - Image background = Image::New(BACKGROUND_IMAGE_PATH); - ImageActor backgroundImage = ImageActor::New(background); - backgroundImage.SetParentOrigin(ParentOrigin::CENTER); - backgroundImage.ApplyConstraint( Constraint::New( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) ); - - Layer backgroundLayer = Layer::New(); - backgroundLayer.ApplyConstraint( Constraint::New( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) ); - backgroundLayer.SetParentOrigin( ParentOrigin::CENTER ); - mBloomView.Add( backgroundLayer ); - backgroundLayer.Add( backgroundImage ); - - Layer foregroundLayer = Layer::New(); - foregroundLayer.ApplyConstraint( Constraint::New( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) ); - foregroundLayer.SetParentOrigin( ParentOrigin::CENTER ); - mBloomView.Add( foregroundLayer ); - - // Create visible actors - mObjectRootActor = Actor::New(); - mObjectRootActor.SetParentOrigin( ParentOrigin::CENTER ); - mObjectRootActor.ApplyConstraint( Constraint::New( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) ); - foregroundLayer.Add( mObjectRootActor ); - - ImageActor imageActor = ImageActor::New( mDiffuseImage ); - imageActor.SetParentOrigin( ParentOrigin::CENTER ); - imageActor.SetSize( stageSize * 0.75f); - mObjectRootActor.Add( imageActor ); - - imageActor = ImageActor::New( mDiffuseImage ); - imageActor.SetParentOrigin( ParentOrigin::CENTER ); - imageActor.SetSize( stageSize * 0.5f ); - imageActor.SetPosition(0.0f, 0.0f, 100.0f); - mObjectRootActor.Add( imageActor ); - - ToggleAnimation(); - PulseBloomIntensity(); - - // Gesture detection - mTapGestureDetector = TapGestureDetector::New(); - mTapGestureDetector.Attach( mStageRootActor ); - mTapGestureDetector.DetectedSignal().Connect( this, &TestApp::OnTap ); - } - - PushButton CreateButton(const std::string& name, const std::string& label, const Vector3& sizeConstraint) - { - // Create the button - Image img = Image::New(BUTTON_BACKGROUND_IMAGE_PATH); - ImageActor background = ImageActor::New(img); - - background.SetStyle(ImageActor::STYLE_NINE_PATCH); - background.SetNinePatchBorder(BUTTON_IMAGE_BORDER); - - PushButton button = PushButton::New(); - button.SetName(name); - button.SetBackgroundImage(background); - - // Set the button's size - button.ApplyConstraint( Constraint::New( Actor::SIZE, ParentSource( Actor::SIZE ), RelativeToConstraint( sizeConstraint ) ) ); - - // Make sure the button only takes up its natural or allocated width. - button.SetSizePolicy( Toolkit::Control::Fixed, Toolkit::Control::Fixed ); - - mStageRootActor.Add(button); - - button.ClickedSignal().Connect(this, &TestApp::OnButtonTouchEvent); - - SetButtonLabel(button, label, TextView::Center); - - return button; - } - - void SetButtonLabel(PushButton button, const std::string& label, const TextView::LineJustification justification) - { - Font font = Font::New(); - Vector3 textSize = font.MeasureText(label); - - // Add a text label to the button - TextView textView = TextView::New( label ); - textView.SetAnchorPoint( AnchorPoint::CENTER ); - textView.SetParentOrigin( ParentOrigin::CENTER ); - textView.SetMultilinePolicy(TextView::SplitByWord); - textView.SetWidthExceedPolicy(TextView::Original); - textView.SetTextAlignment(static_cast< Alignment::Type >( Alignment::HorizontalCenter | Alignment::VerticalCenter )); - textView.SetLineJustification(justification); - textView.SetSize(textSize); - - Alignment align = Alignment::New(); - align.Add(textView); - align.SetScaling( Alignment::ShrinkToFitKeepAspect ); - - button.SetLabelText(align); - } - - /** - * Signal handler, called when the button is pressed - */ - bool OnButtonTouchEvent(Button button) - { - if(button.GetName() == BUTTON_QUIT) - { - // quit the application - mApplication.Quit(); - } - - return true; - } - - void AnimateBloomView() - { - if(mRotationAnimation) - { - mRotationAnimation.Stop(); - } - if(mResizeAnimation) - { - mResizeAnimation.Stop(); - } - if(mTranslationAnimation) - { - mTranslationAnimation.Stop(); - } - if(mBlurAnimation) - { - mBlurAnimation.Stop(); - } - - // ROTATE - float animDuration = 10.0f; - mRotationAnimation = Animation::New(animDuration); - mRotationAnimation.RotateBy(mBloomView, Degree(720), Vector3::YAXIS, AlphaFunctions::EaseInOut); - mRotationAnimation.SetEndAction( Animation::Discard ); - mRotationAnimation.SetLooping( true ); - mRotationAnimation.Play(); - - - // RESIZE - Stage stage = Stage::GetCurrent(); - Vector3 stageSize(stage.GetSize().width, stage.GetSize().height, 1.0f); - mResizeAnimation = Animation::New( 7.5f ); - mResizeAnimation.AnimateTo( Property(mBloomView, Actor::SIZE), stageSize * Vector3(0.5f, 0.5f, 1.0f), AlphaFunctions::Bounce, TimePeriod(2.5f) ); - mResizeAnimation.SetEndAction( Animation::Discard ); - mResizeAnimation.SetLooping( true ); - mResizeAnimation.Play(); - - - // TRANSLATE - mTranslationAnimation = Animation::New( 7.5f ); - mTranslationAnimation.AnimateBy( Property(mObjectRootActor, Actor::POSITION), Vector3(100.0f, 0.0f, 0.0f), AlphaFunctions::Bounce, TimePeriod(2.5f) ); - mTranslationAnimation.AnimateBy( Property(mObjectRootActor, Actor::POSITION), Vector3(300.0f, 0.0f, 0.0f), AlphaFunctions::Bounce, TimePeriod(2.5f, 2.5f) ); - mTranslationAnimation.AnimateBy( Property(mObjectRootActor, Actor::POSITION), Vector3(0.0f, 0.0f, 0.0f), AlphaFunctions::Bounce, TimePeriod(5.0f, 2.5f) ); - mTranslationAnimation.SetEndAction( Animation::Discard ); - mTranslationAnimation.SetLooping( true ); - mTranslationAnimation.Play(); - - - // BLUR - mBlurAnimation = Animation::New( 4.0f ); - mBlurAnimation.AnimateTo( Property( mBloomView, mBloomView.GetBlurStrengthPropertyIndex() ), 0.0f, AlphaFunctions::Linear, TimePeriod(0.0f, 0.5f) ); - mBlurAnimation.AnimateTo( Property( mBloomView, mBloomView.GetBlurStrengthPropertyIndex() ), 1.0f, AlphaFunctions::Linear, TimePeriod(2.0f, 0.5f) ); - mBlurAnimation.SetEndAction( Animation::Discard ); - mBlurAnimation.SetLooping( true ); - mBlurAnimation.Play(); - } - - void AnimateActorRoot() - { - if(mRotationAnimation) - { - mRotationAnimation.Stop(); - } - if(mResizeAnimation) - { - mResizeAnimation.Stop(); - } - if(mTranslationAnimation) - { - mTranslationAnimation.Stop(); - } - if(mBlurAnimation) - { - mBlurAnimation.Stop(); - } - - // ROTATE - float animDuration = 10.0f; - mRotationAnimation = Animation::New(animDuration); - mRotationAnimation.RotateBy(mObjectRootActor, Degree(720), Vector3::YAXIS, AlphaFunctions::EaseInOut); - mRotationAnimation.SetEndAction( Animation::Discard ); - mRotationAnimation.SetLooping( true ); - mRotationAnimation.Play(); - - - // RESIZE - Stage stage = Stage::GetCurrent(); - Vector3 stageSize(stage.GetSize().width, stage.GetSize().height, 1.0f); - mResizeAnimation = Animation::New( 7.5f ); - mResizeAnimation.AnimateTo( Property(mBloomView, Actor::SIZE), stageSize * Vector3(0.5f, 0.5f, 1.0f), AlphaFunctions::Bounce, TimePeriod(2.5f) ); - mResizeAnimation.SetEndAction( Animation::Discard ); - mResizeAnimation.SetLooping( true ); - mResizeAnimation.Play(); - - - // TRANSLATE - mTranslationAnimation = Animation::New( 7.5f ); - mTranslationAnimation.AnimateBy( Property(mObjectRootActor, Actor::POSITION), Vector3(100.0f, 0.0f, 0.0f), AlphaFunctions::Bounce, TimePeriod(2.5f) ); - mTranslationAnimation.AnimateBy( Property(mObjectRootActor, Actor::POSITION), Vector3(300.0f, 0.0f, 0.0f), AlphaFunctions::Bounce, TimePeriod(2.5f, 2.5f) ); - mTranslationAnimation.AnimateBy( Property(mObjectRootActor, Actor::POSITION), Vector3(0.0f, 0.0f, 0.0f), AlphaFunctions::Bounce, TimePeriod(5.0f, 2.5f) ); - mTranslationAnimation.SetEndAction( Animation::Discard ); - mTranslationAnimation.SetLooping( true ); - mTranslationAnimation.Play(); - - - // BLUR - mBlurAnimation = Animation::New( 4.0f ); - mBlurAnimation.AnimateTo( Property( mBloomView, mBloomView.GetBlurStrengthPropertyIndex() ), 0.0f, AlphaFunctions::Linear, TimePeriod(0.0f, 0.5f) ); - mBlurAnimation.AnimateTo( Property( mBloomView, mBloomView.GetBlurStrengthPropertyIndex() ), 1.0f, AlphaFunctions::Linear, TimePeriod(2.0f, 0.5f) ); - mBlurAnimation.SetEndAction( Animation::Discard ); - mBlurAnimation.SetLooping( true ); - mBlurAnimation.Play(); - } - - void ToggleAnimation() - { - mCurrentAnimation++; - if(mCurrentAnimation == NUM_MOVEMENT_ANIMATIONS) - { - mCurrentAnimation = 0; - } - - switch(mCurrentAnimation) - { - case 0: - AnimateActorRoot(); - break; - - case 1: - AnimateBloomView(); - break; - } - } -#endif //#ifdef ADD_REMOVE_FROM_STAGE_TEST - - void PulseBloomIntensity() - { - mPulseBloomIntensityAnim = Animation::New( 2.5f ); - mPulseBloomIntensityAnim.AnimateTo( Property(mBloomView, mBloomView.GetBloomIntensityPropertyIndex()), 3.0f, AlphaFunctions::Bounce, TimePeriod(2.5f) ); - mPulseBloomIntensityAnim.SetEndAction( Animation::Discard ); - mPulseBloomIntensityAnim.SetLooping( true ); - mPulseBloomIntensityAnim.Play(); - } - - void OnTap( Actor actor, const TapGesture& tapGesture ) - { - Stage stage = Stage::GetCurrent(); - -#ifdef ADD_REMOVE_FROM_STAGE_TEST - if(mBloomView.OnStage()) - { - mStageRootActor.Remove(mBloomView); - mBloomView.Deactivate(); - } - else - { - mStageRootActor.Add(mBloomView); - mBloomView.Activate(); - } -#else //#ifdef ADD_REMOVE_FROM_STAGE_TEST - ToggleAnimation(); -#endif //#ifdef ADD_REMOVE_FROM_STAGE_TEST - } - -private: - - Application& mApplication; - - TapGestureDetector mTapGestureDetector; - - Actor mStageRootActor; - - Actor mObjectRootActor; - Image mDiffuseImage; - - unsigned int mCurrentAnimation; - Animation mRotationAnimation; - Animation mResizeAnimation; - Animation mTranslationAnimation; - Animation mBlurAnimation; - Animation mPulseBloomIntensityAnim; - - // for rendering the blur / bloom - GaussianBlurView mGaussianBlurView; - BloomView mBloomView; -}; - -/*****************************************************************************/ - -static void -RunTest( Application& application ) -{ - TestApp theApp(application); - application.MainLoop(); -} - -/*****************************************************************************/ - -int -main(int argc, char **argv) -{ - Application application = Application::New(&argc, &argv); - - RunTest(application); - - return 0; -} diff --git a/examples/gaussian-blur-view/gaussian-blur-view-example.cpp b/examples/gaussian-blur-view/gaussian-blur-view-example.cpp deleted file mode 100644 index 7fce8a6..0000000 --- a/examples/gaussian-blur-view/gaussian-blur-view-example.cpp +++ /dev/null @@ -1,521 +0,0 @@ -// -// Copyright (c) 2014 Samsung Electronics Co., Ltd. -// -// Licensed under the Flora License, Version 1.0 (the License); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://floralicense.org/license/ -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an AS IS BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -#include -#include - -using namespace Dali; -using namespace Dali::Toolkit; - -namespace -{ - -//#define ADD_REMOVE_FROM_STAGE_TEST - -const char* BACKGROUND_IMAGE_PATH = DALI_IMAGE_DIR "desktop_background_1440x2560.png"; -const char* UI_DIFFUSE_IMAGE( DALI_IMAGE_DIR "UI-Leather-DIFF.png" ); - -const Rect UI_PIXEL_AREA( 0, 0, 720, 1280 ); - -const Rect PANEL1_PIXEL_AREA( 0, 0, 720, 39 ); -const Rect PANEL2_PIXEL_AREA( 0, 39, 720, 100 ); - -const unsigned int NUM_MOVEMENT_ANIMATIONS = 2; - -// for animating bloom intensity on tap gesture -const float PULSE_BLOOM_INCREASE_ANIM_TIME = 1.175; -const float PULSE_BLOOM_DECREASE_ANIM_TIME = 2.4; -const float PULSE_BLOOM_TOTAL_ANIM_TIME = PULSE_BLOOM_INCREASE_ANIM_TIME + PULSE_BLOOM_DECREASE_ANIM_TIME; -const float PULSE_BLOOM_INTENSITY_DEFAULT = 1.0f; -const float PULSE_BLOOM_INTENSITY_INCREASE = 3.0f; - - -// buttons -const char* BUTTON_BACKGROUND_IMAGE_PATH = DALI_IMAGE_DIR "GreyThinLine30x30-76x78.png"; - -// These values depend on the button background image -const float BUTTON_IMAGE_BORDER_LEFT = 16.0f; -const float BUTTON_IMAGE_BORDER_RIGHT = 16.0f; -const float BUTTON_IMAGE_BORDER_TOP = 13.0f; -const float BUTTON_IMAGE_BORDER_BOTTOM = 20.0f; - -const Vector4 BUTTON_IMAGE_BORDER( BUTTON_IMAGE_BORDER_LEFT, BUTTON_IMAGE_BORDER_TOP, BUTTON_IMAGE_BORDER_RIGHT, BUTTON_IMAGE_BORDER_BOTTOM ); - -const float UI_MARGIN = 4.0f; ///< Screen Margin for placement of UI buttons -const Vector3 BUTTON_SIZE_CONSTRAINT( 0.24f, 0.09f, 1.0f ); -const char * BUTTON_QUIT = "Quit"; -const char * BUTTON_QUIT_LABEL ="Quit"; - -} // namespace - - - -/** - * This example demonstrates a blur effect. - */ -class TestApp : public ConnectionTracker -{ -public: - - TestApp( Application &application ) - : mApplication(application) - , mCurrentAnimation(0) - { - application.InitSignal().Connect(this, &TestApp::Create); - application.TerminateSignal().Connect(this, &TestApp::Terminate); - } - - ~TestApp() - { - } - -public: - - void Create(Application& application) - { - // Preload images - mDiffuseImage = Image::New( UI_DIFFUSE_IMAGE ); - - // Creation is deferred until images have loaded - mDiffuseImage.LoadingFinishedSignal().Connect( this, &TestApp::Create2 ); - } - -#ifdef ADD_REMOVE_FROM_STAGE_TEST - void Create2(Image loadedImage) - { - Stage stage = Stage::GetCurrent(); - Vector2 stageSize = stage.GetSize(); - - mStageRootActor = Actor::New(); - mStageRootActor.SetParentOrigin(ParentOrigin::CENTER); - mStageRootActor.SetSize(stageSize); - stage.Add(mStageRootActor); - - // Create the object that will perform the blurring work - mGaussianBlurView = Dali::Toolkit::GaussianBlurView::New(); - mGaussianBlurView.SetParentOrigin(ParentOrigin::CENTER); - mGaussianBlurView.SetSize(stageSize * 0.75f); - mStageRootActor.Add(mGaussianBlurView); - mGaussianBlurView.Activate(); - - // Create the background image - Image background = Image::New(BACKGROUND_IMAGE_PATH); - ImageActor backgroundImage = ImageActor::New(background); - backgroundImage.SetParentOrigin(ParentOrigin::CENTER); - backgroundImage.ApplyConstraint( Constraint::New( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) ); - - Layer backgroundLayer = Layer::New(); - backgroundLayer.ApplyConstraint( Constraint::New( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) ); - backgroundLayer.SetParentOrigin( ParentOrigin::CENTER ); - mGaussianBlurView.Add( backgroundLayer ); - backgroundLayer.Add( backgroundImage ); - - Layer foregroundLayer = Layer::New(); - foregroundLayer.ApplyConstraint( Constraint::New( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) ); - foregroundLayer.SetParentOrigin( ParentOrigin::CENTER ); - mGaussianBlurView.Add( foregroundLayer ); - - // Create visible actors - mObjectRootActor = Actor::New(); - mObjectRootActor.SetParentOrigin( ParentOrigin::CENTER ); - mObjectRootActor.ApplyConstraint( Constraint::New( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) ); - foregroundLayer.Add( mObjectRootActor ); - - ImageActor imageActor = ImageActor::New( mDiffuseImage ); - imageActor.SetParentOrigin( ParentOrigin::CENTER ); - imageActor.SetSize( stageSize * 0.75f); - mObjectRootActor.Add( imageActor ); - - imageActor = ImageActor::New( mDiffuseImage ); - imageActor.SetParentOrigin( ParentOrigin::CENTER ); - imageActor.SetSize( stageSize * 0.5f ); - imageActor.SetPosition(0.0f, 0.0f, 100.0f); - mObjectRootActor.Add( imageActor ); - - AnimateGaussianBlurView(); - - // Gesture detection - mTapGestureDetector = TapGestureDetector::New(); - mTapGestureDetector.Attach( mStageRootActor ); - mTapGestureDetector.DetectedSignal().Connect( this, &TestApp::OnTap ); - } - - void AnimateGaussianBlurView() - { - if(mRotationAnimation) - { - mRotationAnimation.Stop(); - } - if(mResizeAnimation) - { - mResizeAnimation.Stop(); - } - if(mTranslationAnimation) - { - mTranslationAnimation.Stop(); - } - if(mBlurAnimation) - { - mBlurAnimation.Stop(); - } - - // ROTATE - float animDuration = 10.0f; - mRotationAnimation = Animation::New(animDuration); - mRotationAnimation.RotateBy(mGaussianBlurView, Degree(720), Vector3::YAXIS, AlphaFunctions::EaseInOut); - mRotationAnimation.SetEndAction( Animation::Discard ); - mRotationAnimation.SetLooping( true ); - mRotationAnimation.Play(); - - // BLUR - mBlurAnimation = Animation::New( 4.0f ); - mBlurAnimation.AnimateTo( Property( mGaussianBlurView, mGaussianBlurView.GetBlurStrengthPropertyIndex() ), 0.0f, AlphaFunctions::Linear, TimePeriod(0.0f, 0.5f) ); - mBlurAnimation.AnimateTo( Property( mGaussianBlurView, mGaussianBlurView.GetBlurStrengthPropertyIndex() ), 1.0f, AlphaFunctions::Linear, TimePeriod(2.0f, 0.5f) ); - mBlurAnimation.SetEndAction( Animation::Discard ); - mBlurAnimation.SetLooping( true ); - mBlurAnimation.Play(); - } -#else //#ifdef ADD_REMOVE_FROM_STAGE_TEST - - void Create2(Image loadedImage) - { - Stage stage = Stage::GetCurrent(); - Vector2 stageSize = stage.GetSize(); - - mStageRootActor = Actor::New(); - mStageRootActor.SetParentOrigin(ParentOrigin::CENTER); - mStageRootActor.SetSize(stageSize); - stage.Add(mStageRootActor); - - // Create the object that will perform the blurring work - mGaussianBlurView = Dali::Toolkit::GaussianBlurView::New(); - mGaussianBlurView.SetParentOrigin(ParentOrigin::CENTER); - mGaussianBlurView.SetSize(stageSize * 0.75f); - mStageRootActor.Add(mGaussianBlurView); - mGaussianBlurView.Activate(); - - // Create the Quit button - PushButton button; - button = CreateButton(BUTTON_QUIT, BUTTON_QUIT_LABEL, BUTTON_SIZE_CONSTRAINT); - button.SetAnchorPoint(AnchorPoint::BOTTOM_RIGHT); - button.SetParentOrigin(ParentOrigin::BOTTOM_RIGHT); - button.SetPosition(-UI_MARGIN, -UI_MARGIN); - - // Create the background image - Image background = Image::New(BACKGROUND_IMAGE_PATH); - ImageActor backgroundImage = ImageActor::New(background); - backgroundImage.SetParentOrigin(ParentOrigin::CENTER); - backgroundImage.ApplyConstraint( Constraint::New( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) ); - - Layer backgroundLayer = Layer::New(); - backgroundLayer.ApplyConstraint( Constraint::New( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) ); - backgroundLayer.SetParentOrigin( ParentOrigin::CENTER ); - mGaussianBlurView.Add( backgroundLayer ); - backgroundLayer.Add( backgroundImage ); - - Layer foregroundLayer = Layer::New(); - foregroundLayer.ApplyConstraint( Constraint::New( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) ); - foregroundLayer.SetParentOrigin( ParentOrigin::CENTER ); - mGaussianBlurView.Add( foregroundLayer ); - - // Create visible actors - mObjectRootActor = Actor::New(); - mObjectRootActor.SetParentOrigin( ParentOrigin::CENTER ); - mObjectRootActor.ApplyConstraint( Constraint::New( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) ); - foregroundLayer.Add( mObjectRootActor ); - - ImageActor imageActor = ImageActor::New( mDiffuseImage ); - imageActor.SetParentOrigin( ParentOrigin::CENTER ); - imageActor.SetSize( stageSize * 0.75f); - mObjectRootActor.Add( imageActor ); - - imageActor = ImageActor::New( mDiffuseImage ); - imageActor.SetParentOrigin( ParentOrigin::CENTER ); - imageActor.SetSize( stageSize * 0.5f ); - imageActor.SetPosition(0.0f, 0.0f, 100.0f); - mObjectRootActor.Add( imageActor ); - - ToggleAnimation(); - - // Gesture detection - mTapGestureDetector = TapGestureDetector::New(); - mTapGestureDetector.Attach( mStageRootActor ); - mTapGestureDetector.DetectedSignal().Connect( this, &TestApp::OnTap ); - } - - PushButton CreateButton(const std::string& name, const std::string& label, const Vector3& sizeConstraint) - { - // Create the button - Image img = Image::New(BUTTON_BACKGROUND_IMAGE_PATH); - ImageActor background = ImageActor::New(img); - - background.SetStyle(ImageActor::STYLE_NINE_PATCH); - background.SetNinePatchBorder(BUTTON_IMAGE_BORDER); - - PushButton button = PushButton::New(); - button.SetName(name); - button.SetBackgroundImage(background); - - // Set the button's size - button.ApplyConstraint( Constraint::New( Actor::SIZE, ParentSource( Actor::SIZE ), RelativeToConstraint( sizeConstraint ) ) ); - - mStageRootActor.Add(button); - - button.ClickedSignal().Connect(this, &TestApp::OnButtonTouchEvent); - - SetButtonLabel(button, label, TextView::Center); - - return button; - } - - void SetButtonLabel(PushButton button, const std::string& label, const TextView::LineJustification justification) - { - Font font = Font::New(); - Vector3 textSize = font.MeasureText(label); - - // Add a text label to the button - TextView textView = TextView::New( label ); - textView.SetAnchorPoint( AnchorPoint::CENTER ); - textView.SetParentOrigin( ParentOrigin::CENTER ); - textView.SetMultilinePolicy(TextView::SplitByWord); - textView.SetWidthExceedPolicy(TextView::Original); - textView.SetTextAlignment(static_cast< Alignment::Type >( Alignment::HorizontalCenter | Alignment::VerticalCenter )); - textView.SetLineJustification(justification); - textView.SetSize(textSize); - - Alignment align = Alignment::New(); - align.Add(textView); - align.SetScaling( Alignment::ShrinkToFitKeepAspect ); - - button.SetLabelText(align); - } - - /** - * Signal handler, called when the button is pressed - */ - bool OnButtonTouchEvent(Button button) - { - if(button.GetName() == BUTTON_QUIT) - { - // quit the application - mApplication.Quit(); - } - - return true; - } - - void AnimateGaussianBlurView() - { - if(mRotationAnimation) - { - mRotationAnimation.Stop(); - } - if(mResizeAnimation) - { - mResizeAnimation.Stop(); - } - if(mTranslationAnimation) - { - mTranslationAnimation.Stop(); - } - if(mBlurAnimation) - { - mBlurAnimation.Stop(); - } - - // ROTATE - float animDuration = 10.0f; - mRotationAnimation = Animation::New(animDuration); - mRotationAnimation.RotateBy(mGaussianBlurView, Degree(720), Vector3::YAXIS, AlphaFunctions::EaseInOut); - mRotationAnimation.SetEndAction( Animation::Discard ); - mRotationAnimation.SetLooping( true ); - mRotationAnimation.Play(); - - - // RESIZE - Stage stage = Stage::GetCurrent(); - Vector3 stageSize(stage.GetSize().width, stage.GetSize().height, 1.0f); - mResizeAnimation = Animation::New( 7.5f ); - mResizeAnimation.AnimateTo( Property(mGaussianBlurView, Actor::SIZE), stageSize * Vector3(0.5f, 0.5f, 1.0f), AlphaFunctions::Bounce, TimePeriod(2.5f) ); - mResizeAnimation.SetEndAction( Animation::Discard ); - mResizeAnimation.SetLooping( true ); - mResizeAnimation.Play(); - - - // TRANSLATE - mTranslationAnimation = Animation::New( 7.5f ); - mTranslationAnimation.AnimateBy( Property(mObjectRootActor, Actor::POSITION), Vector3(100.0f, 0.0f, 0.0f), AlphaFunctions::Bounce, TimePeriod(2.5f) ); - mTranslationAnimation.AnimateBy( Property(mObjectRootActor, Actor::POSITION), Vector3(300.0f, 0.0f, 0.0f), AlphaFunctions::Bounce, TimePeriod(2.5f, 2.5f) ); - mTranslationAnimation.AnimateBy( Property(mObjectRootActor, Actor::POSITION), Vector3(0.0f, 0.0f, 0.0f), AlphaFunctions::Bounce, TimePeriod(5.0f, 2.5f) ); - mTranslationAnimation.SetEndAction( Animation::Discard ); - mTranslationAnimation.SetLooping( true ); - mTranslationAnimation.Play(); - - - // BLUR - mBlurAnimation = Animation::New( 4.0f ); - mBlurAnimation.AnimateTo( Property( mGaussianBlurView, mGaussianBlurView.GetBlurStrengthPropertyIndex() ), 0.0f, AlphaFunctions::Linear, TimePeriod(0.0f, 0.5f) ); - mBlurAnimation.AnimateTo( Property( mGaussianBlurView, mGaussianBlurView.GetBlurStrengthPropertyIndex() ), 1.0f, AlphaFunctions::Linear, TimePeriod(2.0f, 0.5f) ); - mBlurAnimation.SetEndAction( Animation::Discard ); - mBlurAnimation.SetLooping( true ); - mBlurAnimation.Play(); - } - - void AnimateActorRoot() - { - if(mRotationAnimation) - { - mRotationAnimation.Stop(); - } - if(mResizeAnimation) - { - mResizeAnimation.Stop(); - } - if(mTranslationAnimation) - { - mTranslationAnimation.Stop(); - } - if(mBlurAnimation) - { - mBlurAnimation.Stop(); - } - - // ROTATE - float animDuration = 10.0f; - mRotationAnimation = Animation::New(animDuration); - mRotationAnimation.RotateBy(mObjectRootActor, Degree(720), Vector3::YAXIS, AlphaFunctions::EaseInOut); - mRotationAnimation.SetEndAction( Animation::Discard ); - mRotationAnimation.SetLooping( true ); - mRotationAnimation.Play(); - - - // RESIZE - Stage stage = Stage::GetCurrent(); - Vector3 stageSize(stage.GetSize().width, stage.GetSize().height, 1.0f); - mResizeAnimation = Animation::New( 7.5f ); - mResizeAnimation.AnimateTo( Property(mGaussianBlurView, Actor::SIZE), stageSize * Vector3(0.5f, 0.5f, 1.0f), AlphaFunctions::Bounce, TimePeriod(2.5f) ); - mResizeAnimation.SetEndAction( Animation::Discard ); - mResizeAnimation.SetLooping( true ); - mResizeAnimation.Play(); - - - // TRANSLATE - mTranslationAnimation = Animation::New( 7.5f ); - mTranslationAnimation.AnimateBy( Property(mObjectRootActor, Actor::POSITION), Vector3(100.0f, 0.0f, 0.0f), AlphaFunctions::Bounce, TimePeriod(2.5f) ); - mTranslationAnimation.AnimateBy( Property(mObjectRootActor, Actor::POSITION), Vector3(300.0f, 0.0f, 0.0f), AlphaFunctions::Bounce, TimePeriod(2.5f, 2.5f) ); - mTranslationAnimation.AnimateBy( Property(mObjectRootActor, Actor::POSITION), Vector3(0.0f, 0.0f, 0.0f), AlphaFunctions::Bounce, TimePeriod(5.0f, 2.5f) ); - mTranslationAnimation.SetEndAction( Animation::Discard ); - mTranslationAnimation.SetLooping( true ); - mTranslationAnimation.Play(); - - - // BLUR - mBlurAnimation = Animation::New( 4.0f ); - mBlurAnimation.AnimateTo( Property( mGaussianBlurView, mGaussianBlurView.GetBlurStrengthPropertyIndex() ), 0.0f, AlphaFunctions::Linear, TimePeriod(0.0f, 0.5f) ); - mBlurAnimation.AnimateTo( Property( mGaussianBlurView, mGaussianBlurView.GetBlurStrengthPropertyIndex() ), 1.0f, AlphaFunctions::Linear, TimePeriod(2.0f, 0.5f) ); - mBlurAnimation.SetEndAction( Animation::Discard ); - mBlurAnimation.SetLooping( true ); - mBlurAnimation.Play(); - } - - void ToggleAnimation() - { - mCurrentAnimation++; - if(mCurrentAnimation == NUM_MOVEMENT_ANIMATIONS) - { - mCurrentAnimation = 0; - } - - switch(mCurrentAnimation) - { - case 0: - AnimateActorRoot(); - break; - - case 1: - AnimateGaussianBlurView(); - break; - } - } -#endif //#ifdef ADD_REMOVE_FROM_STAGE_TEST - - void Terminate( Application& app ) - { - } - - void OnTap( Actor actor, const TapGesture& tapGesture ) - { - Stage stage = Stage::GetCurrent(); - -#ifdef ADD_REMOVE_FROM_STAGE_TEST - if(mGaussianBlurView.OnStage()) - { - mStageRootActor.Remove(mGaussianBlurView); - mGaussianBlurView.Deactivate(); - } - else - { - mStageRootActor.Add(mGaussianBlurView); - mGaussianBlurView.Activate(); - } -#else //#ifdef ADD_REMOVE_FROM_STAGE_TEST - ToggleAnimation(); -#endif //#ifdef ADD_REMOVE_FROM_STAGE_TEST - } - -private: - - Application& mApplication; - - TapGestureDetector mTapGestureDetector; - - Actor mStageRootActor; - - Actor mObjectRootActor; - Image mDiffuseImage; - - unsigned int mCurrentAnimation; - Animation mRotationAnimation; - Animation mResizeAnimation; - Animation mTranslationAnimation; - Animation mBlurAnimation; - Animation mPulseBloomIntensityAnim; - - // for rendering the blur / bloom - GaussianBlurView mGaussianBlurView; - BloomView mBloomView; -}; - -/*****************************************************************************/ - -static void -RunTest( Application& application ) -{ - TestApp theApp(application); - application.MainLoop(); -} - -/*****************************************************************************/ - -int -main(int argc, char **argv) -{ - Application application = Application::New(&argc, &argv); - - RunTest(application); - - return 0; -} diff --git a/examples/magnifier/magnifier-example.cpp b/examples/magnifier/magnifier-example.cpp index d916511..4302665 100644 --- a/examples/magnifier/magnifier-example.cpp +++ b/examples/magnifier/magnifier-example.cpp @@ -236,7 +236,7 @@ public: mMagnifier.SetSourceActor( mView.GetBackgroundLayer() ); mMagnifier.SetSize( MAGNIFIER_SIZE * mStageSize.width ); // Size of magnifier is in relation to stage width mMagnifier.SetMagnificationFactor( MAGNIFICATION_FACTOR ); - mMagnifier.SetFrameVisibility(true); + mMagnifier.SetFrameVisibility(false); mMagnifier.SetScale(Vector3::ZERO); overlay.Add( mMagnifier );