Commit 40844807e7258f1e5d9ef1a3650f438c8777409c
[dali_1.2.9] Merge branch 'devel/master'
Change-Id: I22f7ca621b2329dc94c445a3330a646bc6d585c5
Showing
16 changed files
with
583 additions
and
82 deletions
com.samsung.dali-demo.xml
| ... | ... | @@ -106,9 +106,6 @@ |
| 106 | 106 | <ui-application appid="animated-shapes.example" exec="/usr/apps/com.samsung.dali-demo/bin/animated-shapes.example" nodisplay="true" multiple="false" type="c++app" taskmanage="true"> |
| 107 | 107 | <label>Animated shapes</label> |
| 108 | 108 | </ui-application> |
| 109 | - <ui-application appid="path-animation.example" exec="/usr/apps/com.samsung.dali-demo/bin/path-animation.example" nodisplay="true" multiple="false" type="c++app" taskmanage="true"> | |
| 110 | - <label>Path Animation</label> | |
| 111 | - </ui-application> | |
| 112 | 109 | <ui-application appid="atlas.example" exec="/usr/apps/com.samsung.dali-demo/bin/atlas.example" nodisplay="true" multiple="false" type="c++app" taskmanage="true"> |
| 113 | 110 | <label>Atlas</label> |
| 114 | 111 | </ui-application> | ... | ... |
demo/dali-demo.cpp
| ... | ... | @@ -36,6 +36,7 @@ int DALI_EXPORT_API main(int argc, char **argv) |
| 36 | 36 | // Create the demo launcher |
| 37 | 37 | DaliTableView demo(app); |
| 38 | 38 | |
| 39 | + demo.AddExample(Example("animated-shapes.example", DALI_DEMO_STR_TITLE_ANIMATED_SHAPES)); | |
| 39 | 40 | demo.AddExample(Example("bubble-effect.example", DALI_DEMO_STR_TITLE_BUBBLES)); |
| 40 | 41 | demo.AddExample(Example("blocks.example", DALI_DEMO_STR_TITLE_BLOCKS)); |
| 41 | 42 | demo.AddExample(Example("cube-transition-effect.example", DALI_DEMO_STR_TITLE_CUBE_TRANSITION)); | ... | ... |
demo/dali-table-view.cpp
| ... | ... | @@ -45,12 +45,15 @@ const std::string TILE_BACKGROUND(DEMO_IMAGE_DIR "item-background.9.png"); |
| 45 | 45 | const std::string TILE_BACKGROUND_ALPHA( DEMO_IMAGE_DIR "demo-tile-texture.9.png" ); |
| 46 | 46 | const std::string TILE_FOCUS( DEMO_IMAGE_DIR "tile-focus.9.png" ); |
| 47 | 47 | |
| 48 | -// Keyboard focus constants. | |
| 48 | +// Keyboard focus effect constants. | |
| 49 | 49 | const float KEYBOARD_FOCUS_ANIMATION_DURATION = 1.0f; ///< The total duration of the keyboard focus animation |
| 50 | 50 | const float KEYBOARD_FOCUS_START_SCALE = 1.05f; ///< The starting scale of the focus highlight |
| 51 | 51 | const float KEYBOARD_FOCUS_END_SCALE = 1.18f; ///< The end scale of the focus highlight |
| 52 | 52 | const float KEYBOARD_FOCUS_END_ALPHA = 0.7f; ///< The end alpha of the focus highlight |
| 53 | 53 | const float KEYBOARD_FOCUS_INITIAL_FADE_PERCENTAGE = 0.16f; ///< The duration of the initial fade (from translucent to the end-alpha) as a percentage of the overal animation duration. |
| 54 | +const Vector3 startScale( KEYBOARD_FOCUS_START_SCALE, KEYBOARD_FOCUS_START_SCALE, KEYBOARD_FOCUS_START_SCALE ); ///< @see KEYBOARD_FOCUS_START_SCALE | |
| 55 | +const Vector3 endScale( KEYBOARD_FOCUS_END_SCALE, KEYBOARD_FOCUS_END_SCALE, KEYBOARD_FOCUS_END_SCALE ); ///< @see KEYBOARD_FOCUS_END_SCALE | |
| 56 | +const float initialFadeDuration = KEYBOARD_FOCUS_ANIMATION_DURATION * KEYBOARD_FOCUS_INITIAL_FADE_PERCENTAGE; ///< @see KEYBOARD_FOCUS_INITIAL_FADE_PERCENTAGE | |
| 54 | 57 | |
| 55 | 58 | const float TILE_LABEL_PADDING = 8.0f; ///< Border between edge of tile and the example text |
| 56 | 59 | const float BUTTON_PRESS_ANIMATION_TIME = 0.35f; ///< Time to perform button scale effect. |
| ... | ... | @@ -260,6 +263,9 @@ void DaliTableView::Initialize( Application& application ) |
| 260 | 263 | logo.SetAnchorPoint( AnchorPoint::TOP_CENTER ); |
| 261 | 264 | logo.SetParentOrigin( Vector3( 0.5f, 0.1f, 0.5f ) ); |
| 262 | 265 | logo.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS ); |
| 266 | + // The logo should appear on top of everything. | |
| 267 | + logo.SetDrawMode( DrawMode::OVERLAY_2D ); | |
| 268 | + mRootActor.Add( logo ); | |
| 263 | 269 | |
| 264 | 270 | // Show version in a popup when log is tapped |
| 265 | 271 | mLogoTapDetector = TapGestureDetector::New(); |
| ... | ... | @@ -291,9 +297,6 @@ void DaliTableView::Initialize( Application& application ) |
| 291 | 297 | bubbleContainer.SetParentOrigin( ParentOrigin::CENTER ); |
| 292 | 298 | SetupBackground( bubbleContainer ); |
| 293 | 299 | |
| 294 | - mRootActor.Add( logo ); | |
| 295 | - // We use depth index to bring the logo above the bubbles (as an alternative to creating actors). | |
| 296 | - logo.GetRendererAt( 0 ).SetProperty( Renderer::Property::DEPTH_INDEX, 30000 ); | |
| 297 | 300 | mRootActor.Add( bubbleContainer ); |
| 298 | 301 | mRootActor.Add( mScrollView ); |
| 299 | 302 | |
| ... | ... | @@ -324,64 +327,50 @@ void DaliTableView::Initialize( Application& application ) |
| 324 | 327 | mAnimationTimer.Start(); |
| 325 | 328 | mBackgroundAnimsPlaying = true; |
| 326 | 329 | |
| 330 | + CreateFocusEffect(); | |
| 331 | +} | |
| 332 | + | |
| 333 | +void DaliTableView::CreateFocusEffect() | |
| 334 | +{ | |
| 335 | + // Hook the required signals to manage the focus. | |
| 327 | 336 | KeyboardFocusManager::Get().PreFocusChangeSignal().Connect( this, &DaliTableView::OnKeyboardPreFocusChange ); |
| 328 | 337 | KeyboardFocusManager::Get().FocusedActorEnterKeySignal().Connect( this, &DaliTableView::OnFocusedActorActivated ); |
| 329 | 338 | AccessibilityManager::Get().FocusedActorActivatedSignal().Connect( this, &DaliTableView::OnFocusedActorActivated ); |
| 330 | 339 | |
| 331 | - mFocusContainer = ImageView::New( TILE_FOCUS ); | |
| 332 | - mFocusContainer.SetParentOrigin( ParentOrigin::CENTER ); | |
| 333 | - mFocusContainer.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); | |
| 334 | - mFocusContainer.SetInheritScale( false ); | |
| 335 | - mFocusContainer.SetColorMode( USE_OWN_COLOR ); | |
| 336 | - mFocusContainer.SetName( "focusActor" ); | |
| 337 | - mFocusContainer.OnStageSignal().Connect( this, &DaliTableView::OnStageConnect ); | |
| 338 | - | |
| 339 | - mFocusInner = ImageView::New( TILE_FOCUS ); | |
| 340 | - mFocusInner.SetParentOrigin( ParentOrigin::CENTER ); | |
| 341 | - mFocusInner.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); | |
| 342 | - mFocusInner.SetInheritScale( false ); | |
| 343 | - mFocusInner.SetColorMode( USE_OWN_COLOR ); | |
| 344 | - mFocusInner.SetName( "focusActor" ); | |
| 345 | - mFocusInner.OnStageSignal().Connect( this, &DaliTableView::OnStageConnect ); | |
| 346 | - mFocusContainer.Add( mFocusInner ); | |
| 347 | - | |
| 348 | - // Setup the keyboard focus highlight. | |
| 349 | - Vector3 startScale( KEYBOARD_FOCUS_START_SCALE, KEYBOARD_FOCUS_START_SCALE, KEYBOARD_FOCUS_START_SCALE ); | |
| 350 | - Vector3 endScale( KEYBOARD_FOCUS_END_SCALE, KEYBOARD_FOCUS_END_SCALE, KEYBOARD_FOCUS_END_SCALE ); | |
| 351 | - mFocusAnimation = Animation::New( KEYBOARD_FOCUS_ANIMATION_DURATION ); | |
| 352 | - mFocusAnimationInner = Animation::New( KEYBOARD_FOCUS_ANIMATION_DURATION ); | |
| 353 | - | |
| 354 | - mFocusContainer.SetScale( startScale ); | |
| 355 | - mFocusInner.SetScale( startScale ); | |
| 356 | - mFocusContainer.SetOpacity( 0.0f ); | |
| 357 | - mFocusInner.SetOpacity( 0.0f ); | |
| 358 | - const float initialFadeDuration = KEYBOARD_FOCUS_ANIMATION_DURATION * KEYBOARD_FOCUS_INITIAL_FADE_PERCENTAGE; | |
| 359 | - | |
| 360 | - mFocusAnimation.AnimateTo( Property( mFocusContainer, Actor::Property::COLOR_ALPHA ), KEYBOARD_FOCUS_END_ALPHA, AlphaFunction::LINEAR, TimePeriod( 0.0f, initialFadeDuration ) ); | |
| 361 | - mFocusAnimation.AnimateTo( Property( mFocusContainer, Actor::Property::SCALE ), endScale, AlphaFunction::LINEAR, TimePeriod( initialFadeDuration, KEYBOARD_FOCUS_ANIMATION_DURATION - initialFadeDuration ) ); | |
| 362 | - mFocusAnimation.AnimateTo( Property( mFocusContainer, Actor::Property::COLOR_ALPHA ), 0.0f, AlphaFunction::LINEAR, TimePeriod( initialFadeDuration, KEYBOARD_FOCUS_ANIMATION_DURATION - initialFadeDuration ) ); | |
| 363 | - | |
| 364 | - mFocusAnimationInner.AnimateTo( Property( mFocusInner, Actor::Property::COLOR_ALPHA ), KEYBOARD_FOCUS_END_ALPHA, AlphaFunction::LINEAR, TimePeriod( 0.0f, initialFadeDuration ) ); | |
| 365 | - mFocusAnimationInner.AnimateTo( Property( mFocusInner, Actor::Property::SCALE ), endScale, AlphaFunction::LINEAR, TimePeriod( initialFadeDuration, KEYBOARD_FOCUS_ANIMATION_DURATION - initialFadeDuration ) ); | |
| 366 | - mFocusAnimationInner.AnimateTo( Property( mFocusInner, Actor::Property::COLOR_ALPHA ), 0.0f, AlphaFunction::LINEAR, TimePeriod( initialFadeDuration, KEYBOARD_FOCUS_ANIMATION_DURATION - initialFadeDuration ) ); | |
| 340 | + // Loop to create both actors for the focus highlight effect. | |
| 341 | + for( unsigned int i = 0; i < FOCUS_ANIMATION_ACTOR_NUMBER; ++i ) | |
| 342 | + { | |
| 343 | + mFocusEffect[i].actor = ImageView::New( TILE_FOCUS ); | |
| 344 | + mFocusEffect[i].actor.SetParentOrigin( ParentOrigin::CENTER ); | |
| 345 | + mFocusEffect[i].actor.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); | |
| 346 | + mFocusEffect[i].actor.SetInheritScale( false ); | |
| 347 | + mFocusEffect[i].actor.SetColorMode( USE_OWN_COLOR ); | |
| 348 | + | |
| 349 | + // Setup initial values pre-animation. | |
| 350 | + mFocusEffect[i].actor.SetScale( startScale ); | |
| 351 | + mFocusEffect[i].actor.SetOpacity( 0.0f ); | |
| 352 | + | |
| 353 | + // Create and setup the animation to do the following: | |
| 354 | + // 1) Initial fade in over short period of time | |
| 355 | + // 2) Zoom in (larger) and fade out simultaneously over longer period of time. | |
| 356 | + mFocusEffect[i].animation = Animation::New( KEYBOARD_FOCUS_ANIMATION_DURATION ); | |
| 357 | + | |
| 358 | + mFocusEffect[i].animation.AnimateTo( Property( mFocusEffect[i].actor, Actor::Property::COLOR_ALPHA ), KEYBOARD_FOCUS_END_ALPHA, AlphaFunction::LINEAR, TimePeriod( 0.0f, initialFadeDuration ) ); | |
| 359 | + mFocusEffect[i].animation.AnimateTo( Property( mFocusEffect[i].actor, Actor::Property::SCALE ), endScale, AlphaFunction::LINEAR, TimePeriod( initialFadeDuration, KEYBOARD_FOCUS_ANIMATION_DURATION - initialFadeDuration ) ); | |
| 360 | + mFocusEffect[i].animation.AnimateTo( Property( mFocusEffect[i].actor, Actor::Property::COLOR_ALPHA ), 0.0f, AlphaFunction::LINEAR, TimePeriod( initialFadeDuration, KEYBOARD_FOCUS_ANIMATION_DURATION - initialFadeDuration ) ); | |
| 361 | + | |
| 362 | + mFocusEffect[i].animation.SetLooping( true ); | |
| 363 | + } | |
| 364 | + | |
| 365 | + // Parent the secondary effect from the primary. | |
| 366 | + mFocusEffect[0].actor.Add( mFocusEffect[1].actor ); | |
| 367 | 367 | |
| 368 | 368 | // Play the animation on the 1st glow object. |
| 369 | - mFocusAnimation.SetLooping( true ); | |
| 370 | - mFocusAnimation.Play(); | |
| 369 | + mFocusEffect[0].animation.Play(); | |
| 371 | 370 | // Stagger the animation on the 2st glow object half way through. |
| 372 | - mFocusAnimationInner.SetLooping( true ); | |
| 373 | - mFocusAnimationInner.PlayFrom( KEYBOARD_FOCUS_ANIMATION_DURATION / 2.0f ); | |
| 371 | + mFocusEffect[1].animation.PlayFrom( KEYBOARD_FOCUS_ANIMATION_DURATION / 2.0f ); | |
| 374 | 372 | |
| 375 | - KeyboardFocusManager::Get().SetFocusIndicatorActor( mFocusContainer ); | |
| 376 | -} | |
| 377 | - | |
| 378 | -void DaliTableView::OnStageConnect( Dali::Actor actor ) | |
| 379 | -{ | |
| 380 | - // If this is one of the keyboard focus actors, place it behind the object it is focusing. | |
| 381 | - if( actor.GetName() == "focusActor" ) | |
| 382 | - { | |
| 383 | - actor.GetRendererAt( 0 ).SetProperty( Dali::Renderer::Property::DEPTH_INDEX, -40000 ); | |
| 384 | - } | |
| 373 | + KeyboardFocusManager::Get().SetFocusIndicatorActor( mFocusEffect[0].actor ); | |
| 385 | 374 | } |
| 386 | 375 | |
| 387 | 376 | void DaliTableView::ApplyCubeEffectToPages() |
| ... | ... | @@ -510,12 +499,14 @@ void DaliTableView::Rotate( unsigned int degrees ) |
| 510 | 499 | |
| 511 | 500 | Actor DaliTableView::CreateTile( const std::string& name, const std::string& title, const Dali::Vector3& sizeMultiplier, Vector2& position ) |
| 512 | 501 | { |
| 513 | - Actor content = Actor::New(); | |
| 514 | - content.SetName( name ); | |
| 515 | - content.SetAnchorPoint( AnchorPoint::CENTER ); | |
| 516 | - content.SetParentOrigin( ParentOrigin::CENTER ); | |
| 517 | - content.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS ); | |
| 518 | - content.SetSizeModeFactor( sizeMultiplier ); | |
| 502 | + Actor focusableTile = Actor::New(); | |
| 503 | + focusableTile.SetParentOrigin( ParentOrigin::CENTER ); | |
| 504 | + focusableTile.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS ); | |
| 505 | + focusableTile.SetSizeModeFactor( sizeMultiplier ); | |
| 506 | + focusableTile.SetName( name ); | |
| 507 | + | |
| 508 | + // Set the tile to be keyboard focusable | |
| 509 | + focusableTile.SetKeyboardFocusable( true ); | |
| 519 | 510 | |
| 520 | 511 | Toolkit::ImageView tileContent = ImageView::New(); |
| 521 | 512 | tileContent.SetParentOrigin( ParentOrigin::CENTER ); |
| ... | ... | @@ -542,7 +533,7 @@ Actor DaliTableView::CreateTile( const std::string& name, const std::string& tit |
| 542 | 533 | shaderPosition.AddSource( Source( mScrollView, ScrollView::Property::SCROLL_POSITION ) ); |
| 543 | 534 | shaderPosition.SetRemoveAction( Constraint::Discard ); |
| 544 | 535 | shaderPosition.Apply(); |
| 545 | - content.Add( tileContent ); | |
| 536 | + focusableTile.Add( tileContent ); | |
| 546 | 537 | |
| 547 | 538 | // Create an ImageView for the 9-patch border around the tile. |
| 548 | 539 | ImageView borderImage = ImageView::New( TILE_BACKGROUND ); |
| ... | ... | @@ -564,16 +555,13 @@ Actor DaliTableView::CreateTile( const std::string& name, const std::string& tit |
| 564 | 555 | |
| 565 | 556 | // Pad around the label as its size is the same as the 9-patch border. It will overlap it without padding. |
| 566 | 557 | label.SetPadding( Padding( TILE_LABEL_PADDING, TILE_LABEL_PADDING, TILE_LABEL_PADDING, TILE_LABEL_PADDING ) ); |
| 567 | - content.Add( label ); | |
| 568 | - | |
| 569 | - // Set the tile to be keyboard focusable | |
| 570 | - content.SetKeyboardFocusable( true ); | |
| 558 | + focusableTile.Add( label ); | |
| 571 | 559 | |
| 572 | - // connect to the touch events | |
| 573 | - content.TouchSignal().Connect( this, &DaliTableView::OnTilePressed ); | |
| 574 | - content.HoveredSignal().Connect( this, &DaliTableView::OnTileHovered ); | |
| 560 | + // Connect to the touch events | |
| 561 | + focusableTile.TouchSignal().Connect( this, &DaliTableView::OnTilePressed ); | |
| 562 | + focusableTile.HoveredSignal().Connect( this, &DaliTableView::OnTileHovered ); | |
| 575 | 563 | |
| 576 | - return content; | |
| 564 | + return focusableTile; | |
| 577 | 565 | } |
| 578 | 566 | |
| 579 | 567 | bool DaliTableView::OnTilePressed( Actor actor, const TouchData& event ) | ... | ... |
demo/dali-table-view.h
| 1 | -#ifndef __DALI_DEMO_H__ | |
| 2 | -#define __DALI_DEMO_H__ | |
| 1 | +#ifndef DALI_DEMO_H | |
| 2 | +#define DALI_DEMO_H | |
| 3 | 3 | |
| 4 | 4 | /* |
| 5 | - * Copyright (c) 2015 Samsung Electronics Co., Ltd. | |
| 5 | + * Copyright (c) 2016 Samsung Electronics Co., Ltd. | |
| 6 | 6 | * |
| 7 | 7 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 8 | 8 | * you may not use this file except in compliance with the License. |
| ... | ... | @@ -32,7 +32,6 @@ typedef std::vector<Dali::Animation> AnimationList; |
| 32 | 32 | typedef AnimationList::iterator AnimationListIter; |
| 33 | 33 | typedef AnimationList::const_iterator AnimationListConstIter; |
| 34 | 34 | |
| 35 | - | |
| 36 | 35 | /** |
| 37 | 36 | * Example information |
| 38 | 37 | * |
| ... | ... | @@ -97,6 +96,8 @@ public: |
| 97 | 96 | |
| 98 | 97 | private: // Application callbacks & implementation |
| 99 | 98 | |
| 99 | + static const unsigned int FOCUS_ANIMATION_ACTOR_NUMBER = 2; ///< The number of elements used to form the custom focus effect | |
| 100 | + | |
| 100 | 101 | /** |
| 101 | 102 | * Shape enum for create function |
| 102 | 103 | */ |
| ... | ... | @@ -320,6 +321,11 @@ private: // Application callbacks & implementation |
| 320 | 321 | void PlayAnimation(); |
| 321 | 322 | |
| 322 | 323 | /** |
| 324 | + * @brief Creates and sets up the custom effect used for the keyboard (and mouse) focus. | |
| 325 | + */ | |
| 326 | + void CreateFocusEffect(); | |
| 327 | + | |
| 328 | + /** | |
| 323 | 329 | * Callback when the keyboard focus is going to be changed. |
| 324 | 330 | * |
| 325 | 331 | * @param[in] current The current focused actor |
| ... | ... | @@ -384,10 +390,15 @@ private: |
| 384 | 390 | Dali::TapGestureDetector mLogoTapDetector; ///< To detect taps on the logo |
| 385 | 391 | Dali::Toolkit::Popup mVersionPopup; ///< Displays DALi library version information |
| 386 | 392 | |
| 387 | - Dali::Toolkit::ImageView mFocusContainer; ///< The parent keyboard focus highlight actor | |
| 388 | - Dali::Toolkit::ImageView mFocusInner; ///< The child keyboard focus highlight actor | |
| 389 | - Dali::Animation mFocusAnimation; ///< The animation for the parent keyboard focus highlight actor | |
| 390 | - Dali::Animation mFocusAnimationInner; ///< The animation for the child keyboard focus highlight actor | |
| 393 | + /** | |
| 394 | + * This struct encapsulates all data relevant to each of the elements used within the custom keyboard focus effect. | |
| 395 | + */ | |
| 396 | + struct FocusEffect | |
| 397 | + { | |
| 398 | + Dali::Toolkit::ImageView actor; ///< The parent keyboard focus highlight actor | |
| 399 | + Dali::Animation animation; ///< The animation for the parent keyboard focus highlight actor | |
| 400 | + }; | |
| 401 | + FocusEffect mFocusEffect[FOCUS_ANIMATION_ACTOR_NUMBER]; ///< The elements used to create the custom focus effect | |
| 391 | 402 | |
| 392 | 403 | std::vector< Dali::Actor > mPages; ///< List of pages. |
| 393 | 404 | AnimationList mBackgroundAnimations; ///< List of background bubble animations |
| ... | ... | @@ -402,4 +413,4 @@ private: |
| 402 | 413 | |
| 403 | 414 | }; |
| 404 | 415 | |
| 405 | -#endif // __DALI_DEMO_H__ | |
| 416 | +#endif // DALI_DEMO_H | ... | ... |
examples/animated-shapes/animated-shapes-example.cpp
0 → 100644
| 1 | +/* | |
| 2 | + * Copyright (c) 2016 Samsung Electronics Co., Ltd. | |
| 3 | + * | |
| 4 | + * Licensed under the Apache License, Version 2.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://www.apache.org/licenses/LICENSE-2.0 | |
| 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 | + | |
| 18 | +#include <dali/dali.h> | |
| 19 | +#include <dali-toolkit/dali-toolkit.h> | |
| 20 | +#include "shared/view.h" | |
| 21 | + | |
| 22 | +#include <sstream> | |
| 23 | + | |
| 24 | +using namespace Dali; | |
| 25 | +using namespace Dali::Toolkit; | |
| 26 | + | |
| 27 | +namespace | |
| 28 | +{ | |
| 29 | + | |
| 30 | +const char* APPLICATION_TITLE("Animated Shapes"); | |
| 31 | + | |
| 32 | +const char* VERTEX_SHADER = DALI_COMPOSE_SHADER | |
| 33 | +( | |
| 34 | + attribute mediump vec3 aCoefficient; | |
| 35 | + uniform mediump mat4 uMvpMatrix; | |
| 36 | + uniform mediump vec3 uPosition[MAX_POINT_COUNT]; | |
| 37 | + varying lowp vec2 vCoefficient; | |
| 38 | + void main() | |
| 39 | + { | |
| 40 | + int vertexId = int(aCoefficient.z); | |
| 41 | + gl_Position = uMvpMatrix * vec4(uPosition[vertexId], 1.0); | |
| 42 | + | |
| 43 | + vCoefficient = aCoefficient.xy; | |
| 44 | + } | |
| 45 | +); | |
| 46 | + | |
| 47 | +// Fragment shader. | |
| 48 | +const char* FRAGMENT_SHADER = DALI_COMPOSE_SHADER | |
| 49 | +( | |
| 50 | + uniform lowp vec4 uColor; | |
| 51 | + varying lowp vec2 vCoefficient; | |
| 52 | + void main() | |
| 53 | + { | |
| 54 | + lowp float C = (vCoefficient.x*vCoefficient.x-vCoefficient.y); | |
| 55 | + lowp float Cdx = dFdx(C); | |
| 56 | + lowp float Cdy = dFdy(C); | |
| 57 | + | |
| 58 | + lowp float distance = float(C / sqrt(Cdx*Cdx + Cdy*Cdy)); | |
| 59 | + lowp float alpha = 0.5 - distance; | |
| 60 | + gl_FragColor = vec4( uColor.rgb, uColor.a * alpha ); | |
| 61 | + } | |
| 62 | +); | |
| 63 | + | |
| 64 | +Shader CreateShader( unsigned int pointCount ) | |
| 65 | +{ | |
| 66 | + std::ostringstream vertexShader; | |
| 67 | + vertexShader << "#define MAX_POINT_COUNT "<< pointCount << "\n"<<VERTEX_SHADER; | |
| 68 | + | |
| 69 | + std::ostringstream fragmentShader; | |
| 70 | + fragmentShader << "#extension GL_OES_standard_derivatives : enable "<< "\n"<<FRAGMENT_SHADER; | |
| 71 | + | |
| 72 | + Shader shader = Shader::New( vertexShader.str(), fragmentShader.str() ); | |
| 73 | + for( unsigned int i(0); i<pointCount; ++i ) | |
| 74 | + { | |
| 75 | + std::ostringstream propertyName; | |
| 76 | + propertyName << "uPosition["<<i<<"]"; | |
| 77 | + shader.RegisterProperty(propertyName.str(),Vector3(0.0f,0.0f,0.0f) ); | |
| 78 | + } | |
| 79 | + | |
| 80 | + return shader; | |
| 81 | +} | |
| 82 | + | |
| 83 | +} //unnamed namespace | |
| 84 | + | |
| 85 | +// This example shows resolution independent rendering and animation of curves using the gpu. | |
| 86 | +// | |
| 87 | +class AnimatedShapesExample : public ConnectionTracker | |
| 88 | +{ | |
| 89 | +public: | |
| 90 | + | |
| 91 | + AnimatedShapesExample( Application& application ) | |
| 92 | +: mApplication( application ) | |
| 93 | +{ | |
| 94 | + // Connect to the Application's Init signal | |
| 95 | + mApplication.InitSignal().Connect( this, &AnimatedShapesExample::Create ); | |
| 96 | +} | |
| 97 | + | |
| 98 | + ~AnimatedShapesExample() | |
| 99 | + { | |
| 100 | + // Nothing to do here; | |
| 101 | + } | |
| 102 | + | |
| 103 | + // The Init signal is received once (only) during the Application lifetime | |
| 104 | + void Create( Application& application ) | |
| 105 | + { | |
| 106 | + // Hide the indicator bar | |
| 107 | + application.GetWindow().ShowIndicator( Dali::Window::INVISIBLE ); | |
| 108 | + | |
| 109 | + Stage stage = Stage::GetCurrent(); | |
| 110 | + | |
| 111 | + // Creates the background gradient | |
| 112 | + Toolkit::Control background = Dali::Toolkit::Control::New(); | |
| 113 | + background.SetAnchorPoint( Dali::AnchorPoint::CENTER ); | |
| 114 | + background.SetParentOrigin( Dali::ParentOrigin::CENTER ); | |
| 115 | + background.SetResizePolicy( Dali::ResizePolicy::FILL_TO_PARENT, Dali::Dimension::ALL_DIMENSIONS ); | |
| 116 | + Dali::Property::Map map; | |
| 117 | + map.Insert( Visual::Property::TYPE, Visual::GRADIENT ); | |
| 118 | + Property::Array stopOffsets; | |
| 119 | + stopOffsets.PushBack( 0.0f ); | |
| 120 | + stopOffsets.PushBack( 1.0f ); | |
| 121 | + map.Insert( GradientVisual::Property::STOP_OFFSET, stopOffsets ); | |
| 122 | + Property::Array stopColors; | |
| 123 | + stopColors.PushBack( Vector4( 0.0f,0.0f,1.0f,1.0f ) ); | |
| 124 | + stopColors.PushBack( Vector4( 1.0f,1.0f,1.0f,1.0f ) ); | |
| 125 | + map.Insert( GradientVisual::Property::STOP_COLOR, stopColors ); | |
| 126 | + Vector2 halfStageSize = Stage::GetCurrent().GetSize()*0.5f; | |
| 127 | + map.Insert( GradientVisual::Property::START_POSITION, Vector2(0.0f,-halfStageSize.y) ); | |
| 128 | + map.Insert( GradientVisual::Property::END_POSITION, Vector2(0.0f,halfStageSize.y) ); | |
| 129 | + map.Insert( GradientVisual::Property::UNITS, GradientVisual::Units::USER_SPACE ); | |
| 130 | + background.SetProperty( Dali::Toolkit::Control::Property::BACKGROUND, map ); | |
| 131 | + stage.Add( background ); | |
| 132 | + | |
| 133 | + // Create a TextLabel for the application title. | |
| 134 | + Toolkit::TextLabel label = Toolkit::TextLabel::New( APPLICATION_TITLE ); | |
| 135 | + label.SetAnchorPoint( AnchorPoint::TOP_CENTER ); | |
| 136 | + label.SetParentOrigin( Vector3( 0.5f, 0.0f, 0.5f ) ); | |
| 137 | + label.SetProperty( Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" ); | |
| 138 | + label.SetProperty( Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" ); | |
| 139 | + label.SetProperty( Toolkit::TextLabel::Property::TEXT_COLOR, Vector4( 1.0f, 1.0f, 1.0f, 1.0f ) ); | |
| 140 | + stage.Add( label ); | |
| 141 | + | |
| 142 | + CreateTriangleMorph(Vector3( stage.GetSize().x*0.5f, stage.GetSize().y*0.15f, 0.0f), 100.0f ); | |
| 143 | + CreateCircleMorph( Vector3( stage.GetSize().x*0.5f, stage.GetSize().y*0.5f, 0.0f), 55.0f ); | |
| 144 | + CreateQuadMorph( Vector3( stage.GetSize().x*0.5f, stage.GetSize().y*0.85f, 0.0f), 60.0f ); | |
| 145 | + | |
| 146 | + stage.KeyEventSignal().Connect( this, &AnimatedShapesExample::OnKeyEvent ); | |
| 147 | + } | |
| 148 | + | |
| 149 | + void CreateTriangleMorph( Vector3 center, float side ) | |
| 150 | + { | |
| 151 | + float h = ( side *0.5f ) / 0.866f; | |
| 152 | + | |
| 153 | + Vector3 v0 = Vector3( -h, h, 0.0f ); | |
| 154 | + Vector3 v1 = Vector3( 0.0f, -side * 0.366f, 0.0f ); | |
| 155 | + Vector3 v2 = Vector3( h, h, 0.0f ); | |
| 156 | + | |
| 157 | + Vector3 v3 = v0 + ( ( v1 - v0 ) * 0.5f ); | |
| 158 | + Vector3 v4 = v1 + ( ( v2 - v1 ) * 0.5f ); | |
| 159 | + Vector3 v5 = v2 + ( ( v0 - v2 ) * 0.5f ); | |
| 160 | + | |
| 161 | + Shader shader = CreateShader( 12 ); | |
| 162 | + shader.SetProperty( shader.GetPropertyIndex( "uPosition[0]"), v0 ); | |
| 163 | + shader.SetProperty( shader.GetPropertyIndex( "uPosition[1]"), v3 ); | |
| 164 | + shader.SetProperty( shader.GetPropertyIndex( "uPosition[2]"), v1 ); | |
| 165 | + | |
| 166 | + shader.SetProperty( shader.GetPropertyIndex( "uPosition[3]"), v1 ); | |
| 167 | + shader.SetProperty( shader.GetPropertyIndex( "uPosition[4]"), v4 ); | |
| 168 | + shader.SetProperty( shader.GetPropertyIndex( "uPosition[5]"), v2 ); | |
| 169 | + | |
| 170 | + shader.SetProperty( shader.GetPropertyIndex( "uPosition[6]"), v2 ); | |
| 171 | + shader.SetProperty( shader.GetPropertyIndex( "uPosition[7]"), v5 ); | |
| 172 | + shader.SetProperty( shader.GetPropertyIndex( "uPosition[8]"), v0 ); | |
| 173 | + | |
| 174 | + shader.SetProperty( shader.GetPropertyIndex( "uPosition[9]"), v0 ); | |
| 175 | + shader.SetProperty( shader.GetPropertyIndex( "uPosition[10]"), v1 ); | |
| 176 | + shader.SetProperty( shader.GetPropertyIndex( "uPosition[11]"), v2 ); | |
| 177 | + | |
| 178 | + | |
| 179 | + //Create geometry | |
| 180 | + static const Vector3 vertexData[] = { Dali::Vector3( 0.0f, 0.0f, 0.0f ), | |
| 181 | + Dali::Vector3( 0.5f, 0.0f, 1.0f ), | |
| 182 | + Dali::Vector3( 1.0f, 1.0f, 2.0f ), | |
| 183 | + | |
| 184 | + Dali::Vector3( 0.0f, 0.0f, 3.0f ), | |
| 185 | + Dali::Vector3( 0.5f, 0.0f, 4.0f ), | |
| 186 | + Dali::Vector3( 1.0f, 1.0f, 5.0f ), | |
| 187 | + | |
| 188 | + Dali::Vector3( 0.0f, 0.0f, 6.0f ), | |
| 189 | + Dali::Vector3( 0.5f, 0.0f, 7.0f ), | |
| 190 | + Dali::Vector3( 1.0f, 1.0f, 8.0f ), | |
| 191 | + | |
| 192 | + Dali::Vector3( 0.0f, 1.0f, 9.0f ), | |
| 193 | + Dali::Vector3( 0.0f, 1.0f, 10.0f ), | |
| 194 | + Dali::Vector3( 0.0f, 1.0f, 11.0f ) | |
| 195 | + }; | |
| 196 | + | |
| 197 | + unsigned short indexData[] = { 0, 2, 1, 3, 5, 4, 6, 8, 7, 9, 11, 10 }; | |
| 198 | + | |
| 199 | + //Create a vertex buffer for vertex positions and texture coordinates | |
| 200 | + Dali::Property::Map vertexFormat; | |
| 201 | + vertexFormat["aCoefficient"] = Dali::Property::VECTOR3; | |
| 202 | + Dali::PropertyBuffer vertexBuffer = Dali::PropertyBuffer::New( vertexFormat ); | |
| 203 | + vertexBuffer.SetData( vertexData, sizeof(vertexData)/sizeof(vertexData[0])); | |
| 204 | + | |
| 205 | + //Create the geometry | |
| 206 | + Dali::Geometry geometry = Dali::Geometry::New(); | |
| 207 | + geometry.AddVertexBuffer( vertexBuffer ); | |
| 208 | + geometry.SetIndexBuffer( indexData, sizeof(indexData)/sizeof(indexData[0]) ); | |
| 209 | + | |
| 210 | + Renderer renderer = Renderer::New( geometry, shader ); | |
| 211 | + renderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::ON ); | |
| 212 | + | |
| 213 | + Actor actor = Actor::New(); | |
| 214 | + actor.SetSize( 400.0f, 400.0f ); | |
| 215 | + actor.SetPosition( center ); | |
| 216 | + actor.SetAnchorPoint( AnchorPoint::CENTER ); | |
| 217 | + actor.SetColor(Vector4(1.0f,1.0f,0.0f,1.0f) ); | |
| 218 | + actor.AddRenderer( renderer ); | |
| 219 | + | |
| 220 | + Stage stage = Stage::GetCurrent(); | |
| 221 | + stage.Add( actor ); | |
| 222 | + | |
| 223 | + //Animation | |
| 224 | + Animation animation = Animation::New(5.0f); | |
| 225 | + KeyFrames k0 = KeyFrames::New(); | |
| 226 | + k0.Add( 0.0f,v3 ); | |
| 227 | + k0.Add( 0.5f, v3 + Vector3(-150.0f,-150.0f,0.0f)); | |
| 228 | + k0.Add( 1.0f, v3 ); | |
| 229 | + animation.AnimateBetween( Property(shader, "uPosition[1]"),k0, AlphaFunction::EASE_IN_OUT_SINE ); | |
| 230 | + | |
| 231 | + k0 = KeyFrames::New(); | |
| 232 | + k0.Add( 0.0f,v4 ); | |
| 233 | + k0.Add( 0.5f, v4 + Vector3(150.0f,-150.0f,0.0f)); | |
| 234 | + k0.Add( 1.0f, v4 ); | |
| 235 | + animation.AnimateBetween( Property(shader,"uPosition[4]"),k0, AlphaFunction::EASE_IN_OUT_SINE ); | |
| 236 | + | |
| 237 | + k0 = KeyFrames::New(); | |
| 238 | + k0.Add( 0.0f,v5 ); | |
| 239 | + k0.Add( 0.5f, v5 + Vector3(0.0,150.0f,0.0f)); | |
| 240 | + k0.Add( 1.0f, v5 ); | |
| 241 | + animation.AnimateBetween( Property(shader, "uPosition[7]"),k0, AlphaFunction::EASE_IN_OUT_SINE ); | |
| 242 | + animation.SetLooping( true ); | |
| 243 | + animation.Play(); | |
| 244 | + } | |
| 245 | + | |
| 246 | + void CreateCircleMorph( Vector3 center, float radius ) | |
| 247 | + { | |
| 248 | + Shader shader = CreateShader( 16 ); | |
| 249 | + shader.SetProperty( shader.GetPropertyIndex("uPosition[0]"), Vector3( -radius, -radius, 0.0f ) ); | |
| 250 | + shader.SetProperty( shader.GetPropertyIndex("uPosition[1]"), Vector3( 0.0f, -radius, 0.0f ) ); | |
| 251 | + shader.SetProperty( shader.GetPropertyIndex("uPosition[2]"), Vector3( radius, -radius, 0.0f ) ); | |
| 252 | + | |
| 253 | + shader.SetProperty( shader.GetPropertyIndex("uPosition[3]"), Vector3( radius, -radius, 0.0f ) ); | |
| 254 | + shader.SetProperty( shader.GetPropertyIndex("uPosition[4]"), Vector3( radius, 0.0f, 0.0f ) ); | |
| 255 | + shader.SetProperty( shader.GetPropertyIndex("uPosition[5]"), Vector3( radius, radius, 0.0f ) ); | |
| 256 | + | |
| 257 | + shader.SetProperty( shader.GetPropertyIndex("uPosition[6]"), Vector3( radius, radius, 0.0f ) ); | |
| 258 | + shader.SetProperty( shader.GetPropertyIndex("uPosition[7]"), Vector3( 0.0f, radius, 0.0f ) ); | |
| 259 | + shader.SetProperty( shader.GetPropertyIndex("uPosition[8]"), Vector3( -radius, radius, 0.0f ) ); | |
| 260 | + | |
| 261 | + shader.SetProperty( shader.GetPropertyIndex("uPosition[9]"), Vector3( -radius, radius, 0.0f ) ); | |
| 262 | + shader.SetProperty( shader.GetPropertyIndex("uPosition[10]"), Vector3( -radius, 0.0f, 0.0f ) ); | |
| 263 | + shader.SetProperty( shader.GetPropertyIndex("uPosition[11]"), Vector3( -radius, -radius, 0.0f ) ); | |
| 264 | + | |
| 265 | + shader.SetProperty( shader.GetPropertyIndex("uPosition[12]"), Vector3( -radius, -radius, 0.0f ) ); | |
| 266 | + shader.SetProperty( shader.GetPropertyIndex("uPosition[13]"), Vector3( radius, -radius, 0.0f ) ); | |
| 267 | + shader.SetProperty( shader.GetPropertyIndex("uPosition[14]"), Vector3( radius, radius, 0.0f ) ); | |
| 268 | + shader.SetProperty( shader.GetPropertyIndex("uPosition[15]"), Vector3( -radius, radius, 0.0f ) ); | |
| 269 | + | |
| 270 | + //shader.SetProperty( shader.GetPropertyIndex("uLineWidth"), 2.0f ); | |
| 271 | + | |
| 272 | + static const Vector3 vertexData[] = { Vector3( 0.0f, 0.0f, 0.0f ), | |
| 273 | + Vector3( 0.5f, 0.0f, 1.0f ), | |
| 274 | + Vector3( 1.0f, 1.0f, 2.0f ), | |
| 275 | + Vector3( 0.0f, 0.0f, 3.0f ), | |
| 276 | + Vector3( 0.5f, 0.0f, 4.0f ), | |
| 277 | + Vector3( 1.0f, 1.0f, 5.0f ), | |
| 278 | + Vector3( 0.0f, 0.0f, 6.0f ), | |
| 279 | + Vector3( 0.5f, 0.0f, 7.0f ), | |
| 280 | + Vector3( 1.0f, 1.0f, 8.0f ), | |
| 281 | + Vector3( 0.0f, 0.0f, 9.0f ), | |
| 282 | + Vector3( 0.5f, 0.0f, 10.0f ), | |
| 283 | + Vector3( 1.0f, 1.0f, 11.0f ), | |
| 284 | + Vector3( 0.0f, 1.0f, 12.0f ), | |
| 285 | + Vector3( 0.0f, 1.0f, 13.0f ), | |
| 286 | + Vector3( 0.0f, 1.0f, 14.0f ), | |
| 287 | + Vector3( 0.0f, 1.0f, 15.0f )}; | |
| 288 | + | |
| 289 | + short unsigned int indexData[] = { 0, 2, 1, 3, 5, 4, 6, 8, 7, 9, 11, 10, 12, 13, 14, 12, 14, 15 }; | |
| 290 | + | |
| 291 | + //Create a vertex buffer for vertex positions and texture coordinates | |
| 292 | + Dali::Property::Map vertexFormat; | |
| 293 | + vertexFormat["aCoefficient"] = Dali::Property::VECTOR3; | |
| 294 | + Dali::PropertyBuffer vertexBuffer = Dali::PropertyBuffer::New( vertexFormat ); | |
| 295 | + vertexBuffer.SetData( vertexData, sizeof(vertexData)/sizeof(vertexData[0])); | |
| 296 | + | |
| 297 | + //Create the geometry | |
| 298 | + Dali::Geometry geometry = Dali::Geometry::New(); | |
| 299 | + geometry.AddVertexBuffer( vertexBuffer ); | |
| 300 | + geometry.SetIndexBuffer( indexData, sizeof(indexData)/sizeof(indexData[0]) ); | |
| 301 | + | |
| 302 | + Renderer renderer = Renderer::New( geometry, shader ); | |
| 303 | + renderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::ON ); | |
| 304 | + | |
| 305 | + Actor actor = Actor::New(); | |
| 306 | + actor.SetSize( 400.0f, 400.0f ); | |
| 307 | + actor.SetPosition( center ); | |
| 308 | + actor.SetAnchorPoint( AnchorPoint::CENTER ); | |
| 309 | + actor.AddRenderer( renderer ); | |
| 310 | + | |
| 311 | + Stage stage = Stage::GetCurrent(); | |
| 312 | + stage.Add( actor ); | |
| 313 | + | |
| 314 | + //Animation | |
| 315 | + Animation animation = Animation::New(5.0f); | |
| 316 | + KeyFrames k0 = KeyFrames::New(); | |
| 317 | + k0.Add( 0.0f, Vector3( 0.0f,-radius*1.85, 0.0f ) ); | |
| 318 | + k0.Add( 0.5f, Vector3( -radius*1.85, -radius*3.0f, 0.0f ) ); | |
| 319 | + k0.Add( 1.0f, Vector3( 0.0f,-radius*1.85, 0.0f ) ); | |
| 320 | + animation.AnimateBetween( Property( shader, shader.GetPropertyIndex("uPosition[1]") ),k0, AlphaFunction::EASE_IN_OUT_SINE ); | |
| 321 | + | |
| 322 | + k0 = KeyFrames::New(); | |
| 323 | + k0.Add( 0.0f, Vector3( radius*1.85, 0.0f, 0.0f ) ); | |
| 324 | + k0.Add( 0.5f, Vector3( radius*3.0f,-radius*1.85, 0.0f ) ); | |
| 325 | + k0.Add( 1.0f, Vector3( radius*1.85,0.0f, 0.0f ) ); | |
| 326 | + animation.AnimateBetween( Property(shader, shader.GetPropertyIndex("uPosition[4]")),k0, AlphaFunction::EASE_IN_OUT_SINE ); | |
| 327 | + | |
| 328 | + k0 = KeyFrames::New(); | |
| 329 | + k0.Add( 0.0f, Vector3( 0.0f, radius*1.85, 0.0f ) ); | |
| 330 | + k0.Add( 0.5f, Vector3( radius*1.85, radius*3.0f, 0.0f) ); | |
| 331 | + k0.Add( 1.0f, Vector3( 0.0f, radius*1.85, 0.0f) ); | |
| 332 | + animation.AnimateBetween( Property( shader, shader.GetPropertyIndex("uPosition[7]") ),k0, AlphaFunction::EASE_IN_OUT_SINE ); | |
| 333 | + | |
| 334 | + k0 = KeyFrames::New(); | |
| 335 | + k0.Add( 0.0f, Vector3( -radius*1.85, 0.0f, 0.0f) ); | |
| 336 | + k0.Add( 0.5f, Vector3(-radius*3.0f, radius*1.85, 0.0f) ); | |
| 337 | + k0.Add( 1.0f, Vector3( -radius*1.85, 0.0f, 0.0f) ); | |
| 338 | + animation.AnimateBetween( Property( shader, shader.GetPropertyIndex("uPosition[10]") ),k0, AlphaFunction::EASE_IN_OUT_SINE ); | |
| 339 | + | |
| 340 | + animation.AnimateBy( Property( actor, Actor::Property::ORIENTATION ), Quaternion( Radian( Degree(-90.0f) ), Vector3::ZAXIS ) ); | |
| 341 | + animation.SetLooping( true ); | |
| 342 | + animation.Play(); | |
| 343 | + } | |
| 344 | + | |
| 345 | + void CreateQuadMorph( Vector3 center, float radius ) | |
| 346 | + { | |
| 347 | + Shader shader = CreateShader( 16 ); | |
| 348 | + shader.SetProperty( shader.GetPropertyIndex("uPosition[0]"), Vector3( -radius, -radius, 0.0f ) ); | |
| 349 | + shader.SetProperty( shader.GetPropertyIndex("uPosition[1]"), Vector3( 0.0f, -radius, 0.0f ) ); | |
| 350 | + shader.SetProperty( shader.GetPropertyIndex("uPosition[2]"), Vector3( radius, -radius, 0.0f ) ); | |
| 351 | + | |
| 352 | + shader.SetProperty( shader.GetPropertyIndex("uPosition[3]"), Vector3( radius, -radius, 0.0f ) ); | |
| 353 | + shader.SetProperty( shader.GetPropertyIndex("uPosition[4]"), Vector3( radius, 0.0f, 0.0f ) ); | |
| 354 | + shader.SetProperty( shader.GetPropertyIndex("uPosition[5]"), Vector3( radius, radius, 0.0f ) ); | |
| 355 | + | |
| 356 | + shader.SetProperty( shader.GetPropertyIndex("uPosition[6]"), Vector3( radius, radius, 0.0f ) ); | |
| 357 | + shader.SetProperty( shader.GetPropertyIndex("uPosition[7]"), Vector3( 0.0f, radius, 0.0f ) ); | |
| 358 | + shader.SetProperty( shader.GetPropertyIndex("uPosition[8]"), Vector3( -radius, radius, 0.0f ) ); | |
| 359 | + | |
| 360 | + shader.SetProperty( shader.GetPropertyIndex("uPosition[9]"), Vector3( -radius, radius, 0.0f ) ); | |
| 361 | + shader.SetProperty( shader.GetPropertyIndex("uPosition[10]"), Vector3( -radius, 0.0f, 0.0f ) ); | |
| 362 | + shader.SetProperty( shader.GetPropertyIndex("uPosition[11]"), Vector3( -radius, -radius, 0.0f ) ); | |
| 363 | + | |
| 364 | + shader.SetProperty( shader.GetPropertyIndex("uPosition[12]"), Vector3( -radius, -radius, 0.0f ) ); | |
| 365 | + shader.SetProperty( shader.GetPropertyIndex("uPosition[13]"), Vector3( radius, -radius, 0.0f ) ); | |
| 366 | + shader.SetProperty( shader.GetPropertyIndex("uPosition[14]"), Vector3( radius, radius, 0.0f ) ); | |
| 367 | + shader.SetProperty( shader.GetPropertyIndex("uPosition[15]"), Vector3( -radius, radius, 0.0f ) ); | |
| 368 | + | |
| 369 | + static const Vector3 vertexData[] = { Dali::Vector3( 0.0f, 0.0f, 0.0f ), | |
| 370 | + Dali::Vector3( 0.5f, 0.0f, 1.0f ), | |
| 371 | + Dali::Vector3( 1.0f, 1.0f, 2.0f ), | |
| 372 | + | |
| 373 | + Dali::Vector3( 0.0f, 0.0f, 3.0f ), | |
| 374 | + Dali::Vector3( 0.5f, 0.0f, 4.0f ), | |
| 375 | + Dali::Vector3( 1.0f, 1.0f, 5.0f ), | |
| 376 | + | |
| 377 | + Dali::Vector3( 0.0f, 0.0f, 6.0f ), | |
| 378 | + Dali::Vector3( 0.5f, 0.0f, 7.0f ), | |
| 379 | + Dali::Vector3( 1.0f, 1.0f, 8.0f ), | |
| 380 | + | |
| 381 | + Dali::Vector3( 0.0f, 0.0f, 9.0f ), | |
| 382 | + Dali::Vector3( 0.5f, 0.0f, 10.0f ), | |
| 383 | + Dali::Vector3( 1.0f, 1.0f, 11.0f ), | |
| 384 | + | |
| 385 | + Dali::Vector3( 0.0f, 1.0f, 12.0f ), | |
| 386 | + Dali::Vector3( 0.0f, 1.0f, 13.0f ), | |
| 387 | + Dali::Vector3( 0.0f, 1.0f, 14.0f ), | |
| 388 | + Dali::Vector3( 0.0f, 1.0f, 15.0f ) }; | |
| 389 | + | |
| 390 | + short unsigned int indexData[] = { 0, 2, 1, 3, 5, 4, 6, 8, 7, 9, 11, 10, 12, 15, 14, 12, 14, 13 }; | |
| 391 | + | |
| 392 | + //Create a vertex buffer for vertex positions and texture coordinates | |
| 393 | + Dali::Property::Map vertexFormat; | |
| 394 | + vertexFormat["aCoefficient"] = Dali::Property::VECTOR3; | |
| 395 | + Dali::PropertyBuffer vertexBuffer = Dali::PropertyBuffer::New( vertexFormat ); | |
| 396 | + vertexBuffer.SetData( vertexData, sizeof(vertexData)/sizeof(vertexData[0])); | |
| 397 | + | |
| 398 | + //Create the geometry | |
| 399 | + Dali::Geometry geometry = Dali::Geometry::New(); | |
| 400 | + geometry.AddVertexBuffer( vertexBuffer ); | |
| 401 | + geometry.SetIndexBuffer( indexData, sizeof(indexData)/sizeof(indexData[0]) ); | |
| 402 | + | |
| 403 | + Renderer renderer = Renderer::New( geometry, shader ); | |
| 404 | + renderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::ON ); | |
| 405 | + | |
| 406 | + Actor actor = Actor::New(); | |
| 407 | + actor.SetSize( 400.0f, 400.0f ); | |
| 408 | + actor.SetPosition( center ); | |
| 409 | + actor.SetAnchorPoint( AnchorPoint::CENTER ); | |
| 410 | + actor.SetColor(Vector4(1.0f,0.0f,0.0f,1.0f) ); | |
| 411 | + actor.AddRenderer( renderer ); | |
| 412 | + | |
| 413 | + Stage stage = Stage::GetCurrent(); | |
| 414 | + stage.Add( actor ); | |
| 415 | + | |
| 416 | + //Animation | |
| 417 | + Animation animation = Animation::New( 5.0f ); | |
| 418 | + KeyFrames k0 = KeyFrames::New(); | |
| 419 | + k0.Add( 0.0f, Vector3( 0.0f, -radius, 0.0f ) ); | |
| 420 | + k0.Add( 0.5f, Vector3( 0.0f, -radius*4.0f, 0.0f ) ); | |
| 421 | + k0.Add( 1.0f, Vector3( 0.0f, -radius, 0.0f ) ); | |
| 422 | + animation.AnimateBetween( Property(shader, shader.GetPropertyIndex("uPosition[1]")),k0, AlphaFunction::EASE_IN_OUT_SINE ); | |
| 423 | + | |
| 424 | + k0 = KeyFrames::New(); | |
| 425 | + k0.Add( 0.0f, Vector3( radius, 0.0f, 0.0f ) ); | |
| 426 | + k0.Add( 0.5f, Vector3( radius*4.0f, 0.0f, 0.0f ) ); | |
| 427 | + k0.Add( 1.0f, Vector3( radius, 0.0f, 0.0f ) ); | |
| 428 | + animation.AnimateBetween( Property(shader, shader.GetPropertyIndex("uPosition[4]")),k0, AlphaFunction::EASE_IN_OUT_SINE ); | |
| 429 | + | |
| 430 | + k0 = KeyFrames::New(); | |
| 431 | + k0.Add( 0.0f, Vector3( 0.0f, radius, 0.0f ) ); | |
| 432 | + k0.Add( 0.5f, Vector3( 0.0f, radius*4.0f, 0.0f ) ); | |
| 433 | + k0.Add( 1.0f, Vector3( 0.0f, radius, 0.0f ) ); | |
| 434 | + animation.AnimateBetween( Property(shader, shader.GetPropertyIndex("uPosition[7]")),k0, AlphaFunction::EASE_IN_OUT_SINE ); | |
| 435 | + | |
| 436 | + k0 = KeyFrames::New(); | |
| 437 | + k0.Add( 0.0f, Vector3( -radius, 0.0f, 0.0f ) ); | |
| 438 | + k0.Add( 0.5f, Vector3( -radius*4.0f,0.0f, 0.0f ) ); | |
| 439 | + k0.Add( 1.0f, Vector3( -radius, 0.0f, 0.0f ) ); | |
| 440 | + animation.AnimateBetween( Property(shader, shader.GetPropertyIndex("uPosition[10]")),k0, AlphaFunction::EASE_IN_OUT_SINE ); | |
| 441 | + | |
| 442 | + animation.AnimateBy( Property( actor, Actor::Property::ORIENTATION ), Quaternion( Radian( Degree(90.0f) ), Vector3::ZAXIS ) ); | |
| 443 | + animation.SetLooping( true ); | |
| 444 | + animation.Play(); | |
| 445 | + } | |
| 446 | + | |
| 447 | + /** | |
| 448 | + * Main key event handler | |
| 449 | + */ | |
| 450 | + void OnKeyEvent(const KeyEvent& event) | |
| 451 | + { | |
| 452 | + if( event.state == KeyEvent::Down && (IsKey( event, DALI_KEY_ESCAPE) || IsKey( event, DALI_KEY_BACK )) ) | |
| 453 | + { | |
| 454 | + mApplication.Quit(); | |
| 455 | + } | |
| 456 | + } | |
| 457 | + | |
| 458 | +private: | |
| 459 | + Application& mApplication; | |
| 460 | + | |
| 461 | +}; | |
| 462 | + | |
| 463 | +void RunTest( Application& application ) | |
| 464 | +{ | |
| 465 | + AnimatedShapesExample test( application ); | |
| 466 | + application.MainLoop(); | |
| 467 | +} | |
| 468 | + | |
| 469 | +int main( int argc, char **argv ) | |
| 470 | +{ | |
| 471 | + Application application = Application::New( &argc, &argv ); | |
| 472 | + RunTest( application ); | |
| 473 | + | |
| 474 | + return 0; | |
| 475 | +} | ... | ... |
packaging/com.samsung.dali-demo.spec
resources/po/as.po
resources/po/de.po
resources/po/en_GB.po
resources/po/en_US.po
resources/po/es.po
resources/po/ko.po
resources/po/ml.po
resources/po/ur.po
resources/po/zn_CH.po
shared/dali-demo-strings.h
| ... | ... | @@ -32,6 +32,7 @@ extern "C" |
| 32 | 32 | |
| 33 | 33 | #ifdef INTERNATIONALIZATION_ENABLED |
| 34 | 34 | |
| 35 | +#define DALI_DEMO_STR_TITLE_ANIMATED_SHAPES dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_ANIMATED_SHAPES") | |
| 35 | 36 | #define DALI_DEMO_STR_TITLE_BLOCKS dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_BLOCKS") |
| 36 | 37 | #define DALI_DEMO_STR_TITLE_BUBBLES dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_BUBBLES") |
| 37 | 38 | #define DALI_DEMO_STR_TITLE_BUTTONS dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_BUTTONS") |
| ... | ... | @@ -81,6 +82,7 @@ extern "C" |
| 81 | 82 | |
| 82 | 83 | #else // !INTERNATIONALIZATION_ENABLED |
| 83 | 84 | |
| 85 | +#define DALI_DEMO_STR_TITLE_ANIMATED_SHAPES "Animated Shapes" | |
| 84 | 86 | #define DALI_DEMO_STR_TITLE_BLOCKS "Blocks" |
| 85 | 87 | #define DALI_DEMO_STR_TITLE_BUBBLES "Bubbles" |
| 86 | 88 | #define DALI_DEMO_STR_TITLE_BUTTONS "Buttons" | ... | ... |