Commit dbb970792997b816235730245ecdb368b9825d93
1 parent
b098cb9c
Remove bubble-effect from dali demo main screen
Change-Id: I73429729dab7d5df1291c95e5cff03bcfdb87218
Showing
2 changed files
with
31 additions
and
387 deletions
demo/dali-table-view.cpp
| 1 | /* | 1 | /* |
| 2 | - * Copyright (c) 2015 Samsung Electronics Co., Ltd. | 2 | + * Copyright (c) 2016 Samsung Electronics Co., Ltd. |
| 3 | * | 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. | 5 | * you may not use this file except in compliance with the License. |
| @@ -44,6 +44,7 @@ const std::string TILE_BACKGROUND_ALPHA(DEMO_IMAGE_DIR "item-background-alpha.9. | @@ -44,6 +44,7 @@ const std::string TILE_BACKGROUND_ALPHA(DEMO_IMAGE_DIR "item-background-alpha.9. | ||
| 44 | 44 | ||
| 45 | const char * const DEFAULT_TOOLBAR_TEXT( "TOUCH TO LAUNCH EXAMPLE" ); | 45 | const char * const DEFAULT_TOOLBAR_TEXT( "TOUCH TO LAUNCH EXAMPLE" ); |
| 46 | 46 | ||
| 47 | +const Vector4 TILE_COLOR( 0.5f, 0.6f, 0.8f, 0.23f ); ///< Color (including alpha) of tile contents. | ||
| 47 | const float BUTTON_PRESS_ANIMATION_TIME = 0.25f; ///< Time to perform button scale effect. | 48 | const float BUTTON_PRESS_ANIMATION_TIME = 0.25f; ///< Time to perform button scale effect. |
| 48 | const float ROTATE_ANIMATION_TIME = 0.5f; ///< Time to perform rotate effect. | 49 | const float ROTATE_ANIMATION_TIME = 0.5f; ///< Time to perform rotate effect. |
| 49 | const int MAX_PAGES = 256; ///< Maximum pages (arbitrary safety limit) | 50 | const int MAX_PAGES = 256; ///< Maximum pages (arbitrary safety limit) |
| @@ -54,34 +55,6 @@ const float LOGO_MARGIN_RATIO = 0.1f / 0.3f; | @@ -54,34 +55,6 @@ const float LOGO_MARGIN_RATIO = 0.1f / 0.3f; | ||
| 54 | const float BOTTOM_PADDING_RATIO = 0.4f / 0.9f; | 55 | const float BOTTOM_PADDING_RATIO = 0.4f / 0.9f; |
| 55 | const Vector3 SCROLLVIEW_RELATIVE_SIZE(0.9f, 1.0f, 0.8f ); ///< ScrollView's relative size to its parent | 56 | const Vector3 SCROLLVIEW_RELATIVE_SIZE(0.9f, 1.0f, 0.8f ); ///< ScrollView's relative size to its parent |
| 56 | const Vector3 TABLE_RELATIVE_SIZE(0.95f, 0.9f, 0.8f ); ///< TableView's relative size to the entire stage. The Y value means sum of the logo and table relative heights. | 57 | const Vector3 TABLE_RELATIVE_SIZE(0.95f, 0.9f, 0.8f ); ///< TableView's relative size to the entire stage. The Y value means sum of the logo and table relative heights. |
| 57 | -const float STENCIL_RELATIVE_SIZE = 1.0f; | ||
| 58 | - | ||
| 59 | -const float EFFECT_SNAP_DURATION = 0.66f; ///< Scroll Snap Duration for Effects | ||
| 60 | -const float EFFECT_FLICK_DURATION = 0.5f; ///< Scroll Flick Duration for Effects | ||
| 61 | -const Vector3 ANGLE_CUBE_PAGE_ROTATE(Math::PI * 0.5f, Math::PI * 0.5f, 0.0f); | ||
| 62 | - | ||
| 63 | -const Vector4 BUBBLE_COLOR[] = | ||
| 64 | -{ | ||
| 65 | - Vector4( 0.3255f, 0.3412f, 0.6353f, 0.38f ), | ||
| 66 | - Vector4( 0.3647f, 0.7569f, 0.8157f, 0.38f ), | ||
| 67 | - Vector4( 0.3804f, 0.7412f, 0.6510f, 0.38f ), | ||
| 68 | - Vector4( 1.f, 1.f, 1.f, 0.2f ) | ||
| 69 | -}; | ||
| 70 | -const int NUMBER_OF_BUBBLE_COLOR( sizeof(BUBBLE_COLOR) / sizeof(BUBBLE_COLOR[0]) ); | ||
| 71 | - | ||
| 72 | -const int NUM_BACKGROUND_IMAGES = 18; | ||
| 73 | -const float BACKGROUND_SWIPE_SCALE = 0.025f; | ||
| 74 | -const float BACKGROUND_SPREAD_SCALE = 1.5f; | ||
| 75 | -const float SCALE_MOD = 1000.0f * Math::PI * 2.0f; | ||
| 76 | -const float SCALE_SPEED = 10.0f; | ||
| 77 | -const float SCALE_SPEED_SIN = 0.1f; | ||
| 78 | - | ||
| 79 | -const unsigned int BACKGROUND_ANIMATION_DURATION = 15000; // 15 secs | ||
| 80 | - | ||
| 81 | -const Vector4 BACKGROUND_COLOR( 0.3569f, 0.5451f, 0.7294f, 1.0f ); | ||
| 82 | - | ||
| 83 | -const float BUBBLE_MIN_Z = -1.0; | ||
| 84 | -const float BUBBLE_MAX_Z = 0.0f; | ||
| 85 | 58 | ||
| 86 | /** | 59 | /** |
| 87 | * Creates the background image | 60 | * Creates the background image |
| @@ -99,38 +72,6 @@ Control CreateBackground( std::string stylename ) | @@ -99,38 +72,6 @@ Control CreateBackground( std::string stylename ) | ||
| 99 | return background; | 72 | return background; |
| 100 | } | 73 | } |
| 101 | 74 | ||
| 102 | -/** | ||
| 103 | - * Constraint to return a position for a bubble based on the scroll value and vertical wrapping | ||
| 104 | - */ | ||
| 105 | -struct AnimateBubbleConstraint | ||
| 106 | -{ | ||
| 107 | -public: | ||
| 108 | - AnimateBubbleConstraint( const Vector3& initialPos, float scale ) | ||
| 109 | - : mInitialX( initialPos.x ), | ||
| 110 | - mScale( scale ) | ||
| 111 | - { | ||
| 112 | - } | ||
| 113 | - | ||
| 114 | - void operator()( Vector3& position, const PropertyInputContainer& inputs ) | ||
| 115 | - { | ||
| 116 | - const Vector3& parentSize = inputs[1]->GetVector3(); | ||
| 117 | - const Vector3& childSize = inputs[2]->GetVector3(); | ||
| 118 | - | ||
| 119 | - // Wrap bubbles vertically. | ||
| 120 | - float range = parentSize.y + childSize.y; | ||
| 121 | - // This performs a float mod (we don't use fmod as we want the arithmetic modulus as opposed to the remainder). | ||
| 122 | - position.y -= range * ( floor( position.y / range ) + 0.5f ); | ||
| 123 | - | ||
| 124 | - // Bubbles X position moves parallax to horizontal | ||
| 125 | - // panning by a scale factor unique to each bubble. | ||
| 126 | - position.x = mInitialX + ( inputs[0]->GetVector2().x * mScale ); | ||
| 127 | - } | ||
| 128 | - | ||
| 129 | -private: | ||
| 130 | - float mInitialX; | ||
| 131 | - float mScale; | ||
| 132 | -}; | ||
| 133 | - | ||
| 134 | bool CompareByTitle( const Example& lhs, const Example& rhs ) | 75 | bool CompareByTitle( const Example& lhs, const Example& rhs ) |
| 135 | { | 76 | { |
| 136 | return lhs.title < rhs.title; | 77 | return lhs.title < rhs.title; |
| @@ -150,16 +91,13 @@ DaliTableView::DaliTableView( Application& application ) | @@ -150,16 +91,13 @@ DaliTableView::DaliTableView( Application& application ) | ||
| 150 | mScrollRulerX(), | 91 | mScrollRulerX(), |
| 151 | mScrollRulerY(), | 92 | mScrollRulerY(), |
| 152 | mPressedActor(), | 93 | mPressedActor(), |
| 153 | - mAnimationTimer(), | ||
| 154 | mLogoTapDetector(), | 94 | mLogoTapDetector(), |
| 155 | mVersionPopup(), | 95 | mVersionPopup(), |
| 156 | mPages(), | 96 | mPages(), |
| 157 | - mBackgroundAnimations(), | ||
| 158 | mExampleList(), | 97 | mExampleList(), |
| 159 | mTotalPages(), | 98 | mTotalPages(), |
| 160 | mScrolling( false ), | 99 | mScrolling( false ), |
| 161 | - mSortAlphabetically( false ), | ||
| 162 | - mBackgroundAnimsPlaying( false ) | 100 | + mSortAlphabetically( false ) |
| 163 | { | 101 | { |
| 164 | application.InitSignal().Connect( this, &DaliTableView::Initialize ); | 102 | application.InitSignal().Connect( this, &DaliTableView::Initialize ); |
| 165 | } | 103 | } |
| @@ -251,25 +189,6 @@ void DaliTableView::Initialize( Application& application ) | @@ -251,25 +189,6 @@ void DaliTableView::Initialize( Application& application ) | ||
| 251 | mScrollViewLayer.SetParentOrigin( ParentOrigin::CENTER ); | 189 | mScrollViewLayer.SetParentOrigin( ParentOrigin::CENTER ); |
| 252 | mScrollViewLayer.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); | 190 | mScrollViewLayer.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); |
| 253 | 191 | ||
| 254 | - // Create solid background colour. | ||
| 255 | - Control backgroundColourActor = Control::New(); | ||
| 256 | - backgroundColourActor.SetBackgroundColor( BACKGROUND_COLOR ); | ||
| 257 | - backgroundColourActor.SetAnchorPoint( AnchorPoint::CENTER ); | ||
| 258 | - backgroundColourActor.SetParentOrigin( ParentOrigin::CENTER ); | ||
| 259 | - backgroundColourActor.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS ); | ||
| 260 | - backgroundColourActor.SetSizeModeFactor( Vector3( 1.0f, 1.5f, 1.0f ) ); | ||
| 261 | - | ||
| 262 | - mScrollViewLayer.Add( backgroundColourActor ); | ||
| 263 | - | ||
| 264 | - // Populate background and bubbles - needs to be scrollViewLayer so scroll ends show | ||
| 265 | - Actor bubbleContainer = Actor::New(); | ||
| 266 | - bubbleContainer.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); | ||
| 267 | - bubbleContainer.SetAnchorPoint( AnchorPoint::CENTER ); | ||
| 268 | - bubbleContainer.SetParentOrigin( ParentOrigin::CENTER ); | ||
| 269 | - backgroundColourActor.Add( bubbleContainer ); | ||
| 270 | - | ||
| 271 | - SetupBackground( bubbleContainer ); | ||
| 272 | - | ||
| 273 | Alignment buttonsAlignment = Alignment::New(); | 192 | Alignment buttonsAlignment = Alignment::New(); |
| 274 | buttonsAlignment.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); | 193 | buttonsAlignment.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); |
| 275 | buttonsAlignment.Add( mScrollViewLayer ); | 194 | buttonsAlignment.Add( mScrollViewLayer ); |
| @@ -301,12 +220,6 @@ void DaliTableView::Initialize( Application& application ) | @@ -301,12 +220,6 @@ void DaliTableView::Initialize( Application& application ) | ||
| 301 | 220 | ||
| 302 | winHandle.ShowIndicator( Dali::Window::INVISIBLE ); | 221 | winHandle.ShowIndicator( Dali::Window::INVISIBLE ); |
| 303 | 222 | ||
| 304 | - // Background animation | ||
| 305 | - mAnimationTimer = Timer::New( BACKGROUND_ANIMATION_DURATION ); | ||
| 306 | - mAnimationTimer.TickSignal().Connect( this, &DaliTableView::PauseBackgroundAnimation ); | ||
| 307 | - mAnimationTimer.Start(); | ||
| 308 | - mBackgroundAnimsPlaying = true; | ||
| 309 | - | ||
| 310 | KeyboardFocusManager::Get().PreFocusChangeSignal().Connect( this, &DaliTableView::OnKeyboardPreFocusChange ); | 223 | KeyboardFocusManager::Get().PreFocusChangeSignal().Connect( this, &DaliTableView::OnKeyboardPreFocusChange ); |
| 311 | KeyboardFocusManager::Get().FocusedActorEnterKeySignal().Connect( this, &DaliTableView::OnFocusedActorActivated ); | 224 | KeyboardFocusManager::Get().FocusedActorEnterKeySignal().Connect( this, &DaliTableView::OnFocusedActorActivated ); |
| 312 | AccessibilityManager::Get().FocusedActorActivatedSignal().Connect( this, &DaliTableView::OnFocusedActorActivated ); | 225 | AccessibilityManager::Get().FocusedActorActivatedSignal().Connect( this, &DaliTableView::OnFocusedActorActivated ); |
| @@ -325,7 +238,6 @@ void DaliTableView::ApplyCubeEffectToPages() | @@ -325,7 +238,6 @@ void DaliTableView::ApplyCubeEffectToPages() | ||
| 325 | 238 | ||
| 326 | void DaliTableView::OnButtonsPageRelayout( const Dali::Actor& actor ) | 239 | void DaliTableView::OnButtonsPageRelayout( const Dali::Actor& actor ) |
| 327 | { | 240 | { |
| 328 | - | ||
| 329 | } | 241 | } |
| 330 | 242 | ||
| 331 | void DaliTableView::Populate() | 243 | void DaliTableView::Populate() |
| @@ -364,7 +276,7 @@ void DaliTableView::Populate() | @@ -364,7 +276,7 @@ void DaliTableView::Populate() | ||
| 364 | { | 276 | { |
| 365 | const Example& example = ( *iter ); | 277 | const Example& example = ( *iter ); |
| 366 | 278 | ||
| 367 | - Actor tile = CreateTile( example.name, example.title, Vector3( tileParentMultiplier, tileParentMultiplier, 1.0f ), true ); | 279 | + Actor tile = CreateTile( example.name, example.title, Vector3( tileParentMultiplier, tileParentMultiplier, 1.0f ), TILE_COLOR ); |
| 368 | AccessibilityManager accessibilityManager = AccessibilityManager::Get(); | 280 | AccessibilityManager accessibilityManager = AccessibilityManager::Get(); |
| 369 | accessibilityManager.SetFocusOrder( tile, ++exampleCount ); | 281 | accessibilityManager.SetFocusOrder( tile, ++exampleCount ); |
| 370 | accessibilityManager.SetAccessibilityAttribute( tile, Dali::Toolkit::AccessibilityManager::ACCESSIBILITY_LABEL, | 282 | accessibilityManager.SetAccessibilityAttribute( tile, Dali::Toolkit::AccessibilityManager::ACCESSIBILITY_LABEL, |
| @@ -436,7 +348,7 @@ void DaliTableView::Rotate( unsigned int degrees ) | @@ -436,7 +348,7 @@ void DaliTableView::Rotate( unsigned int degrees ) | ||
| 436 | mRotateAnimation.Play(); | 348 | mRotateAnimation.Play(); |
| 437 | } | 349 | } |
| 438 | 350 | ||
| 439 | -Actor DaliTableView::CreateTile( const std::string& name, const std::string& title, const Dali::Vector3& sizeMultiplier, bool addBackground ) | 351 | +Actor DaliTableView::CreateTile( const std::string& name, const std::string& title, const Dali::Vector3& sizeMultiplier, const Dali::Vector4& color ) |
| 440 | { | 352 | { |
| 441 | Actor content = Actor::New(); | 353 | Actor content = Actor::New(); |
| 442 | content.SetName( name ); | 354 | content.SetName( name ); |
| @@ -445,23 +357,25 @@ Actor DaliTableView::CreateTile( const std::string& name, const std::string& tit | @@ -445,23 +357,25 @@ Actor DaliTableView::CreateTile( const std::string& name, const std::string& tit | ||
| 445 | content.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS ); | 357 | content.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS ); |
| 446 | content.SetSizeModeFactor( sizeMultiplier ); | 358 | content.SetSizeModeFactor( sizeMultiplier ); |
| 447 | 359 | ||
| 448 | - // create background image | ||
| 449 | - if( addBackground ) | ||
| 450 | - { | ||
| 451 | - ImageView image = ImageView::New( TILE_BACKGROUND ); | ||
| 452 | - image.SetAnchorPoint( AnchorPoint::CENTER ); | ||
| 453 | - image.SetParentOrigin( ParentOrigin::CENTER ); | ||
| 454 | - // make the image 100% of tile | ||
| 455 | - image.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); | ||
| 456 | - | ||
| 457 | - content.Add( image ); | ||
| 458 | - | ||
| 459 | - // Add stencil | ||
| 460 | - Toolkit::ImageView stencil = NewStencilImage(); | ||
| 461 | - stencil.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); | ||
| 462 | - image.Add( stencil ); | ||
| 463 | - } | 360 | + // Create background image. |
| 361 | + ImageView image = ImageView::New( TILE_BACKGROUND ); | ||
| 362 | + image.SetAnchorPoint( AnchorPoint::CENTER ); | ||
| 363 | + image.SetParentOrigin( ParentOrigin::CENTER ); | ||
| 364 | + // Make the image 100% of tile. | ||
| 365 | + image.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); | ||
| 366 | + content.Add( image ); | ||
| 367 | + | ||
| 368 | + // Create the tile background. | ||
| 369 | + Actor tileBackground = ImageView::New( TILE_BACKGROUND_ALPHA ); | ||
| 370 | + tileBackground.SetParentOrigin( ParentOrigin::CENTER ); | ||
| 371 | + tileBackground.SetAnchorPoint( AnchorPoint::CENTER ); | ||
| 372 | + tileBackground.SetProperty( Actor::Property::COLOR, color ); | ||
| 373 | + Property::Map shaderEffect = CreateAlphaDiscardEffect(); | ||
| 374 | + tileBackground.SetProperty( Toolkit::ImageView::Property::IMAGE, shaderEffect ); | ||
| 375 | + tileBackground.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); | ||
| 376 | + image.Add( tileBackground ); | ||
| 464 | 377 | ||
| 378 | + // Create the tile label. | ||
| 465 | TextLabel label = TextLabel::New(); | 379 | TextLabel label = TextLabel::New(); |
| 466 | label.SetAnchorPoint( AnchorPoint::TOP_LEFT ); | 380 | label.SetAnchorPoint( AnchorPoint::TOP_LEFT ); |
| 467 | label.SetProperty( Control::Property::STYLE_NAME, "launcherlabel" ); | 381 | label.SetProperty( Control::Property::STYLE_NAME, "launcherlabel" ); |
| @@ -482,19 +396,6 @@ Actor DaliTableView::CreateTile( const std::string& name, const std::string& tit | @@ -482,19 +396,6 @@ Actor DaliTableView::CreateTile( const std::string& name, const std::string& tit | ||
| 482 | return content; | 396 | return content; |
| 483 | } | 397 | } |
| 484 | 398 | ||
| 485 | -Toolkit::ImageView DaliTableView::NewStencilImage() | ||
| 486 | -{ | ||
| 487 | - Toolkit::ImageView stencil = ImageView::New( TILE_BACKGROUND_ALPHA ); | ||
| 488 | - stencil.SetParentOrigin( ParentOrigin::CENTER ); | ||
| 489 | - stencil.SetAnchorPoint( AnchorPoint::CENTER ); | ||
| 490 | - stencil.SetDrawMode( DrawMode::STENCIL ); | ||
| 491 | - | ||
| 492 | - Property::Map shaderEffect = CreateAlphaDiscardEffect(); | ||
| 493 | - stencil.SetProperty( Toolkit::ImageView::Property::IMAGE, shaderEffect ); | ||
| 494 | - | ||
| 495 | - return stencil; | ||
| 496 | -} | ||
| 497 | - | ||
| 498 | bool DaliTableView::OnTilePressed( Actor actor, const TouchData& event ) | 399 | bool DaliTableView::OnTilePressed( Actor actor, const TouchData& event ) |
| 499 | { | 400 | { |
| 500 | return DoTilePress( actor, event.GetState( 0 ) ); | 401 | return DoTilePress( actor, event.GetState( 0 ) ); |
| @@ -571,8 +472,6 @@ void DaliTableView::OnPressedAnimationFinished( Dali::Animation& source ) | @@ -571,8 +472,6 @@ void DaliTableView::OnPressedAnimationFinished( Dali::Animation& source ) | ||
| 571 | void DaliTableView::OnScrollStart( const Dali::Vector2& position ) | 472 | void DaliTableView::OnScrollStart( const Dali::Vector2& position ) |
| 572 | { | 473 | { |
| 573 | mScrolling = true; | 474 | mScrolling = true; |
| 574 | - | ||
| 575 | - PlayAnimation(); | ||
| 576 | } | 475 | } |
| 577 | 476 | ||
| 578 | void DaliTableView::OnScrollComplete( const Dali::Vector2& position ) | 477 | void DaliTableView::OnScrollComplete( const Dali::Vector2& position ) |
| @@ -656,138 +555,6 @@ void DaliTableView::OnKeyEvent( const KeyEvent& event ) | @@ -656,138 +555,6 @@ void DaliTableView::OnKeyEvent( const KeyEvent& event ) | ||
| 656 | } | 555 | } |
| 657 | } | 556 | } |
| 658 | 557 | ||
| 659 | -void DaliTableView::SetupBackground( Actor bubbleContainer ) | ||
| 660 | -{ | ||
| 661 | - // Create distance field shape. | ||
| 662 | - BufferImage distanceField; | ||
| 663 | - Size imageSize( 512, 512 ); | ||
| 664 | - CreateShapeImage( CIRCLE, imageSize, distanceField ); | ||
| 665 | - | ||
| 666 | - // Add bubbles to the bubbleContainer. | ||
| 667 | - // Note: The bubbleContainer is parented externally to this function. | ||
| 668 | - AddBackgroundActors( bubbleContainer, NUM_BACKGROUND_IMAGES, distanceField ); | ||
| 669 | -} | ||
| 670 | - | ||
| 671 | -void DaliTableView::InitialiseBackgroundActors( Actor actor ) | ||
| 672 | -{ | ||
| 673 | - // Delete current animations | ||
| 674 | - mBackgroundAnimations.clear(); | ||
| 675 | - | ||
| 676 | - // Create new animations | ||
| 677 | - const Vector3 size = actor.GetTargetSize(); | ||
| 678 | - | ||
| 679 | - for( unsigned int i = 0, childCount = actor.GetChildCount(); i < childCount; ++i ) | ||
| 680 | - { | ||
| 681 | - Actor child = actor.GetChildAt( i ); | ||
| 682 | - | ||
| 683 | - // Calculate a random position | ||
| 684 | - Vector3 childPos( Random::Range( -size.x * 0.5f * BACKGROUND_SPREAD_SCALE, size.x * 0.5f * BACKGROUND_SPREAD_SCALE ), | ||
| 685 | - Random::Range( -size.y, size.y ), | ||
| 686 | - Random::Range( BUBBLE_MIN_Z, BUBBLE_MAX_Z ) ); | ||
| 687 | - | ||
| 688 | - child.SetPosition( childPos ); | ||
| 689 | - | ||
| 690 | - // Define bubble horizontal parallax and vertical wrapping | ||
| 691 | - Constraint animConstraint = Constraint::New < Vector3 > ( child, Actor::Property::POSITION, AnimateBubbleConstraint( childPos, Random::Range( -0.85f, 0.25f ) ) ); | ||
| 692 | - animConstraint.AddSource( Source( mScrollView, ScrollView::Property::SCROLL_POSITION ) ); | ||
| 693 | - animConstraint.AddSource( Dali::ParentSource( Dali::Actor::Property::SIZE ) ); | ||
| 694 | - animConstraint.AddSource( Dali::LocalSource( Dali::Actor::Property::SIZE ) ); | ||
| 695 | - animConstraint.SetRemoveAction( Constraint::Discard ); | ||
| 696 | - animConstraint.Apply(); | ||
| 697 | - | ||
| 698 | - // Kickoff animation | ||
| 699 | - Animation animation = Animation::New( Random::Range( 30.0f, 160.0f ) ); | ||
| 700 | - animation.AnimateBy( Property( child, Actor::Property::POSITION ), Vector3( 0.0f, -2000.0f, 0.0f ), AlphaFunction::LINEAR ); | ||
| 701 | - animation.SetLooping( true ); | ||
| 702 | - animation.Play(); | ||
| 703 | - mBackgroundAnimations.push_back( animation ); | ||
| 704 | - } | ||
| 705 | -} | ||
| 706 | - | ||
| 707 | -void DaliTableView::AddBackgroundActors( Actor layer, int count, BufferImage distanceField ) | ||
| 708 | -{ | ||
| 709 | - for( int i = 0; i < count; ++i ) | ||
| 710 | - { | ||
| 711 | - float randSize = Random::Range( 10.0f, 400.0f ); | ||
| 712 | - ImageView dfActor = ImageView::New( distanceField ); | ||
| 713 | - dfActor.SetSize( Vector2( randSize, randSize ) ); | ||
| 714 | - dfActor.SetParentOrigin( ParentOrigin::CENTER ); | ||
| 715 | - | ||
| 716 | - Dali::Property::Map effect = Toolkit::CreateDistanceFieldEffect(); | ||
| 717 | - dfActor.SetProperty( Toolkit::ImageView::Property::IMAGE, effect ); | ||
| 718 | - dfActor.SetColor( BUBBLE_COLOR[ i%NUMBER_OF_BUBBLE_COLOR ] ); | ||
| 719 | - | ||
| 720 | - layer.Add( dfActor ); | ||
| 721 | - } | ||
| 722 | - | ||
| 723 | - // Positioning will occur when the layer is relaid out | ||
| 724 | - layer.OnRelayoutSignal().Connect( this, &DaliTableView::InitialiseBackgroundActors ); | ||
| 725 | -} | ||
| 726 | - | ||
| 727 | -void DaliTableView::CreateShapeImage( ShapeType shapeType, const Size& size, BufferImage& distanceFieldOut ) | ||
| 728 | -{ | ||
| 729 | - // this bitmap will hold the alpha map for the distance field shader | ||
| 730 | - distanceFieldOut = BufferImage::New( size.width, size.height, Pixel::A8 ); | ||
| 731 | - | ||
| 732 | - // Generate bit pattern | ||
| 733 | - std::vector< unsigned char > imageDataA8; | ||
| 734 | - imageDataA8.reserve( size.width * size.height ); // A8 | ||
| 735 | - | ||
| 736 | - switch( shapeType ) | ||
| 737 | - { | ||
| 738 | - case CIRCLE: | ||
| 739 | - GenerateCircle( size, imageDataA8 ); | ||
| 740 | - break; | ||
| 741 | - case SQUARE: | ||
| 742 | - GenerateSquare( size, imageDataA8 ); | ||
| 743 | - break; | ||
| 744 | - default: | ||
| 745 | - break; | ||
| 746 | - } | ||
| 747 | - | ||
| 748 | - PixelBuffer* buffer = distanceFieldOut.GetBuffer(); | ||
| 749 | - if( buffer ) | ||
| 750 | - { | ||
| 751 | - GenerateDistanceFieldMap( &imageDataA8[ 0 ], size, buffer, size, 8.0f, size ); | ||
| 752 | - distanceFieldOut.Update(); | ||
| 753 | - } | ||
| 754 | -} | ||
| 755 | - | ||
| 756 | -void DaliTableView::GenerateSquare( const Size& size, std::vector< unsigned char >& distanceFieldOut ) | ||
| 757 | -{ | ||
| 758 | - for( int h = 0; h < size.height; ++h ) | ||
| 759 | - { | ||
| 760 | - for( int w = 0; w < size.width; ++w ) | ||
| 761 | - { | ||
| 762 | - distanceFieldOut.push_back( 0xFF ); | ||
| 763 | - } | ||
| 764 | - } | ||
| 765 | -} | ||
| 766 | - | ||
| 767 | -void DaliTableView::GenerateCircle( const Size& size, std::vector< unsigned char >& distanceFieldOut ) | ||
| 768 | -{ | ||
| 769 | - const float radius = size.width * 0.5f * size.width * 0.5f; | ||
| 770 | - Vector2 center( size.width / 2, size.height / 2 ); | ||
| 771 | - | ||
| 772 | - for( int h = 0; h < size.height; ++h ) | ||
| 773 | - { | ||
| 774 | - for( int w = 0; w < size.width; ++w ) | ||
| 775 | - { | ||
| 776 | - Vector2 pos( w, h ); | ||
| 777 | - Vector2 dist = pos - center; | ||
| 778 | - | ||
| 779 | - if( dist.x * dist.x + dist.y * dist.y > radius ) | ||
| 780 | - { | ||
| 781 | - distanceFieldOut.push_back( 0x00 ); | ||
| 782 | - } | ||
| 783 | - else | ||
| 784 | - { | ||
| 785 | - distanceFieldOut.push_back( 0xFF ); | ||
| 786 | - } | ||
| 787 | - } | ||
| 788 | - } | ||
| 789 | -} | ||
| 790 | - | ||
| 791 | ImageView DaliTableView::CreateLogo( std::string imagePath ) | 558 | ImageView DaliTableView::CreateLogo( std::string imagePath ) |
| 792 | { | 559 | { |
| 793 | ImageView logo = ImageView::New( imagePath ); | 560 | ImageView logo = ImageView::New( imagePath ); |
| @@ -798,45 +565,6 @@ ImageView DaliTableView::CreateLogo( std::string imagePath ) | @@ -798,45 +565,6 @@ ImageView DaliTableView::CreateLogo( std::string imagePath ) | ||
| 798 | return logo; | 565 | return logo; |
| 799 | } | 566 | } |
| 800 | 567 | ||
| 801 | -bool DaliTableView::PauseBackgroundAnimation() | ||
| 802 | -{ | ||
| 803 | - PauseAnimation(); | ||
| 804 | - | ||
| 805 | - return false; | ||
| 806 | -} | ||
| 807 | - | ||
| 808 | -void DaliTableView::PauseAnimation() | ||
| 809 | -{ | ||
| 810 | - if( mBackgroundAnimsPlaying ) | ||
| 811 | - { | ||
| 812 | - for( AnimationListIter animIter = mBackgroundAnimations.begin(); animIter != mBackgroundAnimations.end(); ++animIter ) | ||
| 813 | - { | ||
| 814 | - Animation anim = *animIter; | ||
| 815 | - | ||
| 816 | - anim.Stop(); | ||
| 817 | - } | ||
| 818 | - | ||
| 819 | - mBackgroundAnimsPlaying = false; | ||
| 820 | - } | ||
| 821 | -} | ||
| 822 | - | ||
| 823 | -void DaliTableView::PlayAnimation() | ||
| 824 | -{ | ||
| 825 | - if ( !mBackgroundAnimsPlaying ) | ||
| 826 | - { | ||
| 827 | - for( AnimationListIter animIter = mBackgroundAnimations.begin(); animIter != mBackgroundAnimations.end(); ++animIter ) | ||
| 828 | - { | ||
| 829 | - Animation anim = *animIter; | ||
| 830 | - | ||
| 831 | - anim.Play(); | ||
| 832 | - } | ||
| 833 | - | ||
| 834 | - mBackgroundAnimsPlaying = true; | ||
| 835 | - } | ||
| 836 | - | ||
| 837 | - mAnimationTimer.SetInterval( BACKGROUND_ANIMATION_DURATION ); | ||
| 838 | -} | ||
| 839 | - | ||
| 840 | Dali::Actor DaliTableView::OnKeyboardPreFocusChange( Dali::Actor current, Dali::Actor proposed, Dali::Toolkit::Control::KeyboardFocus::Direction direction ) | 568 | Dali::Actor DaliTableView::OnKeyboardPreFocusChange( Dali::Actor current, Dali::Actor proposed, Dali::Toolkit::Control::KeyboardFocus::Direction direction ) |
| 841 | { | 569 | { |
| 842 | Actor nextFocusActor = proposed; | 570 | Actor nextFocusActor = proposed; |
| @@ -930,11 +658,13 @@ void DaliTableView::OnLogoTapped( Dali::Actor actor, const Dali::TapGesture& tap | @@ -930,11 +658,13 @@ void DaliTableView::OnLogoTapped( Dali::Actor actor, const Dali::TapGesture& tap | ||
| 930 | Toolkit::TextLabel titleActor = Toolkit::TextLabel::New( "Version information" ); | 658 | Toolkit::TextLabel titleActor = Toolkit::TextLabel::New( "Version information" ); |
| 931 | titleActor.SetName( "titleActor" ); | 659 | titleActor.SetName( "titleActor" ); |
| 932 | titleActor.SetProperty( Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" ); | 660 | titleActor.SetProperty( Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" ); |
| 661 | + titleActor.SetProperty( Toolkit::TextLabel::Property::TEXT_COLOR, Color::WHITE ); | ||
| 933 | 662 | ||
| 934 | Toolkit::TextLabel contentActor = Toolkit::TextLabel::New( stream.str() ); | 663 | Toolkit::TextLabel contentActor = Toolkit::TextLabel::New( stream.str() ); |
| 935 | contentActor.SetName( "contentActor" ); | 664 | contentActor.SetName( "contentActor" ); |
| 936 | contentActor.SetProperty( Toolkit::TextLabel::Property::MULTI_LINE, true ); | 665 | contentActor.SetProperty( Toolkit::TextLabel::Property::MULTI_LINE, true ); |
| 937 | contentActor.SetProperty( Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" ); | 666 | contentActor.SetProperty( Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" ); |
| 667 | + contentActor.SetProperty( Toolkit::TextLabel::Property::TEXT_COLOR, Color::WHITE ); | ||
| 938 | contentActor.SetPadding( Padding( 0.0f, 0.0f, 20.0f, 0.0f ) ); | 668 | contentActor.SetPadding( Padding( 0.0f, 0.0f, 20.0f, 0.0f ) ); |
| 939 | 669 | ||
| 940 | mVersionPopup.SetTitle( titleActor ); | 670 | mVersionPopup.SetTitle( titleActor ); |
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 | * Licensed under the Apache License, Version 2.0 (the "License"); | 7 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 8 | * you may not use this file except in compliance with the License. | 8 | * you may not use this file except in compliance with the License. |
| @@ -98,15 +98,6 @@ public: | @@ -98,15 +98,6 @@ public: | ||
| 98 | private: // Application callbacks & implementation | 98 | private: // Application callbacks & implementation |
| 99 | 99 | ||
| 100 | /** | 100 | /** |
| 101 | - * Shape enum for create function | ||
| 102 | - */ | ||
| 103 | - enum ShapeType | ||
| 104 | - { | ||
| 105 | - CIRCLE, | ||
| 106 | - SQUARE | ||
| 107 | - }; | ||
| 108 | - | ||
| 109 | - /** | ||
| 110 | * Initialize application. | 101 | * Initialize application. |
| 111 | * | 102 | * |
| 112 | * @param[in] app Application instance | 103 | * @param[in] app Application instance |
| @@ -140,18 +131,11 @@ private: // Application callbacks & implementation | @@ -140,18 +131,11 @@ private: // Application callbacks & implementation | ||
| 140 | * @param[in] name The unique name for this Tile | 131 | * @param[in] name The unique name for this Tile |
| 141 | * @param[in] title The text caption that appears on the Tile | 132 | * @param[in] title The text caption that appears on the Tile |
| 142 | * @param[in] parentSize Tile's parent size. | 133 | * @param[in] parentSize Tile's parent size. |
| 143 | - * @param[in] addBackground Whether to add a background graphic to the tile or not | 134 | + * @param[in] color The color (including alpha) of the tiles contents. |
| 144 | * | 135 | * |
| 145 | * @return The Actor for the created tile. | 136 | * @return The Actor for the created tile. |
| 146 | */ | 137 | */ |
| 147 | - Dali::Actor CreateTile( const std::string& name, const std::string& title, const Dali::Vector3& sizeMultiplier, bool addBackground ); | ||
| 148 | - | ||
| 149 | - /** | ||
| 150 | - * Create a stencil image | ||
| 151 | - * | ||
| 152 | - * @return The stencil image | ||
| 153 | - */ | ||
| 154 | - Dali::Toolkit::ImageView NewStencilImage(); | 138 | + Dali::Actor CreateTile( const std::string& name, const std::string& title, const Dali::Vector3& sizeMultiplier, const Dali::Vector4& color ); |
| 155 | 139 | ||
| 156 | // Signal handlers | 140 | // Signal handlers |
| 157 | 141 | ||
| @@ -257,49 +241,6 @@ private: // Application callbacks & implementation | @@ -257,49 +241,6 @@ private: // Application callbacks & implementation | ||
| 257 | void OnKeyEvent( const Dali::KeyEvent& event ); | 241 | void OnKeyEvent( const Dali::KeyEvent& event ); |
| 258 | 242 | ||
| 259 | /** | 243 | /** |
| 260 | - * Create a depth field background | ||
| 261 | - * | ||
| 262 | - * @param[in] bubbleLayer Add the graphics to this layer | ||
| 263 | - */ | ||
| 264 | - void SetupBackground( Dali::Actor bubbleLayer ); | ||
| 265 | - | ||
| 266 | - /** | ||
| 267 | - * Create background actors for the given layer | ||
| 268 | - * | ||
| 269 | - * @param[in] layer The layer to add the actors to | ||
| 270 | - * @param[in] count The number of actors to generate | ||
| 271 | - * @param[in] distanceField The distance field bitmap to use | ||
| 272 | - */ | ||
| 273 | - void AddBackgroundActors( Dali::Actor layer, int count, Dali::BufferImage distanceField ); | ||
| 274 | - | ||
| 275 | - /** | ||
| 276 | - * Create a bitmap with the specified shape and also output a distance field | ||
| 277 | - * | ||
| 278 | - * @param[in] shapeType The shape to generate | ||
| 279 | - * @param[in] size The size of the bitmap to create | ||
| 280 | - * @param[out] distanceFieldOut The return depth field alpha map | ||
| 281 | - */ | ||
| 282 | - void CreateShapeImage( ShapeType shapeType, const Dali::Size& size, Dali::BufferImage& distanceFieldOut ); | ||
| 283 | - | ||
| 284 | - /** | ||
| 285 | - * Generate a square bit pattern and depth field | ||
| 286 | - * | ||
| 287 | - * @param[in] size The size of the bitmap to create | ||
| 288 | - * @param[out] imageOut The return bitmap | ||
| 289 | - * @param[out] distanceFieldOut The return depth field alpha map | ||
| 290 | - */ | ||
| 291 | - void GenerateSquare( const Dali::Size& size, std::vector<unsigned char>& distanceFieldOut ); | ||
| 292 | - | ||
| 293 | - /** | ||
| 294 | - * Generate a circle bit pattern and depth field | ||
| 295 | - * | ||
| 296 | - * @param[in] size The size of the bitmap to create | ||
| 297 | - * @param[out] imageOut The return bitmap | ||
| 298 | - * @param[out] distanceFieldOut The return depth field alpha map | ||
| 299 | - */ | ||
| 300 | - void GenerateCircle( const Dali::Size& size, std::vector<unsigned char>& distanceFieldOut ); | ||
| 301 | - | ||
| 302 | - /** | ||
| 303 | * Creates the logo. | 244 | * Creates the logo. |
| 304 | * | 245 | * |
| 305 | * @param[in] imagePath The path to the image file to load | 246 | * @param[in] imagePath The path to the image file to load |
| @@ -309,23 +250,6 @@ private: // Application callbacks & implementation | @@ -309,23 +250,6 @@ private: // Application callbacks & implementation | ||
| 309 | Dali::Toolkit::ImageView CreateLogo( std::string imagePath ); | 250 | Dali::Toolkit::ImageView CreateLogo( std::string imagePath ); |
| 310 | 251 | ||
| 311 | /** | 252 | /** |
| 312 | - * Timer handler for ending background animation | ||
| 313 | - * | ||
| 314 | - * @return Return value for timer handler | ||
| 315 | - */ | ||
| 316 | - bool PauseBackgroundAnimation(); | ||
| 317 | - | ||
| 318 | - /** | ||
| 319 | - * Pause all animations | ||
| 320 | - */ | ||
| 321 | - void PauseAnimation(); | ||
| 322 | - | ||
| 323 | - /** | ||
| 324 | - * Resume all animations | ||
| 325 | - */ | ||
| 326 | - void PlayAnimation(); | ||
| 327 | - | ||
| 328 | - /** | ||
| 329 | * Callback when the keyboard focus is going to be changed. | 253 | * Callback when the keyboard focus is going to be changed. |
| 330 | * | 254 | * |
| 331 | * @param[in] current The current focused actor | 255 | * @param[in] current The current focused actor |
| @@ -362,13 +286,6 @@ private: // Application callbacks & implementation | @@ -362,13 +286,6 @@ private: // Application callbacks & implementation | ||
| 362 | */ | 286 | */ |
| 363 | void OnButtonsPageRelayout( const Dali::Actor& actor ); | 287 | void OnButtonsPageRelayout( const Dali::Actor& actor ); |
| 364 | 288 | ||
| 365 | - /** | ||
| 366 | - * @brief Callback called to set up background actors | ||
| 367 | - * | ||
| 368 | - * @param[in] actor The actor raising the callback | ||
| 369 | - */ | ||
| 370 | - void InitialiseBackgroundActors( Dali::Actor actor ); | ||
| 371 | - | ||
| 372 | private: | 289 | private: |
| 373 | 290 | ||
| 374 | Dali::Application& mApplication; ///< Application instance. | 291 | Dali::Application& mApplication; ///< Application instance. |
| @@ -382,20 +299,17 @@ private: | @@ -382,20 +299,17 @@ private: | ||
| 382 | Dali::Toolkit::RulerPtr mScrollRulerX; ///< ScrollView X (horizontal) ruler | 299 | Dali::Toolkit::RulerPtr mScrollRulerX; ///< ScrollView X (horizontal) ruler |
| 383 | Dali::Toolkit::RulerPtr mScrollRulerY; ///< ScrollView Y (vertical) ruler | 300 | Dali::Toolkit::RulerPtr mScrollRulerY; ///< ScrollView Y (vertical) ruler |
| 384 | Dali::Actor mPressedActor; ///< The currently pressed actor. | 301 | Dali::Actor mPressedActor; ///< The currently pressed actor. |
| 385 | - Dali::Timer mAnimationTimer; ///< Timer used to turn off animation after a specific time period | ||
| 386 | Dali::TapGestureDetector mLogoTapDetector; ///< To detect taps on the logo | 302 | Dali::TapGestureDetector mLogoTapDetector; ///< To detect taps on the logo |
| 387 | Dali::Toolkit::Popup mVersionPopup; ///< Displays DALi library version information | 303 | Dali::Toolkit::Popup mVersionPopup; ///< Displays DALi library version information |
| 388 | 304 | ||
| 389 | std::vector< Dali::Actor > mPages; ///< List of pages. | 305 | std::vector< Dali::Actor > mPages; ///< List of pages. |
| 390 | - AnimationList mBackgroundAnimations; ///< List of background bubble animations | ||
| 391 | ExampleList mExampleList; ///< List of examples. | 306 | ExampleList mExampleList; ///< List of examples. |
| 392 | 307 | ||
| 393 | int mTotalPages; ///< Total pages within scrollview. | 308 | int mTotalPages; ///< Total pages within scrollview. |
| 394 | 309 | ||
| 395 | bool mScrolling:1; ///< Flag indicating whether view is currently being scrolled | 310 | bool mScrolling:1; ///< Flag indicating whether view is currently being scrolled |
| 396 | bool mSortAlphabetically:1; ///< Sort examples alphabetically. | 311 | bool mSortAlphabetically:1; ///< Sort examples alphabetically. |
| 397 | - bool mBackgroundAnimsPlaying:1; ///< Are background animations playing | ||
| 398 | 312 | ||
| 399 | }; | 313 | }; |
| 400 | 314 | ||
| 401 | -#endif // __DALI_DEMO_H__ | 315 | +#endif // DALI_DEMO_H |