X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=shared%2Fdali-table-view.cpp;h=869bc7b8bbb0c5d643927229087714e1252c12b8;hb=0950304e0f940a0587bc7bc2fe76e176ffdc77c6;hp=cae9fb1da2b69178091f7d6d31d15c76b77a6dc9;hpb=945e292deb3d058c10ddb1a0c06325a69698ae07;p=platform%2Fcore%2Fuifw%2Fdali-demo.git diff --git a/shared/dali-table-view.cpp b/shared/dali-table-view.cpp index cae9fb1..869bc7b 100644 --- a/shared/dali-table-view.cpp +++ b/shared/dali-table-view.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,17 +20,19 @@ // EXTERNAL INCLUDES #include -#include -#include +#include #include #include #include #include #include +#include +#include // INTERNAL INCLUDES -#include "shared/view.h" +#include "shared/execute-process.h" #include "shared/utility.h" +#include "shared/view.h" using namespace Dali; using namespace Dali::Toolkit; @@ -44,13 +46,15 @@ const std::string LOGO_PATH( DEMO_IMAGE_DIR "Logo-for-demo.png" ); // Keyboard focus effect constants. const float KEYBOARD_FOCUS_ANIMATION_DURATION = 1.0f; ///< The total duration of the keyboard focus animation -const float KEYBOARD_FOCUS_START_SCALE = 1.05f; ///< The starting scale of the focus highlight -const float KEYBOARD_FOCUS_END_SCALE = 1.18f; ///< The end scale of the focus highlight -const float KEYBOARD_FOCUS_END_ALPHA = 0.7f; ///< The end alpha of the focus highlight -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. -const Vector3 startScale( KEYBOARD_FOCUS_START_SCALE, KEYBOARD_FOCUS_START_SCALE, KEYBOARD_FOCUS_START_SCALE ); ///< @see KEYBOARD_FOCUS_START_SCALE -const Vector3 endScale( KEYBOARD_FOCUS_END_SCALE, KEYBOARD_FOCUS_END_SCALE, KEYBOARD_FOCUS_END_SCALE ); ///< @see KEYBOARD_FOCUS_END_SCALE -const float initialFadeDuration = KEYBOARD_FOCUS_ANIMATION_DURATION * KEYBOARD_FOCUS_INITIAL_FADE_PERCENTAGE; ///< @see KEYBOARD_FOCUS_INITIAL_FADE_PERCENTAGE +const int32_t KEYBOARD_FOCUS_ANIMATION_LOOP_COUNT = 5; ///< The number of loops for the keyboard focus animation +const float KEYBOARD_FOCUS_FINAL_SCALE_FLOAT = 1.05f; ///< The final scale of the focus highlight +const float KEYBOARD_FOCUS_ANIMATED_SCALE_FLOAT = 1.18f; ///< The scale of the focus highlight during the animation +const float KEYBOARD_FOCUS_FINAL_ALPHA = 0.7f; ///< The final alpha of the focus highlight +const float KEYBOARD_FOCUS_ANIMATING_ALPHA = 0.0f; ///< The alpha of the focus highlight during the animation +const float KEYBOARD_FOCUS_FADE_PERCENTAGE = 0.16f; ///< The duration of the fade (from translucent to the final-alpha) as a percentage of the overall animation duration +const Vector3 KEYBOARD_FOCUS_FINAL_SCALE( KEYBOARD_FOCUS_FINAL_SCALE_FLOAT, KEYBOARD_FOCUS_FINAL_SCALE_FLOAT, KEYBOARD_FOCUS_FINAL_SCALE_FLOAT ); ///< @see KEYBOARD_FOCUS_START_SCALE_FLOAT +const Vector3 FOCUS_INDICATOR_ANIMATING_SCALE( KEYBOARD_FOCUS_ANIMATED_SCALE_FLOAT, KEYBOARD_FOCUS_ANIMATED_SCALE_FLOAT, KEYBOARD_FOCUS_ANIMATED_SCALE_FLOAT ); ///< @see KEYBOARD_FOCUS_END_SCALE_FLOAT +const float KEYBOARD_FOCUS_MID_KEY_FRAME_TIME = KEYBOARD_FOCUS_ANIMATION_DURATION - ( KEYBOARD_FOCUS_ANIMATION_DURATION * KEYBOARD_FOCUS_FADE_PERCENTAGE ); ///< Time of the mid key-frame const float TILE_LABEL_PADDING = 8.0f; ///< Border between edge of tile and the example text const float BUTTON_PRESS_ANIMATION_TIME = 0.35f; ///< Time to perform button scale effect. @@ -69,15 +73,14 @@ const float EFFECT_SNAP_DURATION = 0.66f; ///< Scroll Snap const float EFFECT_FLICK_DURATION = 0.5f; ///< Scroll Flick Duration for Effects const Vector3 ANGLE_CUBE_PAGE_ROTATE(Math::PI * 0.5f, Math::PI * 0.5f, 0.0f); - -const Vector4 BUBBLE_COLOR[] = +const char * const BUBBLE_COLOR_STYLE_NAME[] = { - Vector4( 0.3255f, 0.3412f, 0.6353f, 0.32f ), - Vector4( 0.3647f, 0.7569f, 0.8157f, 0.32f ), - Vector4( 0.3804f, 0.7412f, 0.6510f, 0.32f ), - Vector4( 1.f, 1.f, 1.f, 0.13f ) + "BubbleColor1", + "BubbleColor2", + "BubbleColor3", + "BubbleColor4" }; -const int NUMBER_OF_BUBBLE_COLOR( sizeof(BUBBLE_COLOR) / sizeof(BUBBLE_COLOR[0]) ); +const int NUMBER_OF_BUBBLE_COLORS( sizeof( BUBBLE_COLOR_STYLE_NAME ) / sizeof( BUBBLE_COLOR_STYLE_NAME[ 0 ] ) ); const char * const SHAPE_IMAGE_TABLE[] = { @@ -87,19 +90,14 @@ const char * const SHAPE_IMAGE_TABLE[] = const int NUMBER_OF_SHAPE_IMAGES( sizeof( SHAPE_IMAGE_TABLE ) / sizeof( SHAPE_IMAGE_TABLE[0] ) ); const int NUM_BACKGROUND_IMAGES = 18; -const float BACKGROUND_SWIPE_SCALE = 0.025f; const float BACKGROUND_SPREAD_SCALE = 1.5f; -const float SCALE_MOD = 1000.0f * Math::PI * 2.0f; -const float SCALE_SPEED = 10.0f; -const float SCALE_SPEED_SIN = 0.1f; const unsigned int BACKGROUND_ANIMATION_DURATION = 15000; // 15 secs -const Vector4 BACKGROUND_COLOR( 0.3569f, 0.5451f, 0.7294f, 1.0f ); - const float BUBBLE_MIN_Z = -1.0; const float BUBBLE_MAX_Z = 0.0f; +const char * const DEMO_BUILD_DATE = __DATE__ " " __TIME__; /** * Creates the background image @@ -107,11 +105,10 @@ const float BUBBLE_MAX_Z = 0.0f; Control CreateBackground( std::string stylename ) { Control background = Control::New(); - Stage::GetCurrent().Add( background ); background.SetStyleName( stylename ); - background.SetName( "BACKGROUND" ); - background.SetAnchorPoint( AnchorPoint::CENTER ); - background.SetParentOrigin( ParentOrigin::CENTER ); + background.SetProperty( Actor::Property::NAME, "BACKGROUND" ); + background.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER ); + background.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER ); background.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); return background; } @@ -231,21 +228,22 @@ void DaliTableView::SortAlphabetically( bool sortAlphabetically ) void DaliTableView::Initialize( Application& application ) { - Stage::GetCurrent().KeyEventSignal().Connect( this, &DaliTableView::OnKeyEvent ); - const Vector2 stageSize = Stage::GetCurrent().GetSize(); + Window window = application.GetWindow(); + window.KeyEventSignal().Connect( this, &DaliTableView::OnKeyEvent ); + const Window::WindowSize windowSize = window.GetSize(); // Background mRootActor = CreateBackground( "LauncherBackground" ); - Stage::GetCurrent().Add( mRootActor ); + window.Add( mRootActor ); // Add logo ImageView logo = ImageView::New( LOGO_PATH ); - logo.SetName( "LOGO_IMAGE" ); - logo.SetAnchorPoint( AnchorPoint::TOP_CENTER ); - logo.SetParentOrigin( Vector3( 0.5f, 0.1f, 0.5f ) ); + logo.SetProperty( Actor::Property::NAME, "LOGO_IMAGE" ); + logo.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_CENTER ); + logo.SetProperty( Actor::Property::PARENT_ORIGIN, Vector3( 0.5f, 0.1f, 0.5f ) ); logo.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS ); // The logo should appear on top of everything. - logo.SetDrawMode( DrawMode::OVERLAY_2D ); + logo.SetProperty( Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D ); mRootActor.Add( logo ); // Show version in a popup when log is tapped @@ -255,27 +253,27 @@ void DaliTableView::Initialize( Application& application ) // Scrollview occupying the majority of the screen mScrollView = ScrollView::New(); - mScrollView.SetAnchorPoint( AnchorPoint::BOTTOM_CENTER ); - mScrollView.SetParentOrigin( Vector3( 0.5f, 1.0f - 0.05f, 0.5f ) ); + mScrollView.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_CENTER ); + mScrollView.SetProperty( Actor::Property::PARENT_ORIGIN, Vector3( 0.5f, 1.0f - 0.05f, 0.5f ) ); mScrollView.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH ); mScrollView.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::HEIGHT ); - mScrollView.SetSizeModeFactor( Vector3( 0.0f, 0.6f, 0.0f ) ); + mScrollView.SetProperty( Actor::Property::SIZE_MODE_FACTOR, Vector3( 0.0f, 0.6f, 0.0f ) ); - const float buttonsPageMargin = ( 1.0f - TABLE_RELATIVE_SIZE.x ) * 0.5f * stageSize.width; - mScrollView.SetPadding( Padding( buttonsPageMargin, buttonsPageMargin, 0.0f, 0.0f ) ); + const float buttonsPageMargin = ( 1.0f - TABLE_RELATIVE_SIZE.x ) * 0.5f * windowSize.GetWidth(); + mScrollView.SetProperty( Actor::Property::PADDING, Padding( buttonsPageMargin, buttonsPageMargin, 0.0f, 0.0f ) ); mScrollView.SetAxisAutoLock( true ); mScrollView.ScrollCompletedSignal().Connect( this, &DaliTableView::OnScrollComplete ); mScrollView.ScrollStartedSignal().Connect( this, &DaliTableView::OnScrollStart ); mScrollView.TouchSignal().Connect( this, &DaliTableView::OnScrollTouched ); - mPageWidth = stageSize.width * TABLE_RELATIVE_SIZE.x * 0.5f; + mPageWidth = windowSize.GetWidth() * TABLE_RELATIVE_SIZE.x * 0.5f; // Populate background and bubbles - needs to be scrollViewLayer so scroll ends show Actor bubbleContainer = Actor::New(); bubbleContainer.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); - bubbleContainer.SetAnchorPoint( AnchorPoint::CENTER ); - bubbleContainer.SetParentOrigin( ParentOrigin::CENTER ); + bubbleContainer.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER ); + bubbleContainer.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER ); SetupBackground( bubbleContainer ); mRootActor.Add( bubbleContainer ); @@ -291,17 +289,26 @@ void DaliTableView::Initialize( Application& application ) ApplyCubeEffectToPages(); Dali::Window winHandle = application.GetWindow(); - winHandle.AddAvailableOrientation( Dali::Window::PORTRAIT ); - winHandle.RemoveAvailableOrientation( Dali::Window::LANDSCAPE ); - winHandle.AddAvailableOrientation( Dali::Window::PORTRAIT_INVERSE ); - winHandle.RemoveAvailableOrientation( Dali::Window::LANDSCAPE_INVERSE ); + + if( windowSize.GetWidth() <= windowSize.GetHeight() ) + { + winHandle.AddAvailableOrientation( Dali::Window::PORTRAIT ); + winHandle.RemoveAvailableOrientation( Dali::Window::LANDSCAPE ); + winHandle.AddAvailableOrientation( Dali::Window::PORTRAIT_INVERSE ); + winHandle.RemoveAvailableOrientation( Dali::Window::LANDSCAPE_INVERSE ); + } + else + { + winHandle.AddAvailableOrientation( Dali::Window::LANDSCAPE ); + winHandle.RemoveAvailableOrientation( Dali::Window::PORTRAIT ); + winHandle.AddAvailableOrientation( Dali::Window::LANDSCAPE_INVERSE ); + winHandle.RemoveAvailableOrientation( Dali::Window::PORTRAIT_INVERSE ); + } // Set initial orientation unsigned int degrees = 0; Rotate( degrees ); - winHandle.ShowIndicator( Dali::Window::INVISIBLE ); - // Background animation mAnimationTimer = Timer::New( BACKGROUND_ANIMATION_DURATION ); mAnimationTimer.TickSignal().Connect( this, &DaliTableView::PauseBackgroundAnimation ); @@ -314,8 +321,9 @@ void DaliTableView::Initialize( Application& application ) void DaliTableView::CreateFocusEffect() { // Hook the required signals to manage the focus. - KeyboardFocusManager::Get().PreFocusChangeSignal().Connect( this, &DaliTableView::OnKeyboardPreFocusChange ); - KeyboardFocusManager::Get().FocusedActorEnterKeySignal().Connect( this, &DaliTableView::OnFocusedActorActivated ); + auto keyboardFocusManager = KeyboardFocusManager::Get(); + keyboardFocusManager.PreFocusChangeSignal().Connect( this, &DaliTableView::OnKeyboardPreFocusChange ); + keyboardFocusManager.FocusedActorEnterKeySignal().Connect( this, &DaliTableView::OnFocusedActorActivated ); AccessibilityManager::Get().FocusedActorActivatedSignal().Connect( this, &DaliTableView::OnFocusedActorActivated ); // Loop to create both actors for the focus highlight effect. @@ -323,36 +331,54 @@ void DaliTableView::CreateFocusEffect() { mFocusEffect[i].actor = ImageView::New(); mFocusEffect[i].actor.SetStyleName( "FocusActor" ); - mFocusEffect[i].actor.SetParentOrigin( ParentOrigin::CENTER ); + mFocusEffect[i].actor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER ); mFocusEffect[i].actor.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); - mFocusEffect[i].actor.SetInheritScale( false ); - mFocusEffect[i].actor.SetColorMode( USE_OWN_COLOR ); + mFocusEffect[i].actor.SetProperty( Actor::Property::INHERIT_SCALE, false ); + mFocusEffect[i].actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_COLOR ); - // Setup initial values pre-animation. - mFocusEffect[i].actor.SetScale( startScale ); - mFocusEffect[i].actor.SetOpacity( 0.0f ); + KeyFrames alphaKeyFrames = KeyFrames::New(); + alphaKeyFrames.Add( 0.0f, KEYBOARD_FOCUS_FINAL_ALPHA ); + alphaKeyFrames.Add( KEYBOARD_FOCUS_MID_KEY_FRAME_TIME, KEYBOARD_FOCUS_ANIMATING_ALPHA ); + alphaKeyFrames.Add( KEYBOARD_FOCUS_ANIMATION_DURATION, KEYBOARD_FOCUS_FINAL_ALPHA ); - // Create and setup the animation to do the following: - // 1) Initial fade in over short period of time - // 2) Zoom in (larger) and fade out simultaneously over longer period of time. - mFocusEffect[i].animation = Animation::New( KEYBOARD_FOCUS_ANIMATION_DURATION ); + KeyFrames scaleKeyFrames = KeyFrames::New(); + scaleKeyFrames.Add( 0.0f, KEYBOARD_FOCUS_FINAL_SCALE ); + scaleKeyFrames.Add( KEYBOARD_FOCUS_MID_KEY_FRAME_TIME, FOCUS_INDICATOR_ANIMATING_SCALE ); + scaleKeyFrames.Add( KEYBOARD_FOCUS_ANIMATION_DURATION, KEYBOARD_FOCUS_FINAL_SCALE ); - mFocusEffect[i].animation.AnimateTo( Property( mFocusEffect[i].actor, Actor::Property::COLOR_ALPHA ), KEYBOARD_FOCUS_END_ALPHA, AlphaFunction::LINEAR, TimePeriod( 0.0f, initialFadeDuration ) ); - mFocusEffect[i].animation.AnimateTo( Property( mFocusEffect[i].actor, Actor::Property::SCALE ), endScale, AlphaFunction::LINEAR, TimePeriod( initialFadeDuration, KEYBOARD_FOCUS_ANIMATION_DURATION - initialFadeDuration ) ); - mFocusEffect[i].animation.AnimateTo( Property( mFocusEffect[i].actor, Actor::Property::COLOR_ALPHA ), 0.0f, AlphaFunction::LINEAR, TimePeriod( initialFadeDuration, KEYBOARD_FOCUS_ANIMATION_DURATION - initialFadeDuration ) ); + mFocusEffect[i].animation = Animation::New( KEYBOARD_FOCUS_ANIMATION_DURATION ); + mFocusEffect[i].animation.AnimateBetween( Property( mFocusEffect[i].actor, Actor::Property::COLOR_ALPHA ), alphaKeyFrames ); + mFocusEffect[i].animation.AnimateBetween( Property( mFocusEffect[i].actor, Actor::Property::SCALE ), scaleKeyFrames ); - mFocusEffect[i].animation.SetLooping( true ); + mFocusEffect[i].animation.SetLoopCount( KEYBOARD_FOCUS_ANIMATION_LOOP_COUNT ); } // Parent the secondary effect from the primary. mFocusEffect[0].actor.Add( mFocusEffect[1].actor ); + keyboardFocusManager.SetFocusIndicatorActor( mFocusEffect[0].actor ); + + // Connect to the on & off scene signals of the indicator which represents when it is enabled & disabled respectively + mFocusEffect[0].actor.OnSceneSignal().Connect( this, &DaliTableView::OnFocusIndicatorEnabled ); + mFocusEffect[0].actor.OffSceneSignal().Connect( this, &DaliTableView::OnFocusIndicatorDisabled ); +} + +void DaliTableView::OnFocusIndicatorEnabled( Actor /* actor */ ) +{ // Play the animation on the 1st glow object. mFocusEffect[0].animation.Play(); - // Stagger the animation on the 2st glow object half way through. + + // Stagger the animation on the 2nd glow object half way through. mFocusEffect[1].animation.PlayFrom( KEYBOARD_FOCUS_ANIMATION_DURATION / 2.0f ); +} - KeyboardFocusManager::Get().SetFocusIndicatorActor( mFocusEffect[0].actor ); +void DaliTableView::OnFocusIndicatorDisabled( Dali::Actor /* actor */ ) +{ + // Stop the focus effect animations + for( auto i = 0u; i < FOCUS_ANIMATION_ACTOR_NUMBER; ++i ) + { + mFocusEffect[ i ].animation.Stop(); + } } void DaliTableView::ApplyCubeEffectToPages() @@ -372,7 +398,7 @@ void DaliTableView::OnButtonsPageRelayout( const Dali::Actor& actor ) void DaliTableView::Populate() { - const Vector2 stageSize = Stage::GetCurrent().GetSize(); + const Window::WindowSize windowSize = mApplication.GetWindow().GetSize(); mTotalPages = ( mExampleList.size() + EXAMPLES_PER_PAGE - 1 ) / EXAMPLES_PER_PAGE; @@ -391,8 +417,8 @@ void DaliTableView::Populate() { // Create Table TableView page = TableView::New( ROWS_PER_PAGE, EXAMPLES_PER_ROW ); - page.SetAnchorPoint( AnchorPoint::CENTER ); - page.SetParentOrigin( ParentOrigin::CENTER ); + page.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER ); + page.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER ); page.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); mScrollView.Add( page ); @@ -417,7 +443,7 @@ void DaliTableView::Populate() accessibilityManager.SetAccessibilityAttribute( tile, Dali::Toolkit::AccessibilityManager::ACCESSIBILITY_HINT, "You can run this example" ); - tile.SetPadding( Padding( margin, margin, margin, margin ) ); + tile.SetProperty( Actor::Property::PADDING, Padding( margin, margin, margin, margin ) ); page.AddChild( tile, TableView::CellPosition( row, column ) ); iter++; @@ -446,7 +472,7 @@ void DaliTableView::Populate() // Update Ruler info. mScrollRulerX = new FixedRuler( mPageWidth ); mScrollRulerY = new DefaultRuler(); - mScrollRulerX->SetDomain( RulerDomain( 0.0f, (mTotalPages+1) * stageSize.width * TABLE_RELATIVE_SIZE.x * 0.5f, true ) ); + mScrollRulerX->SetDomain( RulerDomain( 0.0f, (mTotalPages+1) * windowSize.GetWidth() * TABLE_RELATIVE_SIZE.x * 0.5f, true ) ); mScrollRulerY->Disable(); mScrollView.SetRulerX( mScrollRulerX ); mScrollView.SetRulerY( mScrollRulerY ); @@ -455,12 +481,13 @@ void DaliTableView::Populate() void DaliTableView::Rotate( unsigned int degrees ) { // Resize the root actor - Vector2 stageSize = Stage::GetCurrent().GetSize(); - Vector3 targetSize( stageSize.x, stageSize.y, 1.0f ); + const Window::WindowSize windowSize = mApplication.GetWindow().GetSize(); + const Vector2 originalSize( windowSize.GetWidth(), windowSize.GetHeight() ); + Vector3 targetSize( originalSize.x, originalSize.y, 1.0f ); if( degrees == 90 || degrees == 270 ) { - targetSize = Vector3( stageSize.y, stageSize.x, 1.0f ); + targetSize = Vector3( originalSize.y, originalSize.x, 1.0f ); } if( mRotateAnimation ) @@ -480,13 +507,13 @@ Actor DaliTableView::CreateTile( const std::string& name, const std::string& tit Toolkit::ImageView focusableTile = ImageView::New(); focusableTile.SetStyleName( "DemoTile" ); - focusableTile.SetParentOrigin( ParentOrigin::CENTER ); + focusableTile.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER ); focusableTile.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS ); - focusableTile.SetSizeModeFactor( sizeMultiplier ); - focusableTile.SetName( name ); + focusableTile.SetProperty( Actor::Property::SIZE_MODE_FACTOR, sizeMultiplier ); + focusableTile.SetProperty( Actor::Property::NAME, name ); // Set the tile to be keyboard focusable - focusableTile.SetKeyboardFocusable( true ); + focusableTile.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE, true ); // Register a property with the ImageView. This allows us to inject the scroll-view position into the shader. Property::Value value = Vector3( 0.0f, 0.0f, 0.0f ); @@ -503,15 +530,15 @@ Actor DaliTableView::CreateTile( const std::string& name, const std::string& tit // Create an ImageView for the 9-patch border around the tile. ImageView borderImage = ImageView::New(); borderImage.SetStyleName("DemoTileBorder"); - borderImage.SetAnchorPoint( AnchorPoint::CENTER ); - borderImage.SetParentOrigin( ParentOrigin::CENTER ); + borderImage.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER ); + borderImage.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER ); borderImage.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); - borderImage.SetOpacity( 0.8f ); + borderImage.SetProperty( Actor::Property::OPACITY, 0.8f ); focusableTile.Add( borderImage ); TextLabel label = TextLabel::New(); - label.SetAnchorPoint( AnchorPoint::CENTER ); - label.SetParentOrigin( ParentOrigin::CENTER ); + label.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER ); + label.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER ); label.SetStyleName( "LauncherLabel" ); label.SetProperty( TextLabel::Property::MULTI_LINE, true ); label.SetProperty( TextLabel::Property::TEXT, title ); @@ -520,7 +547,7 @@ Actor DaliTableView::CreateTile( const std::string& name, const std::string& tit label.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::HEIGHT ); // Pad around the label as its size is the same as the 9-patch border. It will overlap it without padding. - label.SetPadding( Padding( TILE_LABEL_PADDING, TILE_LABEL_PADDING, TILE_LABEL_PADDING, TILE_LABEL_PADDING ) ); + label.SetProperty( Actor::Property::PADDING, Padding( TILE_LABEL_PADDING, TILE_LABEL_PADDING, TILE_LABEL_PADDING, TILE_LABEL_PADDING ) ); focusableTile.Add( label ); // Connect to the touch events @@ -530,7 +557,7 @@ Actor DaliTableView::CreateTile( const std::string& name, const std::string& tit return focusableTile; } -bool DaliTableView::OnTilePressed( Actor actor, const TouchData& event ) +bool DaliTableView::OnTilePressed( Actor actor, const TouchEvent& event ) { return DoTilePress( actor, event.GetState( 0 ) ); } @@ -553,7 +580,7 @@ bool DaliTableView::DoTilePress( Actor actor, PointState::Type pointState ) // ignore Example button presses when scrolling or button animating. if( ( !mScrolling ) && ( !mPressedAnimation ) ) { - std::string name = actor.GetName(); + std::string name = actor.GetProperty< std::string >( Dali::Actor::Property::NAME ); const ExampleListIter end = mExampleList.end(); for( ExampleListIter iter = mExampleList.begin(); iter != end; ++iter ) { @@ -593,16 +620,10 @@ void DaliTableView::OnPressedAnimationFinished( Dali::Animation& source ) mPressedAnimation.Reset(); if( mPressedActor ) { - std::string name = mPressedActor.GetName(); + std::string name = mPressedActor.GetProperty< std::string >( Dali::Actor::Property::NAME ); + + ExecuteProcess( name, mApplication ); - std::stringstream stream; - stream << DEMO_EXAMPLE_BIN << name.c_str(); - pid_t pid = fork(); - if( pid == 0) - { - execlp( stream.str().c_str(), name.c_str(), NULL ); - DALI_ASSERT_ALWAYS(false && "exec failed!"); - } mPressedActor.Reset(); } } @@ -623,7 +644,7 @@ void DaliTableView::OnScrollComplete( const Dali::Vector2& position ) accessibilityManager.SetCurrentFocusActor(mPages[mScrollView.GetCurrentPage()].GetChildAt(0) ); } -bool DaliTableView::OnScrollTouched( Actor actor, const TouchData& event ) +bool DaliTableView::OnScrollTouched( Actor actor, const TouchEvent& event ) { if( PointState::DOWN == event.GetState( 0 ) ) { @@ -650,29 +671,30 @@ void DaliTableView::ApplyScrollViewEffect() void DaliTableView::SetupInnerPageCubeEffect() { - const Vector2 stageSize = Stage::GetCurrent().GetSize(); + const Window::WindowSize windowDimensions = mApplication.GetWindow().GetSize(); + const Vector2 windowSize(windowDimensions.GetWidth(), windowDimensions.GetHeight()); Dali::Path path = Dali::Path::New(); Dali::Property::Array points; points.Resize(3); - points[0] = Vector3( stageSize.x*0.5, 0.0f, stageSize.x*0.5f); + points[0] = Vector3( windowSize.x*0.5, 0.0f, windowSize.x*0.5f); points[1] = Vector3( 0.0f, 0.0f, 0.0f ); - points[2] = Vector3( -stageSize.x*0.5f, 0.0f, stageSize.x*0.5f); + points[2] = Vector3( -windowSize.x*0.5f, 0.0f, windowSize.x*0.5f); path.SetProperty( Path::Property::POINTS, points ); Dali::Property::Array controlPoints; controlPoints.Resize(4); - controlPoints[0] = Vector3( stageSize.x*0.5f, 0.0f, stageSize.x*0.3f ); - controlPoints[1] = Vector3( stageSize.x*0.3f, 0.0f, 0.0f ); - controlPoints[2] = Vector3(-stageSize.x*0.3f, 0.0f, 0.0f ); - controlPoints[3] = Vector3(-stageSize.x*0.5f, 0.0f, stageSize.x*0.3f ); + controlPoints[0] = Vector3( windowSize.x*0.5f, 0.0f, windowSize.x*0.3f ); + controlPoints[1] = Vector3( windowSize.x*0.3f, 0.0f, 0.0f ); + controlPoints[2] = Vector3(-windowSize.x*0.3f, 0.0f, 0.0f ); + controlPoints[3] = Vector3(-windowSize.x*0.5f, 0.0f, windowSize.x*0.3f ); path.SetProperty( Path::Property::CONTROL_POINTS, controlPoints ); mScrollViewEffect = ScrollViewPagePathEffect::New(path, Vector3(-1.0f,0.0f,0.0f), Toolkit::ScrollView::Property::SCROLL_FINAL_X, - Vector3(stageSize.x*TABLE_RELATIVE_SIZE.x,stageSize.y*TABLE_RELATIVE_SIZE.y,0.0f),mTotalPages); + Vector3(windowSize.x*TABLE_RELATIVE_SIZE.x,windowSize.y*TABLE_RELATIVE_SIZE.y,0.0f),mTotalPages); } void DaliTableView::OnKeyEvent( const KeyEvent& event ) @@ -719,7 +741,7 @@ void DaliTableView::InitialiseBackgroundActors( Actor actor ) Random::Range( -size.y, size.y ), Random::Range( BUBBLE_MIN_Z, BUBBLE_MAX_Z ) ); - child.SetPosition( childPos ); + child.SetProperty( Actor::Property::POSITION, childPos ); // Define bubble horizontal parallax and vertical wrapping Constraint animConstraint = Constraint::New < Vector3 > ( child, Actor::Property::POSITION, AnimateBubbleConstraint( childPos, Random::Range( -0.85f, 0.25f ) ) ); @@ -746,17 +768,17 @@ void DaliTableView::AddBackgroundActors( Actor layer, int count ) int shapeType = static_cast( Random::Range( 0.0f, NUMBER_OF_SHAPE_IMAGES - 1 ) + 0.5f ); ImageView dfActor = ImageView::New(); - dfActor.SetSize( Vector2( randSize, randSize ) ); - dfActor.SetParentOrigin( ParentOrigin::CENTER ); + dfActor.SetProperty( Actor::Property::SIZE, Vector2( randSize, randSize ) ); + dfActor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER ); // Set the Image URL and the custom shader at the same time Dali::Property::Map effect = Toolkit::CreateDistanceFieldEffect(); Property::Map imageMap; imageMap.Add( ImageVisual::Property::URL, SHAPE_IMAGE_TABLE[ shapeType ] ); - imageMap.Add( Visual::Property::SHADER, effect ); + imageMap.Add( Toolkit::Visual::Property::SHADER, effect ); dfActor.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap ); - dfActor.SetColor( BUBBLE_COLOR[ i%NUMBER_OF_BUBBLE_COLOR ] ); + dfActor.SetStyleName( BUBBLE_COLOR_STYLE_NAME[ i%NUMBER_OF_BUBBLE_COLORS ] ); layer.Add( dfActor ); } @@ -891,28 +913,31 @@ void DaliTableView::OnLogoTapped( Dali::Actor actor, const Dali::TapGesture& tap stream << "DALi Core: " << CORE_MAJOR_VERSION << "." << CORE_MINOR_VERSION << "." << CORE_MICRO_VERSION << std::endl << "(" << CORE_BUILD_DATE << ")\n"; stream << "DALi Adaptor: " << ADAPTOR_MAJOR_VERSION << "." << ADAPTOR_MINOR_VERSION << "." << ADAPTOR_MICRO_VERSION << std::endl << "(" << ADAPTOR_BUILD_DATE << ")\n"; stream << "DALi Toolkit: " << TOOLKIT_MAJOR_VERSION << "." << TOOLKIT_MINOR_VERSION << "." << TOOLKIT_MICRO_VERSION << std::endl << "(" << TOOLKIT_BUILD_DATE << ")\n"; + stream << "DALi Demo:" << "\n(" << DEMO_BUILD_DATE << ")\n"; mVersionPopup = Dali::Toolkit::Popup::New(); Toolkit::TextLabel titleActor = Toolkit::TextLabel::New( "Version information" ); - titleActor.SetName( "titleActor" ); - titleActor.SetProperty( Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" ); + titleActor.SetProperty( Actor::Property::NAME, "titleActor" ); + titleActor.SetProperty( Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, HorizontalAlignment::CENTER ); + titleActor.SetProperty( Toolkit::TextLabel::Property::TEXT_COLOR, Color::WHITE ); Toolkit::TextLabel contentActor = Toolkit::TextLabel::New( stream.str() ); - contentActor.SetName( "contentActor" ); + contentActor.SetProperty( Actor::Property::NAME, "contentActor" ); contentActor.SetProperty( Toolkit::TextLabel::Property::MULTI_LINE, true ); - contentActor.SetProperty( Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" ); - contentActor.SetPadding( Padding( 0.0f, 0.0f, 20.0f, 0.0f ) ); + contentActor.SetProperty( Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, HorizontalAlignment::CENTER ); + contentActor.SetProperty( Toolkit::TextLabel::Property::TEXT_COLOR, Color::WHITE ); + contentActor.SetProperty( Actor::Property::PADDING, Padding( 0.0f, 0.0f, 20.0f, 0.0f ) ); mVersionPopup.SetTitle( titleActor ); mVersionPopup.SetContent( contentActor ); mVersionPopup.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::WIDTH ); - mVersionPopup.SetSizeModeFactor( Vector3( 0.75f, 1.0f, 1.0f ) ); + mVersionPopup.SetProperty( Actor::Property::SIZE_MODE_FACTOR, Vector3( 0.75f, 1.0f, 1.0f ) ); mVersionPopup.SetResizePolicy( ResizePolicy::FIT_TO_CHILDREN, Dimension::HEIGHT ); mVersionPopup.OutsideTouchedSignal().Connect( this, &DaliTableView::HideVersionPopup ); - Stage::GetCurrent().Add( mVersionPopup ); + mApplication.GetWindow().Add( mVersionPopup ); } mVersionPopup.SetDisplayState( Popup::SHOWN );