Commit 4e3f98748dabc601cb28031741e1b21dea0446de
1 parent
02e51d1a
Revert "BloomView & GaussianBlurView demo (for verification purpose only )"
This reverts commit 2e81ed4392078f0fe7497bb62e7151c84d54f707. Change-Id: Iaec9f80b51fbfd44e29950f798b5e90b3d1d5aee
Showing
8 changed files
with
3 additions
and
1067 deletions
build/tizen/examples/Makefile.am
| @@ -37,9 +37,8 @@ bin_PROGRAMS = \ | @@ -37,9 +37,8 @@ bin_PROGRAMS = \ | ||
| 37 | image-scaling-irregular-grid.example \ | 37 | image-scaling-irregular-grid.example \ |
| 38 | buttons.example \ | 38 | buttons.example \ |
| 39 | text-view.example \ | 39 | text-view.example \ |
| 40 | - logging.example \ | ||
| 41 | - bloom-view.example \ | ||
| 42 | - gaussian-blur-view.example | 40 | + logging.example |
| 41 | + | ||
| 43 | 42 | ||
| 44 | daliimagedir = $(appdatadir)/images/ | 43 | daliimagedir = $(appdatadir)/images/ |
| 45 | dalimodeldir = $(appdatadir)/models/ | 44 | dalimodeldir = $(appdatadir)/models/ |
| @@ -177,13 +176,3 @@ logging_example_SOURCES = $(examples_src_dir)/logging/logging-example.cpp | @@ -177,13 +176,3 @@ logging_example_SOURCES = $(examples_src_dir)/logging/logging-example.cpp | ||
| 177 | logging_example_CXXFLAGS = $(EXAMPLE_CXXFLAGS) | 176 | logging_example_CXXFLAGS = $(EXAMPLE_CXXFLAGS) |
| 178 | logging_example_DEPENDENCIES = $(EXAMPLE_DEPS) | 177 | logging_example_DEPENDENCIES = $(EXAMPLE_DEPS) |
| 179 | logging_example_LDADD = $(EXAMPLE_LDADD) | 178 | logging_example_LDADD = $(EXAMPLE_LDADD) |
| 180 | - | ||
| 181 | -bloom_view_example_SOURCES = $(examples_src_dir)/bloom-view/bloom-view-example.cpp | ||
| 182 | -bloom_view_example_CXXFLAGS = $(EXAMPLE_CXXFLAGS) | ||
| 183 | -bloom_view_example_DEPENDENCIES = $(EXAMPLE_DEPS) | ||
| 184 | -bloom_view_example_LDADD = $(EXAMPLE_LDADD) | ||
| 185 | - | ||
| 186 | -gaussian_blur_view_example_SOURCES = $(examples_src_dir)/gaussian-blur-view/gaussian-blur-view-example.cpp | ||
| 187 | -gaussian_blur_view_example_CXXFLAGS = $(EXAMPLE_CXXFLAGS) | ||
| 188 | -gaussian_blur_view_example_DEPENDENCIES = $(EXAMPLE_DEPS) | ||
| 189 | -gaussian_blur_view_example_LDADD = $(EXAMPLE_LDADD) |
com.samsung.dali-demo.xml
| @@ -76,10 +76,4 @@ | @@ -76,10 +76,4 @@ | ||
| 76 | <ui-application appid="logging.example" exec="/usr/apps/com.samsung.dali-demo/bin/logging.example" nodisplay="true" multiple="false" type="c++app" taskmanage="true"> | 76 | <ui-application appid="logging.example" exec="/usr/apps/com.samsung.dali-demo/bin/logging.example" nodisplay="true" multiple="false" type="c++app" taskmanage="true"> |
| 77 | <label>Logging</label> | 77 | <label>Logging</label> |
| 78 | </ui-application> | 78 | </ui-application> |
| 79 | - <ui-application appid="bloom-view.example" exec="/usr/apps/com.samsung.dali-demo/bin/bloom-view.example" nodisplay="true" multiple="false" type="c++app" taskmanage="true"> | ||
| 80 | - <label>Bloom View</label> | ||
| 81 | - </ui-application> | ||
| 82 | - <ui-application appid="gaussian-blur-view.example" exec="/usr/apps/com.samsung.dali-demo/bin/gaussian-blur-view.example" nodisplay="true" multiple="false" type="c++app" taskmanage="true"> | ||
| 83 | - <label>Gaussian Blur View</label> | ||
| 84 | - </ui-application> | ||
| 85 | </manifest> | 79 | </manifest> |
demo/images/GreyThinLine30x30-76x78.png deleted
1.09 KB
demo/images/UI-Leather-DIFF.png deleted
418 KB
demo/images/desktop_background_1440x2560.png deleted
1.83 MB
examples/bloom-view/bloom-view-example.cpp deleted
| 1 | -// | ||
| 2 | -// Copyright (c) 2014 Samsung Electronics Co., Ltd. | ||
| 3 | -// | ||
| 4 | -// Licensed under the Flora License, Version 1.0 (the License); | ||
| 5 | -// you may not use this file except in compliance with the License. | ||
| 6 | -// You may obtain a copy of the License at | ||
| 7 | -// | ||
| 8 | -// http://floralicense.org/license/ | ||
| 9 | -// | ||
| 10 | -// Unless required by applicable law or agreed to in writing, software | ||
| 11 | -// distributed under the License is distributed on an AS IS BASIS, | ||
| 12 | -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 13 | -// See the License for the specific language governing permissions and | ||
| 14 | -// limitations under the License. | ||
| 15 | -// | ||
| 16 | - | ||
| 17 | -#include <dali/dali.h> | ||
| 18 | -#include <dali-toolkit/dali-toolkit.h> | ||
| 19 | - | ||
| 20 | -using namespace Dali; | ||
| 21 | -using namespace Dali::Toolkit; | ||
| 22 | - | ||
| 23 | -namespace | ||
| 24 | -{ | ||
| 25 | - | ||
| 26 | -//#define ADD_REMOVE_FROM_STAGE_TEST | ||
| 27 | - | ||
| 28 | -const char* BACKGROUND_IMAGE_PATH = DALI_IMAGE_DIR "desktop_background_1440x2560.png"; | ||
| 29 | -const char* UI_DIFFUSE_IMAGE( DALI_IMAGE_DIR "UI-Leather-DIFF.png" ); | ||
| 30 | - | ||
| 31 | -const Rect<int> UI_PIXEL_AREA( 0, 0, 720, 1280 ); | ||
| 32 | - | ||
| 33 | -const Rect<int> PANEL1_PIXEL_AREA( 0, 0, 720, 39 ); | ||
| 34 | -const Rect<int> PANEL2_PIXEL_AREA( 0, 39, 720, 100 ); | ||
| 35 | - | ||
| 36 | -const unsigned int NUM_MOVEMENT_ANIMATIONS = 2; | ||
| 37 | - | ||
| 38 | -// for animating bloom intensity on tap gesture | ||
| 39 | -const float PULSE_BLOOM_INCREASE_ANIM_TIME = 1.175; | ||
| 40 | -const float PULSE_BLOOM_DECREASE_ANIM_TIME = 2.4; | ||
| 41 | -const float PULSE_BLOOM_TOTAL_ANIM_TIME = PULSE_BLOOM_INCREASE_ANIM_TIME + PULSE_BLOOM_DECREASE_ANIM_TIME; | ||
| 42 | -const float PULSE_BLOOM_INTENSITY_DEFAULT = 1.0f; | ||
| 43 | -const float PULSE_BLOOM_INTENSITY_INCREASE = 3.0f; | ||
| 44 | - | ||
| 45 | - | ||
| 46 | - | ||
| 47 | -// buttons | ||
| 48 | -const char* BUTTON_BACKGROUND_IMAGE_PATH = DALI_IMAGE_DIR "GreyThinLine30x30-76x78.png"; | ||
| 49 | - | ||
| 50 | -// These values depend on the button background image | ||
| 51 | -const Vector4 BUTTON_IMAGE_BORDER(16.0f, 16.0f, 16.0f, 20.0f); | ||
| 52 | - | ||
| 53 | - | ||
| 54 | -const float UI_MARGIN = 4.0f; ///< Screen Margin for placement of UI buttons | ||
| 55 | -const Vector3 BUTTON_SIZE_CONSTRAINT( 0.24f, 0.09f, 1.0f ); | ||
| 56 | -const char * BUTTON_QUIT = "Quit"; | ||
| 57 | - | ||
| 58 | -} // namespace | ||
| 59 | - | ||
| 60 | - | ||
| 61 | - | ||
| 62 | -/** | ||
| 63 | - * This example demonstrates a bloom effect. | ||
| 64 | - */ | ||
| 65 | -class TestApp : public ConnectionTracker | ||
| 66 | -{ | ||
| 67 | -public: | ||
| 68 | - | ||
| 69 | - TestApp( Application &application ) | ||
| 70 | - : mApplication(application) | ||
| 71 | - , mCurrentAnimation(0) | ||
| 72 | - { | ||
| 73 | - application.InitSignal().Connect(this, &TestApp::Create); | ||
| 74 | - } | ||
| 75 | - | ||
| 76 | - ~TestApp() | ||
| 77 | - { | ||
| 78 | - } | ||
| 79 | - | ||
| 80 | -public: | ||
| 81 | - | ||
| 82 | - void Create(Application& application) | ||
| 83 | - { | ||
| 84 | - // Preload images | ||
| 85 | - mDiffuseImage = Image::New( UI_DIFFUSE_IMAGE ); | ||
| 86 | - | ||
| 87 | - // Creation is deferred until images have loaded | ||
| 88 | - mDiffuseImage.LoadingFinishedSignal().Connect( this, &TestApp::Create2 ); | ||
| 89 | - } | ||
| 90 | - | ||
| 91 | -#ifdef ADD_REMOVE_FROM_STAGE_TEST | ||
| 92 | - void Create2(Image loadedImage) | ||
| 93 | - { | ||
| 94 | - Stage stage = Stage::GetCurrent(); | ||
| 95 | - Vector2 stageSize = stage.GetSize(); | ||
| 96 | - | ||
| 97 | - mStageRootActor = Actor::New(); | ||
| 98 | - mStageRootActor.SetParentOrigin(ParentOrigin::CENTER); | ||
| 99 | - mStageRootActor.SetSize(stageSize); | ||
| 100 | - stage.Add(mStageRootActor); | ||
| 101 | - | ||
| 102 | - // Create the object that will perform the blooming work | ||
| 103 | - mBloomView = Dali::Toolkit::BloomView::New(); | ||
| 104 | - mBloomView.SetParentOrigin(ParentOrigin::CENTER); | ||
| 105 | - mBloomView.SetSize(stageSize * 0.75f); | ||
| 106 | - mStageRootActor.Add(mBloomView); | ||
| 107 | - mBloomView.Activate(); | ||
| 108 | - | ||
| 109 | - // Create the background image | ||
| 110 | - Image background = Image::New(BACKGROUND_IMAGE_PATH); | ||
| 111 | - ImageActor backgroundImage = ImageActor::New(background); | ||
| 112 | - backgroundImage.SetParentOrigin(ParentOrigin::CENTER); | ||
| 113 | - backgroundImage.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) ); | ||
| 114 | - | ||
| 115 | - Layer backgroundLayer = Layer::New(); | ||
| 116 | - backgroundLayer.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) ); | ||
| 117 | - backgroundLayer.SetParentOrigin( ParentOrigin::CENTER ); | ||
| 118 | - mBloomView.Add( backgroundLayer ); | ||
| 119 | - backgroundLayer.Add( backgroundImage ); | ||
| 120 | - | ||
| 121 | - Layer foregroundLayer = Layer::New(); | ||
| 122 | - foregroundLayer.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) ); | ||
| 123 | - foregroundLayer.SetParentOrigin( ParentOrigin::CENTER ); | ||
| 124 | - mBloomView.Add( foregroundLayer ); | ||
| 125 | - | ||
| 126 | - // Create visible actors | ||
| 127 | - mObjectRootActor = Actor::New(); | ||
| 128 | - mObjectRootActor.SetParentOrigin( ParentOrigin::CENTER ); | ||
| 129 | - mObjectRootActor.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) ); | ||
| 130 | - foregroundLayer.Add( mObjectRootActor ); | ||
| 131 | - | ||
| 132 | - ImageActor imageActor = ImageActor::New( mDiffuseImage ); | ||
| 133 | - imageActor.SetParentOrigin( ParentOrigin::CENTER ); | ||
| 134 | - imageActor.SetSize( stageSize * 0.75f); | ||
| 135 | - mObjectRootActor.Add( imageActor ); | ||
| 136 | - | ||
| 137 | - imageActor = ImageActor::New( mDiffuseImage ); | ||
| 138 | - imageActor.SetParentOrigin( ParentOrigin::CENTER ); | ||
| 139 | - imageActor.SetSize( stageSize * 0.5f ); | ||
| 140 | - imageActor.SetPosition(0.0f, 0.0f, 100.0f); | ||
| 141 | - mObjectRootActor.Add( imageActor ); | ||
| 142 | - | ||
| 143 | - AnimateBloomView(); | ||
| 144 | - PulseBloomIntensity(); | ||
| 145 | - | ||
| 146 | - // Gesture detection | ||
| 147 | - mTapGestureDetector = TapGestureDetector::New(); | ||
| 148 | - mTapGestureDetector.Attach( mStageRootActor ); | ||
| 149 | - mTapGestureDetector.DetectedSignal().Connect( this, &TestApp::OnTap ); | ||
| 150 | - } | ||
| 151 | - | ||
| 152 | - void AnimateBloomView() | ||
| 153 | - { | ||
| 154 | - if(mRotationAnimation) | ||
| 155 | - { | ||
| 156 | - mRotationAnimation.Stop(); | ||
| 157 | - } | ||
| 158 | - if(mResizeAnimation) | ||
| 159 | - { | ||
| 160 | - mResizeAnimation.Stop(); | ||
| 161 | - } | ||
| 162 | - if(mTranslationAnimation) | ||
| 163 | - { | ||
| 164 | - mTranslationAnimation.Stop(); | ||
| 165 | - } | ||
| 166 | - if(mBlurAnimation) | ||
| 167 | - { | ||
| 168 | - mBlurAnimation.Stop(); | ||
| 169 | - } | ||
| 170 | - | ||
| 171 | - // ROTATE | ||
| 172 | - float animDuration = 10.0f; | ||
| 173 | - mRotationAnimation = Animation::New(animDuration); | ||
| 174 | - mRotationAnimation.RotateBy(mBloomView, Degree(720), Vector3::YAXIS, AlphaFunctions::EaseInOut); | ||
| 175 | - mRotationAnimation.SetEndAction( Animation::Discard ); | ||
| 176 | - mRotationAnimation.SetLooping( true ); | ||
| 177 | - mRotationAnimation.Play(); | ||
| 178 | - | ||
| 179 | - // BLUR | ||
| 180 | - mBlurAnimation = Animation::New( 4.0f ); | ||
| 181 | - mBlurAnimation.AnimateTo( Property( mBloomView, mBloomView.GetBlurStrengthPropertyIndex() ), 0.0f, AlphaFunctions::Linear, TimePeriod(0.0f, 0.5f) ); | ||
| 182 | - mBlurAnimation.AnimateTo( Property( mBloomView, mBloomView.GetBlurStrengthPropertyIndex() ), 1.0f, AlphaFunctions::Linear, TimePeriod(2.0f, 0.5f) ); | ||
| 183 | - mBlurAnimation.SetEndAction( Animation::Discard ); | ||
| 184 | - mBlurAnimation.SetLooping( true ); | ||
| 185 | - mBlurAnimation.Play(); | ||
| 186 | - } | ||
| 187 | -#else //#ifdef ADD_REMOVE_FROM_STAGE_TEST | ||
| 188 | - | ||
| 189 | - void Create2(Image loadedImage) | ||
| 190 | - { | ||
| 191 | - Stage stage = Stage::GetCurrent(); | ||
| 192 | - Vector2 stageSize = stage.GetSize(); | ||
| 193 | - | ||
| 194 | - mStageRootActor = Actor::New(); | ||
| 195 | - mStageRootActor.SetParentOrigin(ParentOrigin::CENTER); | ||
| 196 | - mStageRootActor.SetSize(stageSize); | ||
| 197 | - stage.Add(mStageRootActor); | ||
| 198 | - | ||
| 199 | - // Create the object that will perform the blooming work | ||
| 200 | - mBloomView = Dali::Toolkit::BloomView::New(); | ||
| 201 | - mBloomView.SetParentOrigin(ParentOrigin::CENTER); | ||
| 202 | - mBloomView.SetSize(stageSize * 0.75f); | ||
| 203 | - mStageRootActor.Add(mBloomView); | ||
| 204 | - mBloomView.Activate(); | ||
| 205 | - | ||
| 206 | - // Create the Quit button | ||
| 207 | - PushButton button; | ||
| 208 | - button = CreateButton(BUTTON_QUIT, BUTTON_QUIT, BUTTON_SIZE_CONSTRAINT); | ||
| 209 | - button.SetAnchorPoint(AnchorPoint::BOTTOM_RIGHT); | ||
| 210 | - button.SetParentOrigin(ParentOrigin::BOTTOM_RIGHT); | ||
| 211 | - button.SetPosition(-UI_MARGIN, -UI_MARGIN); | ||
| 212 | - | ||
| 213 | - // Create the background image | ||
| 214 | - Image background = Image::New(BACKGROUND_IMAGE_PATH); | ||
| 215 | - ImageActor backgroundImage = ImageActor::New(background); | ||
| 216 | - backgroundImage.SetParentOrigin(ParentOrigin::CENTER); | ||
| 217 | - backgroundImage.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) ); | ||
| 218 | - | ||
| 219 | - Layer backgroundLayer = Layer::New(); | ||
| 220 | - backgroundLayer.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) ); | ||
| 221 | - backgroundLayer.SetParentOrigin( ParentOrigin::CENTER ); | ||
| 222 | - mBloomView.Add( backgroundLayer ); | ||
| 223 | - backgroundLayer.Add( backgroundImage ); | ||
| 224 | - | ||
| 225 | - Layer foregroundLayer = Layer::New(); | ||
| 226 | - foregroundLayer.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) ); | ||
| 227 | - foregroundLayer.SetParentOrigin( ParentOrigin::CENTER ); | ||
| 228 | - mBloomView.Add( foregroundLayer ); | ||
| 229 | - | ||
| 230 | - // Create visible actors | ||
| 231 | - mObjectRootActor = Actor::New(); | ||
| 232 | - mObjectRootActor.SetParentOrigin( ParentOrigin::CENTER ); | ||
| 233 | - mObjectRootActor.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) ); | ||
| 234 | - foregroundLayer.Add( mObjectRootActor ); | ||
| 235 | - | ||
| 236 | - ImageActor imageActor = ImageActor::New( mDiffuseImage ); | ||
| 237 | - imageActor.SetParentOrigin( ParentOrigin::CENTER ); | ||
| 238 | - imageActor.SetSize( stageSize * 0.75f); | ||
| 239 | - mObjectRootActor.Add( imageActor ); | ||
| 240 | - | ||
| 241 | - imageActor = ImageActor::New( mDiffuseImage ); | ||
| 242 | - imageActor.SetParentOrigin( ParentOrigin::CENTER ); | ||
| 243 | - imageActor.SetSize( stageSize * 0.5f ); | ||
| 244 | - imageActor.SetPosition(0.0f, 0.0f, 100.0f); | ||
| 245 | - mObjectRootActor.Add( imageActor ); | ||
| 246 | - | ||
| 247 | - ToggleAnimation(); | ||
| 248 | - PulseBloomIntensity(); | ||
| 249 | - | ||
| 250 | - // Gesture detection | ||
| 251 | - mTapGestureDetector = TapGestureDetector::New(); | ||
| 252 | - mTapGestureDetector.Attach( mStageRootActor ); | ||
| 253 | - mTapGestureDetector.DetectedSignal().Connect( this, &TestApp::OnTap ); | ||
| 254 | - } | ||
| 255 | - | ||
| 256 | - PushButton CreateButton(const std::string& name, const std::string& label, const Vector3& sizeConstraint) | ||
| 257 | - { | ||
| 258 | - // Create the button | ||
| 259 | - Image img = Image::New(BUTTON_BACKGROUND_IMAGE_PATH); | ||
| 260 | - ImageActor background = ImageActor::New(img); | ||
| 261 | - | ||
| 262 | - background.SetStyle(ImageActor::STYLE_NINE_PATCH); | ||
| 263 | - background.SetNinePatchBorder(BUTTON_IMAGE_BORDER); | ||
| 264 | - | ||
| 265 | - PushButton button = PushButton::New(); | ||
| 266 | - button.SetName(name); | ||
| 267 | - button.SetBackgroundImage(background); | ||
| 268 | - | ||
| 269 | - // Set the button's size | ||
| 270 | - button.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), RelativeToConstraint( sizeConstraint ) ) ); | ||
| 271 | - | ||
| 272 | - // Make sure the button only takes up its natural or allocated width. | ||
| 273 | - button.SetSizePolicy( Toolkit::Control::Fixed, Toolkit::Control::Fixed ); | ||
| 274 | - | ||
| 275 | - mStageRootActor.Add(button); | ||
| 276 | - | ||
| 277 | - button.ClickedSignal().Connect(this, &TestApp::OnButtonTouchEvent); | ||
| 278 | - | ||
| 279 | - SetButtonLabel(button, label, TextView::Center); | ||
| 280 | - | ||
| 281 | - return button; | ||
| 282 | - } | ||
| 283 | - | ||
| 284 | - void SetButtonLabel(PushButton button, const std::string& label, const TextView::LineJustification justification) | ||
| 285 | - { | ||
| 286 | - Font font = Font::New(); | ||
| 287 | - Vector3 textSize = font.MeasureText(label); | ||
| 288 | - | ||
| 289 | - // Add a text label to the button | ||
| 290 | - TextView textView = TextView::New( label ); | ||
| 291 | - textView.SetAnchorPoint( AnchorPoint::CENTER ); | ||
| 292 | - textView.SetParentOrigin( ParentOrigin::CENTER ); | ||
| 293 | - textView.SetMultilinePolicy(TextView::SplitByWord); | ||
| 294 | - textView.SetWidthExceedPolicy(TextView::Original); | ||
| 295 | - textView.SetTextAlignment(static_cast< Alignment::Type >( Alignment::HorizontalCenter | Alignment::VerticalCenter )); | ||
| 296 | - textView.SetLineJustification(justification); | ||
| 297 | - textView.SetSize(textSize); | ||
| 298 | - | ||
| 299 | - Alignment align = Alignment::New(); | ||
| 300 | - align.Add(textView); | ||
| 301 | - align.SetScaling( Alignment::ShrinkToFitKeepAspect ); | ||
| 302 | - | ||
| 303 | - button.SetLabelText(align); | ||
| 304 | - } | ||
| 305 | - | ||
| 306 | - /** | ||
| 307 | - * Signal handler, called when the button is pressed | ||
| 308 | - */ | ||
| 309 | - bool OnButtonTouchEvent(Button button) | ||
| 310 | - { | ||
| 311 | - if(button.GetName() == BUTTON_QUIT) | ||
| 312 | - { | ||
| 313 | - // quit the application | ||
| 314 | - mApplication.Quit(); | ||
| 315 | - } | ||
| 316 | - | ||
| 317 | - return true; | ||
| 318 | - } | ||
| 319 | - | ||
| 320 | - void AnimateBloomView() | ||
| 321 | - { | ||
| 322 | - if(mRotationAnimation) | ||
| 323 | - { | ||
| 324 | - mRotationAnimation.Stop(); | ||
| 325 | - } | ||
| 326 | - if(mResizeAnimation) | ||
| 327 | - { | ||
| 328 | - mResizeAnimation.Stop(); | ||
| 329 | - } | ||
| 330 | - if(mTranslationAnimation) | ||
| 331 | - { | ||
| 332 | - mTranslationAnimation.Stop(); | ||
| 333 | - } | ||
| 334 | - if(mBlurAnimation) | ||
| 335 | - { | ||
| 336 | - mBlurAnimation.Stop(); | ||
| 337 | - } | ||
| 338 | - | ||
| 339 | - // ROTATE | ||
| 340 | - float animDuration = 10.0f; | ||
| 341 | - mRotationAnimation = Animation::New(animDuration); | ||
| 342 | - mRotationAnimation.RotateBy(mBloomView, Degree(720), Vector3::YAXIS, AlphaFunctions::EaseInOut); | ||
| 343 | - mRotationAnimation.SetEndAction( Animation::Discard ); | ||
| 344 | - mRotationAnimation.SetLooping( true ); | ||
| 345 | - mRotationAnimation.Play(); | ||
| 346 | - | ||
| 347 | - | ||
| 348 | - // RESIZE | ||
| 349 | - Stage stage = Stage::GetCurrent(); | ||
| 350 | - Vector3 stageSize(stage.GetSize().width, stage.GetSize().height, 1.0f); | ||
| 351 | - mResizeAnimation = Animation::New( 7.5f ); | ||
| 352 | - mResizeAnimation.AnimateTo( Property(mBloomView, Actor::SIZE), stageSize * Vector3(0.5f, 0.5f, 1.0f), AlphaFunctions::Bounce, TimePeriod(2.5f) ); | ||
| 353 | - mResizeAnimation.SetEndAction( Animation::Discard ); | ||
| 354 | - mResizeAnimation.SetLooping( true ); | ||
| 355 | - mResizeAnimation.Play(); | ||
| 356 | - | ||
| 357 | - | ||
| 358 | - // TRANSLATE | ||
| 359 | - mTranslationAnimation = Animation::New( 7.5f ); | ||
| 360 | - mTranslationAnimation.AnimateBy( Property(mObjectRootActor, Actor::POSITION), Vector3(100.0f, 0.0f, 0.0f), AlphaFunctions::Bounce, TimePeriod(2.5f) ); | ||
| 361 | - mTranslationAnimation.AnimateBy( Property(mObjectRootActor, Actor::POSITION), Vector3(300.0f, 0.0f, 0.0f), AlphaFunctions::Bounce, TimePeriod(2.5f, 2.5f) ); | ||
| 362 | - mTranslationAnimation.AnimateBy( Property(mObjectRootActor, Actor::POSITION), Vector3(0.0f, 0.0f, 0.0f), AlphaFunctions::Bounce, TimePeriod(5.0f, 2.5f) ); | ||
| 363 | - mTranslationAnimation.SetEndAction( Animation::Discard ); | ||
| 364 | - mTranslationAnimation.SetLooping( true ); | ||
| 365 | - mTranslationAnimation.Play(); | ||
| 366 | - | ||
| 367 | - | ||
| 368 | - // BLUR | ||
| 369 | - mBlurAnimation = Animation::New( 4.0f ); | ||
| 370 | - mBlurAnimation.AnimateTo( Property( mBloomView, mBloomView.GetBlurStrengthPropertyIndex() ), 0.0f, AlphaFunctions::Linear, TimePeriod(0.0f, 0.5f) ); | ||
| 371 | - mBlurAnimation.AnimateTo( Property( mBloomView, mBloomView.GetBlurStrengthPropertyIndex() ), 1.0f, AlphaFunctions::Linear, TimePeriod(2.0f, 0.5f) ); | ||
| 372 | - mBlurAnimation.SetEndAction( Animation::Discard ); | ||
| 373 | - mBlurAnimation.SetLooping( true ); | ||
| 374 | - mBlurAnimation.Play(); | ||
| 375 | - } | ||
| 376 | - | ||
| 377 | - void AnimateActorRoot() | ||
| 378 | - { | ||
| 379 | - if(mRotationAnimation) | ||
| 380 | - { | ||
| 381 | - mRotationAnimation.Stop(); | ||
| 382 | - } | ||
| 383 | - if(mResizeAnimation) | ||
| 384 | - { | ||
| 385 | - mResizeAnimation.Stop(); | ||
| 386 | - } | ||
| 387 | - if(mTranslationAnimation) | ||
| 388 | - { | ||
| 389 | - mTranslationAnimation.Stop(); | ||
| 390 | - } | ||
| 391 | - if(mBlurAnimation) | ||
| 392 | - { | ||
| 393 | - mBlurAnimation.Stop(); | ||
| 394 | - } | ||
| 395 | - | ||
| 396 | - // ROTATE | ||
| 397 | - float animDuration = 10.0f; | ||
| 398 | - mRotationAnimation = Animation::New(animDuration); | ||
| 399 | - mRotationAnimation.RotateBy(mObjectRootActor, Degree(720), Vector3::YAXIS, AlphaFunctions::EaseInOut); | ||
| 400 | - mRotationAnimation.SetEndAction( Animation::Discard ); | ||
| 401 | - mRotationAnimation.SetLooping( true ); | ||
| 402 | - mRotationAnimation.Play(); | ||
| 403 | - | ||
| 404 | - | ||
| 405 | - // RESIZE | ||
| 406 | - Stage stage = Stage::GetCurrent(); | ||
| 407 | - Vector3 stageSize(stage.GetSize().width, stage.GetSize().height, 1.0f); | ||
| 408 | - mResizeAnimation = Animation::New( 7.5f ); | ||
| 409 | - mResizeAnimation.AnimateTo( Property(mBloomView, Actor::SIZE), stageSize * Vector3(0.5f, 0.5f, 1.0f), AlphaFunctions::Bounce, TimePeriod(2.5f) ); | ||
| 410 | - mResizeAnimation.SetEndAction( Animation::Discard ); | ||
| 411 | - mResizeAnimation.SetLooping( true ); | ||
| 412 | - mResizeAnimation.Play(); | ||
| 413 | - | ||
| 414 | - | ||
| 415 | - // TRANSLATE | ||
| 416 | - mTranslationAnimation = Animation::New( 7.5f ); | ||
| 417 | - mTranslationAnimation.AnimateBy( Property(mObjectRootActor, Actor::POSITION), Vector3(100.0f, 0.0f, 0.0f), AlphaFunctions::Bounce, TimePeriod(2.5f) ); | ||
| 418 | - mTranslationAnimation.AnimateBy( Property(mObjectRootActor, Actor::POSITION), Vector3(300.0f, 0.0f, 0.0f), AlphaFunctions::Bounce, TimePeriod(2.5f, 2.5f) ); | ||
| 419 | - mTranslationAnimation.AnimateBy( Property(mObjectRootActor, Actor::POSITION), Vector3(0.0f, 0.0f, 0.0f), AlphaFunctions::Bounce, TimePeriod(5.0f, 2.5f) ); | ||
| 420 | - mTranslationAnimation.SetEndAction( Animation::Discard ); | ||
| 421 | - mTranslationAnimation.SetLooping( true ); | ||
| 422 | - mTranslationAnimation.Play(); | ||
| 423 | - | ||
| 424 | - | ||
| 425 | - // BLUR | ||
| 426 | - mBlurAnimation = Animation::New( 4.0f ); | ||
| 427 | - mBlurAnimation.AnimateTo( Property( mBloomView, mBloomView.GetBlurStrengthPropertyIndex() ), 0.0f, AlphaFunctions::Linear, TimePeriod(0.0f, 0.5f) ); | ||
| 428 | - mBlurAnimation.AnimateTo( Property( mBloomView, mBloomView.GetBlurStrengthPropertyIndex() ), 1.0f, AlphaFunctions::Linear, TimePeriod(2.0f, 0.5f) ); | ||
| 429 | - mBlurAnimation.SetEndAction( Animation::Discard ); | ||
| 430 | - mBlurAnimation.SetLooping( true ); | ||
| 431 | - mBlurAnimation.Play(); | ||
| 432 | - } | ||
| 433 | - | ||
| 434 | - void ToggleAnimation() | ||
| 435 | - { | ||
| 436 | - mCurrentAnimation++; | ||
| 437 | - if(mCurrentAnimation == NUM_MOVEMENT_ANIMATIONS) | ||
| 438 | - { | ||
| 439 | - mCurrentAnimation = 0; | ||
| 440 | - } | ||
| 441 | - | ||
| 442 | - switch(mCurrentAnimation) | ||
| 443 | - { | ||
| 444 | - case 0: | ||
| 445 | - AnimateActorRoot(); | ||
| 446 | - break; | ||
| 447 | - | ||
| 448 | - case 1: | ||
| 449 | - AnimateBloomView(); | ||
| 450 | - break; | ||
| 451 | - } | ||
| 452 | - } | ||
| 453 | -#endif //#ifdef ADD_REMOVE_FROM_STAGE_TEST | ||
| 454 | - | ||
| 455 | - void PulseBloomIntensity() | ||
| 456 | - { | ||
| 457 | - mPulseBloomIntensityAnim = Animation::New( 2.5f ); | ||
| 458 | - mPulseBloomIntensityAnim.AnimateTo( Property(mBloomView, mBloomView.GetBloomIntensityPropertyIndex()), 3.0f, AlphaFunctions::Bounce, TimePeriod(2.5f) ); | ||
| 459 | - mPulseBloomIntensityAnim.SetEndAction( Animation::Discard ); | ||
| 460 | - mPulseBloomIntensityAnim.SetLooping( true ); | ||
| 461 | - mPulseBloomIntensityAnim.Play(); | ||
| 462 | - } | ||
| 463 | - | ||
| 464 | - void OnTap( Actor actor, const TapGesture& tapGesture ) | ||
| 465 | - { | ||
| 466 | - Stage stage = Stage::GetCurrent(); | ||
| 467 | - | ||
| 468 | -#ifdef ADD_REMOVE_FROM_STAGE_TEST | ||
| 469 | - if(mBloomView.OnStage()) | ||
| 470 | - { | ||
| 471 | - mStageRootActor.Remove(mBloomView); | ||
| 472 | - mBloomView.Deactivate(); | ||
| 473 | - } | ||
| 474 | - else | ||
| 475 | - { | ||
| 476 | - mStageRootActor.Add(mBloomView); | ||
| 477 | - mBloomView.Activate(); | ||
| 478 | - } | ||
| 479 | -#else //#ifdef ADD_REMOVE_FROM_STAGE_TEST | ||
| 480 | - ToggleAnimation(); | ||
| 481 | -#endif //#ifdef ADD_REMOVE_FROM_STAGE_TEST | ||
| 482 | - } | ||
| 483 | - | ||
| 484 | -private: | ||
| 485 | - | ||
| 486 | - Application& mApplication; | ||
| 487 | - | ||
| 488 | - TapGestureDetector mTapGestureDetector; | ||
| 489 | - | ||
| 490 | - Actor mStageRootActor; | ||
| 491 | - | ||
| 492 | - Actor mObjectRootActor; | ||
| 493 | - Image mDiffuseImage; | ||
| 494 | - | ||
| 495 | - unsigned int mCurrentAnimation; | ||
| 496 | - Animation mRotationAnimation; | ||
| 497 | - Animation mResizeAnimation; | ||
| 498 | - Animation mTranslationAnimation; | ||
| 499 | - Animation mBlurAnimation; | ||
| 500 | - Animation mPulseBloomIntensityAnim; | ||
| 501 | - | ||
| 502 | - // for rendering the blur / bloom | ||
| 503 | - GaussianBlurView mGaussianBlurView; | ||
| 504 | - BloomView mBloomView; | ||
| 505 | -}; | ||
| 506 | - | ||
| 507 | -/*****************************************************************************/ | ||
| 508 | - | ||
| 509 | -static void | ||
| 510 | -RunTest( Application& application ) | ||
| 511 | -{ | ||
| 512 | - TestApp theApp(application); | ||
| 513 | - application.MainLoop(); | ||
| 514 | -} | ||
| 515 | - | ||
| 516 | -/*****************************************************************************/ | ||
| 517 | - | ||
| 518 | -int | ||
| 519 | -main(int argc, char **argv) | ||
| 520 | -{ | ||
| 521 | - Application application = Application::New(&argc, &argv); | ||
| 522 | - | ||
| 523 | - RunTest(application); | ||
| 524 | - | ||
| 525 | - return 0; | ||
| 526 | -} |
examples/gaussian-blur-view/gaussian-blur-view-example.cpp deleted
| 1 | -// | ||
| 2 | -// Copyright (c) 2014 Samsung Electronics Co., Ltd. | ||
| 3 | -// | ||
| 4 | -// Licensed under the Flora License, Version 1.0 (the License); | ||
| 5 | -// you may not use this file except in compliance with the License. | ||
| 6 | -// You may obtain a copy of the License at | ||
| 7 | -// | ||
| 8 | -// http://floralicense.org/license/ | ||
| 9 | -// | ||
| 10 | -// Unless required by applicable law or agreed to in writing, software | ||
| 11 | -// distributed under the License is distributed on an AS IS BASIS, | ||
| 12 | -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 13 | -// See the License for the specific language governing permissions and | ||
| 14 | -// limitations under the License. | ||
| 15 | -// | ||
| 16 | - | ||
| 17 | -#include <dali/dali.h> | ||
| 18 | -#include <dali-toolkit/dali-toolkit.h> | ||
| 19 | - | ||
| 20 | -using namespace Dali; | ||
| 21 | -using namespace Dali::Toolkit; | ||
| 22 | - | ||
| 23 | -namespace | ||
| 24 | -{ | ||
| 25 | - | ||
| 26 | -//#define ADD_REMOVE_FROM_STAGE_TEST | ||
| 27 | - | ||
| 28 | -const char* BACKGROUND_IMAGE_PATH = DALI_IMAGE_DIR "desktop_background_1440x2560.png"; | ||
| 29 | -const char* UI_DIFFUSE_IMAGE( DALI_IMAGE_DIR "UI-Leather-DIFF.png" ); | ||
| 30 | - | ||
| 31 | -const Rect<int> UI_PIXEL_AREA( 0, 0, 720, 1280 ); | ||
| 32 | - | ||
| 33 | -const Rect<int> PANEL1_PIXEL_AREA( 0, 0, 720, 39 ); | ||
| 34 | -const Rect<int> PANEL2_PIXEL_AREA( 0, 39, 720, 100 ); | ||
| 35 | - | ||
| 36 | -const unsigned int NUM_MOVEMENT_ANIMATIONS = 2; | ||
| 37 | - | ||
| 38 | -// for animating bloom intensity on tap gesture | ||
| 39 | -const float PULSE_BLOOM_INCREASE_ANIM_TIME = 1.175; | ||
| 40 | -const float PULSE_BLOOM_DECREASE_ANIM_TIME = 2.4; | ||
| 41 | -const float PULSE_BLOOM_TOTAL_ANIM_TIME = PULSE_BLOOM_INCREASE_ANIM_TIME + PULSE_BLOOM_DECREASE_ANIM_TIME; | ||
| 42 | -const float PULSE_BLOOM_INTENSITY_DEFAULT = 1.0f; | ||
| 43 | -const float PULSE_BLOOM_INTENSITY_INCREASE = 3.0f; | ||
| 44 | - | ||
| 45 | - | ||
| 46 | -// buttons | ||
| 47 | -const char* BUTTON_BACKGROUND_IMAGE_PATH = DALI_IMAGE_DIR "GreyThinLine30x30-76x78.png"; | ||
| 48 | - | ||
| 49 | -// These values depend on the button background image | ||
| 50 | -const float BUTTON_IMAGE_BORDER_LEFT = 16.0f; | ||
| 51 | -const float BUTTON_IMAGE_BORDER_RIGHT = 16.0f; | ||
| 52 | -const float BUTTON_IMAGE_BORDER_TOP = 13.0f; | ||
| 53 | -const float BUTTON_IMAGE_BORDER_BOTTOM = 20.0f; | ||
| 54 | - | ||
| 55 | -const Vector4 BUTTON_IMAGE_BORDER( BUTTON_IMAGE_BORDER_LEFT, BUTTON_IMAGE_BORDER_TOP, BUTTON_IMAGE_BORDER_RIGHT, BUTTON_IMAGE_BORDER_BOTTOM ); | ||
| 56 | - | ||
| 57 | -const float UI_MARGIN = 4.0f; ///< Screen Margin for placement of UI buttons | ||
| 58 | -const Vector3 BUTTON_SIZE_CONSTRAINT( 0.24f, 0.09f, 1.0f ); | ||
| 59 | -const char * BUTTON_QUIT = "Quit"; | ||
| 60 | -const char * BUTTON_QUIT_LABEL ="Quit"; | ||
| 61 | - | ||
| 62 | -} // namespace | ||
| 63 | - | ||
| 64 | - | ||
| 65 | - | ||
| 66 | -/** | ||
| 67 | - * This example demonstrates a blur effect. | ||
| 68 | - */ | ||
| 69 | -class TestApp : public ConnectionTracker | ||
| 70 | -{ | ||
| 71 | -public: | ||
| 72 | - | ||
| 73 | - TestApp( Application &application ) | ||
| 74 | - : mApplication(application) | ||
| 75 | - , mCurrentAnimation(0) | ||
| 76 | - { | ||
| 77 | - application.InitSignal().Connect(this, &TestApp::Create); | ||
| 78 | - application.TerminateSignal().Connect(this, &TestApp::Terminate); | ||
| 79 | - } | ||
| 80 | - | ||
| 81 | - ~TestApp() | ||
| 82 | - { | ||
| 83 | - } | ||
| 84 | - | ||
| 85 | -public: | ||
| 86 | - | ||
| 87 | - void Create(Application& application) | ||
| 88 | - { | ||
| 89 | - // Preload images | ||
| 90 | - mDiffuseImage = Image::New( UI_DIFFUSE_IMAGE ); | ||
| 91 | - | ||
| 92 | - // Creation is deferred until images have loaded | ||
| 93 | - mDiffuseImage.LoadingFinishedSignal().Connect( this, &TestApp::Create2 ); | ||
| 94 | - } | ||
| 95 | - | ||
| 96 | -#ifdef ADD_REMOVE_FROM_STAGE_TEST | ||
| 97 | - void Create2(Image loadedImage) | ||
| 98 | - { | ||
| 99 | - Stage stage = Stage::GetCurrent(); | ||
| 100 | - Vector2 stageSize = stage.GetSize(); | ||
| 101 | - | ||
| 102 | - mStageRootActor = Actor::New(); | ||
| 103 | - mStageRootActor.SetParentOrigin(ParentOrigin::CENTER); | ||
| 104 | - mStageRootActor.SetSize(stageSize); | ||
| 105 | - stage.Add(mStageRootActor); | ||
| 106 | - | ||
| 107 | - // Create the object that will perform the blurring work | ||
| 108 | - mGaussianBlurView = Dali::Toolkit::GaussianBlurView::New(); | ||
| 109 | - mGaussianBlurView.SetParentOrigin(ParentOrigin::CENTER); | ||
| 110 | - mGaussianBlurView.SetSize(stageSize * 0.75f); | ||
| 111 | - mStageRootActor.Add(mGaussianBlurView); | ||
| 112 | - mGaussianBlurView.Activate(); | ||
| 113 | - | ||
| 114 | - // Create the background image | ||
| 115 | - Image background = Image::New(BACKGROUND_IMAGE_PATH); | ||
| 116 | - ImageActor backgroundImage = ImageActor::New(background); | ||
| 117 | - backgroundImage.SetParentOrigin(ParentOrigin::CENTER); | ||
| 118 | - backgroundImage.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) ); | ||
| 119 | - | ||
| 120 | - Layer backgroundLayer = Layer::New(); | ||
| 121 | - backgroundLayer.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) ); | ||
| 122 | - backgroundLayer.SetParentOrigin( ParentOrigin::CENTER ); | ||
| 123 | - mGaussianBlurView.Add( backgroundLayer ); | ||
| 124 | - backgroundLayer.Add( backgroundImage ); | ||
| 125 | - | ||
| 126 | - Layer foregroundLayer = Layer::New(); | ||
| 127 | - foregroundLayer.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) ); | ||
| 128 | - foregroundLayer.SetParentOrigin( ParentOrigin::CENTER ); | ||
| 129 | - mGaussianBlurView.Add( foregroundLayer ); | ||
| 130 | - | ||
| 131 | - // Create visible actors | ||
| 132 | - mObjectRootActor = Actor::New(); | ||
| 133 | - mObjectRootActor.SetParentOrigin( ParentOrigin::CENTER ); | ||
| 134 | - mObjectRootActor.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) ); | ||
| 135 | - foregroundLayer.Add( mObjectRootActor ); | ||
| 136 | - | ||
| 137 | - ImageActor imageActor = ImageActor::New( mDiffuseImage ); | ||
| 138 | - imageActor.SetParentOrigin( ParentOrigin::CENTER ); | ||
| 139 | - imageActor.SetSize( stageSize * 0.75f); | ||
| 140 | - mObjectRootActor.Add( imageActor ); | ||
| 141 | - | ||
| 142 | - imageActor = ImageActor::New( mDiffuseImage ); | ||
| 143 | - imageActor.SetParentOrigin( ParentOrigin::CENTER ); | ||
| 144 | - imageActor.SetSize( stageSize * 0.5f ); | ||
| 145 | - imageActor.SetPosition(0.0f, 0.0f, 100.0f); | ||
| 146 | - mObjectRootActor.Add( imageActor ); | ||
| 147 | - | ||
| 148 | - AnimateGaussianBlurView(); | ||
| 149 | - | ||
| 150 | - // Gesture detection | ||
| 151 | - mTapGestureDetector = TapGestureDetector::New(); | ||
| 152 | - mTapGestureDetector.Attach( mStageRootActor ); | ||
| 153 | - mTapGestureDetector.DetectedSignal().Connect( this, &TestApp::OnTap ); | ||
| 154 | - } | ||
| 155 | - | ||
| 156 | - void AnimateGaussianBlurView() | ||
| 157 | - { | ||
| 158 | - if(mRotationAnimation) | ||
| 159 | - { | ||
| 160 | - mRotationAnimation.Stop(); | ||
| 161 | - } | ||
| 162 | - if(mResizeAnimation) | ||
| 163 | - { | ||
| 164 | - mResizeAnimation.Stop(); | ||
| 165 | - } | ||
| 166 | - if(mTranslationAnimation) | ||
| 167 | - { | ||
| 168 | - mTranslationAnimation.Stop(); | ||
| 169 | - } | ||
| 170 | - if(mBlurAnimation) | ||
| 171 | - { | ||
| 172 | - mBlurAnimation.Stop(); | ||
| 173 | - } | ||
| 174 | - | ||
| 175 | - // ROTATE | ||
| 176 | - float animDuration = 10.0f; | ||
| 177 | - mRotationAnimation = Animation::New(animDuration); | ||
| 178 | - mRotationAnimation.RotateBy(mGaussianBlurView, Degree(720), Vector3::YAXIS, AlphaFunctions::EaseInOut); | ||
| 179 | - mRotationAnimation.SetEndAction( Animation::Discard ); | ||
| 180 | - mRotationAnimation.SetLooping( true ); | ||
| 181 | - mRotationAnimation.Play(); | ||
| 182 | - | ||
| 183 | - // BLUR | ||
| 184 | - mBlurAnimation = Animation::New( 4.0f ); | ||
| 185 | - mBlurAnimation.AnimateTo( Property( mGaussianBlurView, mGaussianBlurView.GetBlurStrengthPropertyIndex() ), 0.0f, AlphaFunctions::Linear, TimePeriod(0.0f, 0.5f) ); | ||
| 186 | - mBlurAnimation.AnimateTo( Property( mGaussianBlurView, mGaussianBlurView.GetBlurStrengthPropertyIndex() ), 1.0f, AlphaFunctions::Linear, TimePeriod(2.0f, 0.5f) ); | ||
| 187 | - mBlurAnimation.SetEndAction( Animation::Discard ); | ||
| 188 | - mBlurAnimation.SetLooping( true ); | ||
| 189 | - mBlurAnimation.Play(); | ||
| 190 | - } | ||
| 191 | -#else //#ifdef ADD_REMOVE_FROM_STAGE_TEST | ||
| 192 | - | ||
| 193 | - void Create2(Image loadedImage) | ||
| 194 | - { | ||
| 195 | - Stage stage = Stage::GetCurrent(); | ||
| 196 | - Vector2 stageSize = stage.GetSize(); | ||
| 197 | - | ||
| 198 | - mStageRootActor = Actor::New(); | ||
| 199 | - mStageRootActor.SetParentOrigin(ParentOrigin::CENTER); | ||
| 200 | - mStageRootActor.SetSize(stageSize); | ||
| 201 | - stage.Add(mStageRootActor); | ||
| 202 | - | ||
| 203 | - // Create the object that will perform the blurring work | ||
| 204 | - mGaussianBlurView = Dali::Toolkit::GaussianBlurView::New(); | ||
| 205 | - mGaussianBlurView.SetParentOrigin(ParentOrigin::CENTER); | ||
| 206 | - mGaussianBlurView.SetSize(stageSize * 0.75f); | ||
| 207 | - mStageRootActor.Add(mGaussianBlurView); | ||
| 208 | - mGaussianBlurView.Activate(); | ||
| 209 | - | ||
| 210 | - // Create the Quit button | ||
| 211 | - PushButton button; | ||
| 212 | - button = CreateButton(BUTTON_QUIT, BUTTON_QUIT_LABEL, BUTTON_SIZE_CONSTRAINT); | ||
| 213 | - button.SetAnchorPoint(AnchorPoint::BOTTOM_RIGHT); | ||
| 214 | - button.SetParentOrigin(ParentOrigin::BOTTOM_RIGHT); | ||
| 215 | - button.SetPosition(-UI_MARGIN, -UI_MARGIN); | ||
| 216 | - | ||
| 217 | - // Create the background image | ||
| 218 | - Image background = Image::New(BACKGROUND_IMAGE_PATH); | ||
| 219 | - ImageActor backgroundImage = ImageActor::New(background); | ||
| 220 | - backgroundImage.SetParentOrigin(ParentOrigin::CENTER); | ||
| 221 | - backgroundImage.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) ); | ||
| 222 | - | ||
| 223 | - Layer backgroundLayer = Layer::New(); | ||
| 224 | - backgroundLayer.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) ); | ||
| 225 | - backgroundLayer.SetParentOrigin( ParentOrigin::CENTER ); | ||
| 226 | - mGaussianBlurView.Add( backgroundLayer ); | ||
| 227 | - backgroundLayer.Add( backgroundImage ); | ||
| 228 | - | ||
| 229 | - Layer foregroundLayer = Layer::New(); | ||
| 230 | - foregroundLayer.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) ); | ||
| 231 | - foregroundLayer.SetParentOrigin( ParentOrigin::CENTER ); | ||
| 232 | - mGaussianBlurView.Add( foregroundLayer ); | ||
| 233 | - | ||
| 234 | - // Create visible actors | ||
| 235 | - mObjectRootActor = Actor::New(); | ||
| 236 | - mObjectRootActor.SetParentOrigin( ParentOrigin::CENTER ); | ||
| 237 | - mObjectRootActor.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) ); | ||
| 238 | - foregroundLayer.Add( mObjectRootActor ); | ||
| 239 | - | ||
| 240 | - ImageActor imageActor = ImageActor::New( mDiffuseImage ); | ||
| 241 | - imageActor.SetParentOrigin( ParentOrigin::CENTER ); | ||
| 242 | - imageActor.SetSize( stageSize * 0.75f); | ||
| 243 | - mObjectRootActor.Add( imageActor ); | ||
| 244 | - | ||
| 245 | - imageActor = ImageActor::New( mDiffuseImage ); | ||
| 246 | - imageActor.SetParentOrigin( ParentOrigin::CENTER ); | ||
| 247 | - imageActor.SetSize( stageSize * 0.5f ); | ||
| 248 | - imageActor.SetPosition(0.0f, 0.0f, 100.0f); | ||
| 249 | - mObjectRootActor.Add( imageActor ); | ||
| 250 | - | ||
| 251 | - ToggleAnimation(); | ||
| 252 | - | ||
| 253 | - // Gesture detection | ||
| 254 | - mTapGestureDetector = TapGestureDetector::New(); | ||
| 255 | - mTapGestureDetector.Attach( mStageRootActor ); | ||
| 256 | - mTapGestureDetector.DetectedSignal().Connect( this, &TestApp::OnTap ); | ||
| 257 | - } | ||
| 258 | - | ||
| 259 | - PushButton CreateButton(const std::string& name, const std::string& label, const Vector3& sizeConstraint) | ||
| 260 | - { | ||
| 261 | - // Create the button | ||
| 262 | - Image img = Image::New(BUTTON_BACKGROUND_IMAGE_PATH); | ||
| 263 | - ImageActor background = ImageActor::New(img); | ||
| 264 | - | ||
| 265 | - background.SetStyle(ImageActor::STYLE_NINE_PATCH); | ||
| 266 | - background.SetNinePatchBorder(BUTTON_IMAGE_BORDER); | ||
| 267 | - | ||
| 268 | - PushButton button = PushButton::New(); | ||
| 269 | - button.SetName(name); | ||
| 270 | - button.SetBackgroundImage(background); | ||
| 271 | - | ||
| 272 | - // Set the button's size | ||
| 273 | - button.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), RelativeToConstraint( sizeConstraint ) ) ); | ||
| 274 | - | ||
| 275 | - mStageRootActor.Add(button); | ||
| 276 | - | ||
| 277 | - button.ClickedSignal().Connect(this, &TestApp::OnButtonTouchEvent); | ||
| 278 | - | ||
| 279 | - SetButtonLabel(button, label, TextView::Center); | ||
| 280 | - | ||
| 281 | - return button; | ||
| 282 | - } | ||
| 283 | - | ||
| 284 | - void SetButtonLabel(PushButton button, const std::string& label, const TextView::LineJustification justification) | ||
| 285 | - { | ||
| 286 | - Font font = Font::New(); | ||
| 287 | - Vector3 textSize = font.MeasureText(label); | ||
| 288 | - | ||
| 289 | - // Add a text label to the button | ||
| 290 | - TextView textView = TextView::New( label ); | ||
| 291 | - textView.SetAnchorPoint( AnchorPoint::CENTER ); | ||
| 292 | - textView.SetParentOrigin( ParentOrigin::CENTER ); | ||
| 293 | - textView.SetMultilinePolicy(TextView::SplitByWord); | ||
| 294 | - textView.SetWidthExceedPolicy(TextView::Original); | ||
| 295 | - textView.SetTextAlignment(static_cast< Alignment::Type >( Alignment::HorizontalCenter | Alignment::VerticalCenter )); | ||
| 296 | - textView.SetLineJustification(justification); | ||
| 297 | - textView.SetSize(textSize); | ||
| 298 | - | ||
| 299 | - Alignment align = Alignment::New(); | ||
| 300 | - align.Add(textView); | ||
| 301 | - align.SetScaling( Alignment::ShrinkToFitKeepAspect ); | ||
| 302 | - | ||
| 303 | - button.SetLabelText(align); | ||
| 304 | - } | ||
| 305 | - | ||
| 306 | - /** | ||
| 307 | - * Signal handler, called when the button is pressed | ||
| 308 | - */ | ||
| 309 | - bool OnButtonTouchEvent(Button button) | ||
| 310 | - { | ||
| 311 | - if(button.GetName() == BUTTON_QUIT) | ||
| 312 | - { | ||
| 313 | - // quit the application | ||
| 314 | - mApplication.Quit(); | ||
| 315 | - } | ||
| 316 | - | ||
| 317 | - return true; | ||
| 318 | - } | ||
| 319 | - | ||
| 320 | - void AnimateGaussianBlurView() | ||
| 321 | - { | ||
| 322 | - if(mRotationAnimation) | ||
| 323 | - { | ||
| 324 | - mRotationAnimation.Stop(); | ||
| 325 | - } | ||
| 326 | - if(mResizeAnimation) | ||
| 327 | - { | ||
| 328 | - mResizeAnimation.Stop(); | ||
| 329 | - } | ||
| 330 | - if(mTranslationAnimation) | ||
| 331 | - { | ||
| 332 | - mTranslationAnimation.Stop(); | ||
| 333 | - } | ||
| 334 | - if(mBlurAnimation) | ||
| 335 | - { | ||
| 336 | - mBlurAnimation.Stop(); | ||
| 337 | - } | ||
| 338 | - | ||
| 339 | - // ROTATE | ||
| 340 | - float animDuration = 10.0f; | ||
| 341 | - mRotationAnimation = Animation::New(animDuration); | ||
| 342 | - mRotationAnimation.RotateBy(mGaussianBlurView, Degree(720), Vector3::YAXIS, AlphaFunctions::EaseInOut); | ||
| 343 | - mRotationAnimation.SetEndAction( Animation::Discard ); | ||
| 344 | - mRotationAnimation.SetLooping( true ); | ||
| 345 | - mRotationAnimation.Play(); | ||
| 346 | - | ||
| 347 | - | ||
| 348 | - // RESIZE | ||
| 349 | - Stage stage = Stage::GetCurrent(); | ||
| 350 | - Vector3 stageSize(stage.GetSize().width, stage.GetSize().height, 1.0f); | ||
| 351 | - mResizeAnimation = Animation::New( 7.5f ); | ||
| 352 | - mResizeAnimation.AnimateTo( Property(mGaussianBlurView, Actor::SIZE), stageSize * Vector3(0.5f, 0.5f, 1.0f), AlphaFunctions::Bounce, TimePeriod(2.5f) ); | ||
| 353 | - mResizeAnimation.SetEndAction( Animation::Discard ); | ||
| 354 | - mResizeAnimation.SetLooping( true ); | ||
| 355 | - mResizeAnimation.Play(); | ||
| 356 | - | ||
| 357 | - | ||
| 358 | - // TRANSLATE | ||
| 359 | - mTranslationAnimation = Animation::New( 7.5f ); | ||
| 360 | - mTranslationAnimation.AnimateBy( Property(mObjectRootActor, Actor::POSITION), Vector3(100.0f, 0.0f, 0.0f), AlphaFunctions::Bounce, TimePeriod(2.5f) ); | ||
| 361 | - mTranslationAnimation.AnimateBy( Property(mObjectRootActor, Actor::POSITION), Vector3(300.0f, 0.0f, 0.0f), AlphaFunctions::Bounce, TimePeriod(2.5f, 2.5f) ); | ||
| 362 | - mTranslationAnimation.AnimateBy( Property(mObjectRootActor, Actor::POSITION), Vector3(0.0f, 0.0f, 0.0f), AlphaFunctions::Bounce, TimePeriod(5.0f, 2.5f) ); | ||
| 363 | - mTranslationAnimation.SetEndAction( Animation::Discard ); | ||
| 364 | - mTranslationAnimation.SetLooping( true ); | ||
| 365 | - mTranslationAnimation.Play(); | ||
| 366 | - | ||
| 367 | - | ||
| 368 | - // BLUR | ||
| 369 | - mBlurAnimation = Animation::New( 4.0f ); | ||
| 370 | - mBlurAnimation.AnimateTo( Property( mGaussianBlurView, mGaussianBlurView.GetBlurStrengthPropertyIndex() ), 0.0f, AlphaFunctions::Linear, TimePeriod(0.0f, 0.5f) ); | ||
| 371 | - mBlurAnimation.AnimateTo( Property( mGaussianBlurView, mGaussianBlurView.GetBlurStrengthPropertyIndex() ), 1.0f, AlphaFunctions::Linear, TimePeriod(2.0f, 0.5f) ); | ||
| 372 | - mBlurAnimation.SetEndAction( Animation::Discard ); | ||
| 373 | - mBlurAnimation.SetLooping( true ); | ||
| 374 | - mBlurAnimation.Play(); | ||
| 375 | - } | ||
| 376 | - | ||
| 377 | - void AnimateActorRoot() | ||
| 378 | - { | ||
| 379 | - if(mRotationAnimation) | ||
| 380 | - { | ||
| 381 | - mRotationAnimation.Stop(); | ||
| 382 | - } | ||
| 383 | - if(mResizeAnimation) | ||
| 384 | - { | ||
| 385 | - mResizeAnimation.Stop(); | ||
| 386 | - } | ||
| 387 | - if(mTranslationAnimation) | ||
| 388 | - { | ||
| 389 | - mTranslationAnimation.Stop(); | ||
| 390 | - } | ||
| 391 | - if(mBlurAnimation) | ||
| 392 | - { | ||
| 393 | - mBlurAnimation.Stop(); | ||
| 394 | - } | ||
| 395 | - | ||
| 396 | - // ROTATE | ||
| 397 | - float animDuration = 10.0f; | ||
| 398 | - mRotationAnimation = Animation::New(animDuration); | ||
| 399 | - mRotationAnimation.RotateBy(mObjectRootActor, Degree(720), Vector3::YAXIS, AlphaFunctions::EaseInOut); | ||
| 400 | - mRotationAnimation.SetEndAction( Animation::Discard ); | ||
| 401 | - mRotationAnimation.SetLooping( true ); | ||
| 402 | - mRotationAnimation.Play(); | ||
| 403 | - | ||
| 404 | - | ||
| 405 | - // RESIZE | ||
| 406 | - Stage stage = Stage::GetCurrent(); | ||
| 407 | - Vector3 stageSize(stage.GetSize().width, stage.GetSize().height, 1.0f); | ||
| 408 | - mResizeAnimation = Animation::New( 7.5f ); | ||
| 409 | - mResizeAnimation.AnimateTo( Property(mGaussianBlurView, Actor::SIZE), stageSize * Vector3(0.5f, 0.5f, 1.0f), AlphaFunctions::Bounce, TimePeriod(2.5f) ); | ||
| 410 | - mResizeAnimation.SetEndAction( Animation::Discard ); | ||
| 411 | - mResizeAnimation.SetLooping( true ); | ||
| 412 | - mResizeAnimation.Play(); | ||
| 413 | - | ||
| 414 | - | ||
| 415 | - // TRANSLATE | ||
| 416 | - mTranslationAnimation = Animation::New( 7.5f ); | ||
| 417 | - mTranslationAnimation.AnimateBy( Property(mObjectRootActor, Actor::POSITION), Vector3(100.0f, 0.0f, 0.0f), AlphaFunctions::Bounce, TimePeriod(2.5f) ); | ||
| 418 | - mTranslationAnimation.AnimateBy( Property(mObjectRootActor, Actor::POSITION), Vector3(300.0f, 0.0f, 0.0f), AlphaFunctions::Bounce, TimePeriod(2.5f, 2.5f) ); | ||
| 419 | - mTranslationAnimation.AnimateBy( Property(mObjectRootActor, Actor::POSITION), Vector3(0.0f, 0.0f, 0.0f), AlphaFunctions::Bounce, TimePeriod(5.0f, 2.5f) ); | ||
| 420 | - mTranslationAnimation.SetEndAction( Animation::Discard ); | ||
| 421 | - mTranslationAnimation.SetLooping( true ); | ||
| 422 | - mTranslationAnimation.Play(); | ||
| 423 | - | ||
| 424 | - | ||
| 425 | - // BLUR | ||
| 426 | - mBlurAnimation = Animation::New( 4.0f ); | ||
| 427 | - mBlurAnimation.AnimateTo( Property( mGaussianBlurView, mGaussianBlurView.GetBlurStrengthPropertyIndex() ), 0.0f, AlphaFunctions::Linear, TimePeriod(0.0f, 0.5f) ); | ||
| 428 | - mBlurAnimation.AnimateTo( Property( mGaussianBlurView, mGaussianBlurView.GetBlurStrengthPropertyIndex() ), 1.0f, AlphaFunctions::Linear, TimePeriod(2.0f, 0.5f) ); | ||
| 429 | - mBlurAnimation.SetEndAction( Animation::Discard ); | ||
| 430 | - mBlurAnimation.SetLooping( true ); | ||
| 431 | - mBlurAnimation.Play(); | ||
| 432 | - } | ||
| 433 | - | ||
| 434 | - void ToggleAnimation() | ||
| 435 | - { | ||
| 436 | - mCurrentAnimation++; | ||
| 437 | - if(mCurrentAnimation == NUM_MOVEMENT_ANIMATIONS) | ||
| 438 | - { | ||
| 439 | - mCurrentAnimation = 0; | ||
| 440 | - } | ||
| 441 | - | ||
| 442 | - switch(mCurrentAnimation) | ||
| 443 | - { | ||
| 444 | - case 0: | ||
| 445 | - AnimateActorRoot(); | ||
| 446 | - break; | ||
| 447 | - | ||
| 448 | - case 1: | ||
| 449 | - AnimateGaussianBlurView(); | ||
| 450 | - break; | ||
| 451 | - } | ||
| 452 | - } | ||
| 453 | -#endif //#ifdef ADD_REMOVE_FROM_STAGE_TEST | ||
| 454 | - | ||
| 455 | - void Terminate( Application& app ) | ||
| 456 | - { | ||
| 457 | - } | ||
| 458 | - | ||
| 459 | - void OnTap( Actor actor, const TapGesture& tapGesture ) | ||
| 460 | - { | ||
| 461 | - Stage stage = Stage::GetCurrent(); | ||
| 462 | - | ||
| 463 | -#ifdef ADD_REMOVE_FROM_STAGE_TEST | ||
| 464 | - if(mGaussianBlurView.OnStage()) | ||
| 465 | - { | ||
| 466 | - mStageRootActor.Remove(mGaussianBlurView); | ||
| 467 | - mGaussianBlurView.Deactivate(); | ||
| 468 | - } | ||
| 469 | - else | ||
| 470 | - { | ||
| 471 | - mStageRootActor.Add(mGaussianBlurView); | ||
| 472 | - mGaussianBlurView.Activate(); | ||
| 473 | - } | ||
| 474 | -#else //#ifdef ADD_REMOVE_FROM_STAGE_TEST | ||
| 475 | - ToggleAnimation(); | ||
| 476 | -#endif //#ifdef ADD_REMOVE_FROM_STAGE_TEST | ||
| 477 | - } | ||
| 478 | - | ||
| 479 | -private: | ||
| 480 | - | ||
| 481 | - Application& mApplication; | ||
| 482 | - | ||
| 483 | - TapGestureDetector mTapGestureDetector; | ||
| 484 | - | ||
| 485 | - Actor mStageRootActor; | ||
| 486 | - | ||
| 487 | - Actor mObjectRootActor; | ||
| 488 | - Image mDiffuseImage; | ||
| 489 | - | ||
| 490 | - unsigned int mCurrentAnimation; | ||
| 491 | - Animation mRotationAnimation; | ||
| 492 | - Animation mResizeAnimation; | ||
| 493 | - Animation mTranslationAnimation; | ||
| 494 | - Animation mBlurAnimation; | ||
| 495 | - Animation mPulseBloomIntensityAnim; | ||
| 496 | - | ||
| 497 | - // for rendering the blur / bloom | ||
| 498 | - GaussianBlurView mGaussianBlurView; | ||
| 499 | - BloomView mBloomView; | ||
| 500 | -}; | ||
| 501 | - | ||
| 502 | -/*****************************************************************************/ | ||
| 503 | - | ||
| 504 | -static void | ||
| 505 | -RunTest( Application& application ) | ||
| 506 | -{ | ||
| 507 | - TestApp theApp(application); | ||
| 508 | - application.MainLoop(); | ||
| 509 | -} | ||
| 510 | - | ||
| 511 | -/*****************************************************************************/ | ||
| 512 | - | ||
| 513 | -int | ||
| 514 | -main(int argc, char **argv) | ||
| 515 | -{ | ||
| 516 | - Application application = Application::New(&argc, &argv); | ||
| 517 | - | ||
| 518 | - RunTest(application); | ||
| 519 | - | ||
| 520 | - return 0; | ||
| 521 | -} |
examples/magnifier/magnifier-example.cpp
| @@ -236,7 +236,7 @@ public: | @@ -236,7 +236,7 @@ public: | ||
| 236 | mMagnifier.SetSourceActor( mView.GetBackgroundLayer() ); | 236 | mMagnifier.SetSourceActor( mView.GetBackgroundLayer() ); |
| 237 | mMagnifier.SetSize( MAGNIFIER_SIZE * mStageSize.width ); // Size of magnifier is in relation to stage width | 237 | mMagnifier.SetSize( MAGNIFIER_SIZE * mStageSize.width ); // Size of magnifier is in relation to stage width |
| 238 | mMagnifier.SetMagnificationFactor( MAGNIFICATION_FACTOR ); | 238 | mMagnifier.SetMagnificationFactor( MAGNIFICATION_FACTOR ); |
| 239 | - mMagnifier.SetFrameVisibility(true); | 239 | + mMagnifier.SetFrameVisibility(false); |
| 240 | mMagnifier.SetScale(Vector3::ZERO); | 240 | mMagnifier.SetScale(Vector3::ZERO); |
| 241 | overlay.Add( mMagnifier ); | 241 | overlay.Add( mMagnifier ); |
| 242 | 242 |