X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=demo%2Fdali-table-view.cpp;h=daebe612eed5d23bc3e77b7640b2b0c4d62c7955;hb=5231d448dc1154a1e0f55242e60e3a9166c97d51;hp=166db0bbe0c47336f0114bc444f6708589673ea1;hpb=4ac5ac3ce0f0740cea5c8769be306985cd1bf315;p=platform%2Fcore%2Fuifw%2Fdali-demo.git diff --git a/demo/dali-table-view.cpp b/demo/dali-table-view.cpp index 166db0b..daebe61 100644 --- a/demo/dali-table-view.cpp +++ b/demo/dali-table-view.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2015 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. @@ -37,18 +37,10 @@ using namespace Dali::Toolkit; namespace { -const std::string BUTTON_BACKWARD( "Backward" ); -const std::string BUTTON_FORWARD( "Forward" ); -const std::string BUTTON_QUIT( "Quit" ); -const std::string BUTTON_OK( "Ok" ); -const std::string BUTTON_CANCEL( "Cancel" ); - -const std::string DEFAULT_BACKGROUND_IMAGE_PATH( DALI_IMAGE_DIR "background-gradient.jpg" ); -const std::string LOGO_PATH( DALI_IMAGE_DIR "dali-logo.png" ); -const std::string DEFAULT_TOOLBAR_IMAGE_PATH( DALI_IMAGE_DIR "top-bar.png" ); -const std::string BUTTON_BACKGROUND(DALI_IMAGE_DIR "button-background.png"); -const std::string TILE_BACKGROUND(DALI_IMAGE_DIR "item-background.png"); -const std::string TILE_BACKGROUND_ALPHA(DALI_IMAGE_DIR "item-background-alpha.png"); +const std::string LOGO_PATH( DEMO_IMAGE_DIR "Logo-for-demo.png" ); +const std::string DEFAULT_TOOLBAR_IMAGE_PATH( DEMO_IMAGE_DIR "top-bar.png" ); +const std::string TILE_BACKGROUND(DEMO_IMAGE_DIR "item-background.9.png"); +const std::string TILE_BACKGROUND_ALPHA(DEMO_IMAGE_DIR "item-background-alpha.9.png"); const char * const DEFAULT_TOOLBAR_TEXT( "TOUCH TO LAUNCH EXAMPLE" ); @@ -68,7 +60,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[] = +{ + Vector4( 0.3255f, 0.3412f, 0.6353f, 0.38f ), + Vector4( 0.3647f, 0.7569f, 0.8157f, 0.38f ), + Vector4( 0.3804f, 0.7412f, 0.6510f, 0.38f ), + Vector4( 1.f, 1.f, 1.f, 0.2f ) +}; +const int NUMBER_OF_BUBBLE_COLOR( sizeof(BUBBLE_COLOR) / sizeof(BUBBLE_COLOR[0]) ); const int NUM_BACKGROUND_IMAGES = 18; const float BACKGROUND_SWIPE_SCALE = 0.025f; @@ -79,8 +78,7 @@ const float SCALE_SPEED_SIN = 0.1f; const unsigned int BACKGROUND_ANIMATION_DURATION = 15000; // 15 secs -const float BACKGROUND_Z = -1.0f; -const Vector4 BACKGROUND_COLOR( 1.0f, 1.0f, 1.0f, 1.0f ); +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; @@ -88,25 +86,19 @@ const float BUBBLE_MAX_Z = 0.0f; /** * Creates the background image */ -ImageActor CreateBackground( std::string imagePath ) +Control CreateBackground( std::string stylename ) { - Image image = ResourceImage::New( imagePath ); - ImageActor background = ImageActor::New( image ); + Control background = Control::New(); + Stage::GetCurrent().Add( background ); + background.SetProperty( Control::Property::STYLE_NAME,stylename); background.SetName( "BACKGROUND" ); background.SetAnchorPoint( AnchorPoint::CENTER ); background.SetParentOrigin( ParentOrigin::CENTER ); - background.SetZ( -1.0f ); background.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); return background; } -// These values depend on the tile image -const float IMAGE_BORDER_LEFT = 11.0f; -const float IMAGE_BORDER_RIGHT = IMAGE_BORDER_LEFT; -const float IMAGE_BORDER_TOP = IMAGE_BORDER_LEFT; -const float IMAGE_BORDER_BOTTOM = IMAGE_BORDER_LEFT; - /** * Constraint to return a position for a bubble based on the scroll value and vertical wrapping */ @@ -114,8 +106,8 @@ struct AnimateBubbleConstraint { public: AnimateBubbleConstraint( const Vector3& initialPos, float scale ) - : mInitialX( initialPos.x ), - mScale( scale ) + : mInitialX( initialPos.x ), + mScale( scale ) { } @@ -124,11 +116,10 @@ public: const Vector3& parentSize = inputs[1]->GetVector3(); const Vector3& childSize = inputs[2]->GetVector3(); - // Wrap bubbles verically. - if( position.y + childSize.y * 0.5f < -parentSize.y * 0.5f ) - { - position.y = parentSize.y * 0.5f + childSize.y * 0.5f; - } + // Wrap bubbles vertically. + float range = parentSize.y + childSize.y; + // This performs a float mod (we don't use fmod as we want the arithmetic modulus as opposed to the remainder). + position.y -= range * ( floor( position.y / range ) + 0.5f ); // Bubbles X position moves parallax to horizontal // panning by a scale factor unique to each bubble. @@ -138,7 +129,6 @@ public: private: float mInitialX; float mScale; - float mShapeSize; }; bool CompareByTitle( const Example& lhs, const Example& rhs ) @@ -153,31 +143,23 @@ DaliTableView::DaliTableView( Application& application ) mBackgroundLayer(), mRootActor(), mRotateAnimation(), - mBackground(), mPressedAnimation(), mScrollViewLayer(), mScrollView(), mScrollViewEffect(), mScrollRulerX(), mScrollRulerY(), - mButtons(), mPressedActor(), mAnimationTimer(), mLogoTapDetector(), mVersionPopup(), - mButtonsPageRelativeSize(), mPages(), - mTableViewImages(), - mBackgroundActors(), mBackgroundAnimations(), mExampleList(), - mExampleMap(), - mBackgroundImagePath( DEFAULT_BACKGROUND_IMAGE_PATH ), mTotalPages(), mScrolling( false ), mSortAlphabetically( false ), - mBackgroundAnimsPlaying( false ), - mVersionPopupShown( false ) + mBackgroundAnimsPlaying( false ) { application.InitSignal().Connect( this, &DaliTableView::Initialize ); } @@ -189,12 +171,6 @@ DaliTableView::~DaliTableView() void DaliTableView::AddExample( Example example ) { mExampleList.push_back( example ); - mExampleMap[ example.name ] = example; -} - -void DaliTableView::SetBackgroundPath( std::string imagePath ) -{ - mBackgroundImagePath = imagePath; } void DaliTableView::SortAlphabetically( bool sortAlphabetically ) @@ -209,10 +185,10 @@ void DaliTableView::Initialize( Application& application ) const Vector2 stageSize = Stage::GetCurrent().GetSize(); // Background - Actor background = CreateBackground( mBackgroundImagePath ); + Control background = CreateBackground( "launcherbackground" ); Stage::GetCurrent().Add( background ); - // Render entire content as overlays, as is all on same 2D plane. + // Add root actor mRootActor = TableView::New( 4, 1 ); mRootActor.SetAnchorPoint( AnchorPoint::CENTER ); mRootActor.SetParentOrigin( ParentOrigin::CENTER ); @@ -230,7 +206,7 @@ void DaliTableView::Initialize( Application& application ) mRootActor.SetFitHeight( 0 ); // Add logo - Dali::ImageActor logo = CreateLogo( LOGO_PATH ); + ImageView logo = CreateLogo( LOGO_PATH ); logo.SetName( "LOGO_IMAGE" ); logo.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS ); const float paddingHeight = ( ( 1.f-TABLE_RELATIVE_SIZE.y ) * stageSize.y ); @@ -265,21 +241,24 @@ void DaliTableView::Initialize( Application& application ) mScrollView.SetAxisAutoLock( true ); mScrollView.ScrollCompletedSignal().Connect( this, &DaliTableView::OnScrollComplete ); mScrollView.ScrollStartedSignal().Connect( this, &DaliTableView::OnScrollStart ); - mScrollView.TouchedSignal().Connect( this, &DaliTableView::OnScrollTouched ); + mScrollView.TouchSignal().Connect( this, &DaliTableView::OnScrollTouched ); mScrollViewLayer = Layer::New(); + + // Disable the depth test for performance + mScrollViewLayer.SetDepthTestDisabled( true ); mScrollViewLayer.SetAnchorPoint( AnchorPoint::CENTER ); mScrollViewLayer.SetParentOrigin( ParentOrigin::CENTER ); - mScrollViewLayer.SetDrawMode( DrawMode::OVERLAY ); mScrollViewLayer.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); // Create solid background colour. - ImageActor backgroundColourActor = Dali::Toolkit::CreateSolidColorActor( BACKGROUND_COLOR ); + Control backgroundColourActor = Control::New(); + backgroundColourActor.SetBackgroundColor( BACKGROUND_COLOR ); backgroundColourActor.SetAnchorPoint( AnchorPoint::CENTER ); backgroundColourActor.SetParentOrigin( ParentOrigin::CENTER ); backgroundColourActor.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS ); backgroundColourActor.SetSizeModeFactor( Vector3( 1.0f, 1.5f, 1.0f ) ); - backgroundColourActor.SetZ( BACKGROUND_Z ); + mScrollViewLayer.Add( backgroundColourActor ); // Populate background and bubbles - needs to be scrollViewLayer so scroll ends show @@ -287,7 +266,7 @@ void DaliTableView::Initialize( Application& application ) bubbleContainer.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); bubbleContainer.SetAnchorPoint( AnchorPoint::CENTER ); bubbleContainer.SetParentOrigin( ParentOrigin::CENTER ); - mScrollViewLayer.Add( bubbleContainer ); + backgroundColourActor.Add( bubbleContainer ); SetupBackground( bubbleContainer ); @@ -320,8 +299,6 @@ void DaliTableView::Initialize( Application& application ) unsigned int degrees = 0; Rotate( degrees ); - //orientation.ChangedSignal().Connect( this, &DaliTableView::OrientationChanged ); - winHandle.ShowIndicator( Dali::Window::INVISIBLE ); // Background animation @@ -331,7 +308,8 @@ void DaliTableView::Initialize( Application& application ) mBackgroundAnimsPlaying = true; KeyboardFocusManager::Get().PreFocusChangeSignal().Connect( this, &DaliTableView::OnKeyboardPreFocusChange ); - KeyboardFocusManager::Get().FocusedActorActivatedSignal().Connect( this, &DaliTableView::OnFocusedActorActivated ); + KeyboardFocusManager::Get().FocusedActorEnterKeySignal().Connect( this, &DaliTableView::OnFocusedActorActivated ); + AccessibilityManager::Get().FocusedActorActivatedSignal().Connect( this, &DaliTableView::OnFocusedActorActivated ); } void DaliTableView::ApplyCubeEffectToPages() @@ -369,8 +347,8 @@ void DaliTableView::Populate() for( int t = 0; t < mTotalPages; t++ ) { - // Create Table. (contains up to 9 Examples) - TableView page = TableView::New( 3, 3 ); + // Create Table + TableView page = TableView::New( ROWS_PER_PAGE, EXAMPLES_PER_ROW ); page.SetAnchorPoint( AnchorPoint::CENTER ); page.SetParentOrigin( ParentOrigin::CENTER ); page.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); @@ -387,12 +365,12 @@ void DaliTableView::Populate() const Example& example = ( *iter ); Actor tile = CreateTile( example.name, example.title, Vector3( tileParentMultiplier, tileParentMultiplier, 1.0f ), true ); - FocusManager focusManager = FocusManager::Get(); - focusManager.SetFocusOrder( tile, ++exampleCount ); - focusManager.SetAccessibilityAttribute( tile, Dali::Toolkit::FocusManager::ACCESSIBILITY_LABEL, + AccessibilityManager accessibilityManager = AccessibilityManager::Get(); + accessibilityManager.SetFocusOrder( tile, ++exampleCount ); + accessibilityManager.SetAccessibilityAttribute( tile, Dali::Toolkit::AccessibilityManager::ACCESSIBILITY_LABEL, example.title ); - focusManager.SetAccessibilityAttribute( tile, Dali::Toolkit::FocusManager::ACCESSIBILITY_TRAIT, "Tile" ); - focusManager.SetAccessibilityAttribute( tile, Dali::Toolkit::FocusManager::ACCESSIBILITY_HINT, + accessibilityManager.SetAccessibilityAttribute( tile, Dali::Toolkit::AccessibilityManager::ACCESSIBILITY_TRAIT, "Tile" ); + accessibilityManager.SetAccessibilityAttribute( tile, Dali::Toolkit::AccessibilityManager::ACCESSIBILITY_HINT, "You can run this example" ); tile.SetPadding( Padding( margin, margin, margin, margin ) ); @@ -435,11 +413,6 @@ void DaliTableView::Populate() mScrollView.SetRulerY( mScrollRulerY ); } -void DaliTableView::OrientationChanged( Orientation orientation ) -{ - // TODO: Implement if orientation change required -} - void DaliTableView::Rotate( unsigned int degrees ) { // Resize the root actor @@ -475,21 +448,16 @@ Actor DaliTableView::CreateTile( const std::string& name, const std::string& tit // create background image if( addBackground ) { - Image bg = ResourceImage::New( TILE_BACKGROUND ); - ImageActor image = ImageActor::New( bg ); + ImageView image = ImageView::New( TILE_BACKGROUND ); image.SetAnchorPoint( AnchorPoint::CENTER ); image.SetParentOrigin( ParentOrigin::CENTER ); // make the image 100% of tile image.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); - // move image back to get text appear in front - image.SetZ( -1 ); - image.SetStyle( ImageActor::STYLE_NINE_PATCH ); - image.SetNinePatchBorder( Vector4( IMAGE_BORDER_LEFT, IMAGE_BORDER_TOP, IMAGE_BORDER_RIGHT, IMAGE_BORDER_BOTTOM ) ); content.Add( image ); // Add stencil - ImageActor stencil = NewStencilImage(); + Toolkit::ImageView stencil = NewStencilImage(); stencil.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); image.Add( stencil ); } @@ -508,36 +476,35 @@ Actor DaliTableView::CreateTile( const std::string& name, const std::string& tit content.SetKeyboardFocusable(true); // connect to the touch events - content.TouchedSignal().Connect( this, &DaliTableView::OnTilePressed ); + content.TouchSignal().Connect( this, &DaliTableView::OnTilePressed ); content.HoveredSignal().Connect( this, &DaliTableView::OnTileHovered ); return content; } -ImageActor DaliTableView::NewStencilImage() +Toolkit::ImageView DaliTableView::NewStencilImage() { - Image alpha = ResourceImage::New( TILE_BACKGROUND_ALPHA ); - - ImageActor stencilActor = ImageActor::New( alpha ); - stencilActor.SetStyle( ImageActor::STYLE_NINE_PATCH ); - stencilActor.SetNinePatchBorder( Vector4( IMAGE_BORDER_LEFT, IMAGE_BORDER_TOP, IMAGE_BORDER_RIGHT, IMAGE_BORDER_BOTTOM ) ); + Toolkit::ImageView stencil = ImageView::New( TILE_BACKGROUND_ALPHA ); + stencil.SetParentOrigin( ParentOrigin::CENTER ); + stencil.SetAnchorPoint( AnchorPoint::CENTER ); + stencil.SetDrawMode( DrawMode::STENCIL ); - stencilActor.SetParentOrigin( ParentOrigin::CENTER ); - stencilActor.SetAnchorPoint( AnchorPoint::CENTER ); - stencilActor.SetDrawMode( DrawMode::STENCIL ); + Property::Map shaderEffect = CreateAlphaDiscardEffect(); + stencil.SetProperty( Toolkit::ImageView::Property::IMAGE, shaderEffect ); - Dali::ShaderEffect shaderEffect = AlphaDiscardEffect::New(); - stencilActor.SetShaderEffect( shaderEffect ); + return stencil; +} - return stencilActor; +bool DaliTableView::OnTilePressed( Actor actor, const TouchData& event ) +{ + return DoTilePress( actor, event.GetState( 0 ) ); } -bool DaliTableView::OnTilePressed( Actor actor, const TouchEvent& event ) +bool DaliTableView::DoTilePress( Actor actor, PointState::Type pointState ) { bool consumed = false; - const TouchPoint& point = event.GetPoint( 0 ); - if( TouchPoint::Down == point.state ) + if( PointState::DOWN == pointState ) { mPressedActor = actor; consumed = true; @@ -545,21 +512,22 @@ bool DaliTableView::OnTilePressed( Actor actor, const TouchEvent& event ) // A button press is only valid if the Down & Up events // both occurred within the button. - if( ( TouchPoint::Up == point.state ) && + if( ( PointState::UP == pointState ) && ( mPressedActor == actor ) ) { - std::string name = actor.GetName(); - ExampleMapConstIter iter = mExampleMap.find( name ); - - FocusManager focusManager = FocusManager::Get(); - - if( iter != mExampleMap.end() ) + // ignore Example button presses when scrolling or button animating. + if( ( !mScrolling ) && ( !mPressedAnimation ) ) { - // ignore Example button presses when scrolling or button animating. - if( ( !mScrolling ) && ( !mPressedAnimation ) ) + std::string name = actor.GetName(); + const ExampleListIter end = mExampleList.end(); + for( ExampleListIter iter = mExampleList.begin(); iter != end; ++iter ) { - // do nothing, until pressed animation finished. - consumed = true; + if( (*iter).name == name ) + { + // do nothing, until pressed animation finished. + consumed = true; + break; + } } } @@ -587,32 +555,14 @@ void DaliTableView::OnPressedAnimationFinished( Dali::Animation& source ) if( mPressedActor ) { std::string name = mPressedActor.GetName(); - ExampleMapConstIter iter = mExampleMap.find( name ); - - if( iter == mExampleMap.end() ) - { - if( name == BUTTON_QUIT ) - { - // Move focus to the OK button - FocusManager focusManager = FocusManager::Get(); - // Enable the group mode and wrap mode - focusManager.SetGroupMode( true ); - focusManager.SetWrapMode( true ); - } - } - else + std::stringstream stream; + stream << DEMO_EXAMPLE_BIN << name.c_str(); + pid_t pid = fork(); + if( pid == 0) { - const Example& example( iter->second ); - - std::stringstream stream; - stream << DALI_EXAMPLE_BIN << example.name.c_str(); - pid_t pid = fork(); - if( pid == 0) - { - execlp( stream.str().c_str(), example.name.c_str(), NULL ); - DALI_ASSERT_ALWAYS(false && "exec failed!"); - } + execlp( stream.str().c_str(), name.c_str(), NULL ); + DALI_ASSERT_ALWAYS(false && "exec failed!"); } mPressedActor.Reset(); } @@ -630,14 +580,13 @@ void DaliTableView::OnScrollComplete( const Dali::Vector2& position ) mScrolling = false; // move focus to 1st item of new page - FocusManager focusManager = FocusManager::Get(); - focusManager.SetCurrentFocusActor(mPages[mScrollView.GetCurrentPage()].GetChildAt(0) ); + AccessibilityManager accessibilityManager = AccessibilityManager::Get(); + accessibilityManager.SetCurrentFocusActor(mPages[mScrollView.GetCurrentPage()].GetChildAt(0) ); } -bool DaliTableView::OnScrollTouched( Actor actor, const TouchEvent& event ) +bool DaliTableView::OnScrollTouched( Actor actor, const TouchData& event ) { - const TouchPoint& point = event.GetPoint( 0 ); - if( TouchPoint::Down == point.state ) + if( PointState::DOWN == event.GetState( 0 ) ) { mPressedActor = actor; } @@ -693,9 +642,11 @@ void DaliTableView::OnKeyEvent( const KeyEvent& event ) { if ( IsKey( event, Dali::DALI_KEY_ESCAPE) || IsKey( event, Dali::DALI_KEY_BACK) ) { - if ( mVersionPopup && mVersionPopupShown ) + // If there's a Popup, Hide it if it's contributing to the display in any way (EG. transitioning in or out). + // Otherwise quit. + if ( mVersionPopup && ( mVersionPopup.GetDisplayState() != Toolkit::Popup::HIDDEN ) ) { - HideVersionPopup(); + mVersionPopup.SetDisplayState( Popup::HIDDEN ); } else { @@ -741,11 +692,12 @@ void DaliTableView::InitialiseBackgroundActors( Actor actor ) animConstraint.AddSource( Source( mScrollView, ScrollView::Property::SCROLL_POSITION ) ); animConstraint.AddSource( Dali::ParentSource( Dali::Actor::Property::SIZE ) ); animConstraint.AddSource( Dali::LocalSource( Dali::Actor::Property::SIZE ) ); + animConstraint.SetRemoveAction( Constraint::Discard ); animConstraint.Apply(); // Kickoff animation - Animation animation = Animation::New( Random::Range( 40.0f, 80.0f ) ); - animation.AnimateBy( Property( child, Actor::Property::POSITION ), Vector3( 0.0f, -1.0f, 0.0f ), AlphaFunction::LINEAR ); + Animation animation = Animation::New( Random::Range( 30.0f, 160.0f ) ); + animation.AnimateBy( Property( child, Actor::Property::POSITION ), Vector3( 0.0f, -2000.0f, 0.0f ), AlphaFunction::LINEAR ); animation.SetLooping( true ); animation.Play(); mBackgroundAnimations.push_back( animation ); @@ -757,18 +709,14 @@ void DaliTableView::AddBackgroundActors( Actor layer, int count, BufferImage dis for( int i = 0; i < count; ++i ) { float randSize = Random::Range( 10.0f, 400.0f ); - float hue = Random::Range( 0.3f, 1.0f ); - Vector4 randColour( hue, hue * 0.5, 0.0f, Random::Range( 0.3f, 0.6f )); - - ImageActor dfActor = ImageActor::New( distanceField ); + ImageView dfActor = ImageView::New( distanceField ); dfActor.SetSize( Vector2( randSize, randSize ) ); dfActor.SetParentOrigin( ParentOrigin::CENTER ); - Toolkit::DistanceFieldEffect effect = Toolkit::DistanceFieldEffect::New(); - dfActor.SetShaderEffect( effect ); - dfActor.SetColor( randColour ); - effect.SetOutlineParams( Vector2( 0.55f, 0.00f ) ); - effect.SetSmoothingEdge( 0.5f ); + Dali::Property::Map effect = Toolkit::CreateDistanceFieldEffect(); + dfActor.SetProperty( Toolkit::ImageView::Property::IMAGE, effect ); + dfActor.SetColor( BUBBLE_COLOR[ i%NUMBER_OF_BUBBLE_COLOR ] ); + layer.Add( dfActor ); } @@ -840,10 +788,9 @@ void DaliTableView::GenerateCircle( const Size& size, std::vector< unsigned char } } -ImageActor DaliTableView::CreateLogo( std::string imagePath ) +ImageView DaliTableView::CreateLogo( std::string imagePath ) { - Image image = ResourceImage::New( imagePath ); - ImageActor logo = ImageActor::New( image ); + ImageView logo = ImageView::New( imagePath ); logo.SetAnchorPoint( AnchorPoint::CENTER ); logo.SetParentOrigin( ParentOrigin::CENTER ); @@ -937,7 +884,7 @@ Dali::Actor DaliTableView::OnKeyboardPreFocusChange( Dali::Actor current, Dali:: int colPos = remainingExamples >= EXAMPLES_PER_PAGE ? EXAMPLES_PER_ROW - 1 : ( remainingExamples % EXAMPLES_PER_PAGE - rowPos * EXAMPLES_PER_ROW - 1 ); // Move the focus to the last tile in the new page. - nextFocusActor = mPages[newPage].GetChildAt(colPos * EXAMPLES_PER_ROW + rowPos); + nextFocusActor = mPages[newPage].GetChildAt(rowPos * EXAMPLES_PER_ROW + colPos); } else { @@ -956,9 +903,7 @@ void DaliTableView::OnFocusedActorActivated( Dali::Actor activatedActor ) mPressedActor = activatedActor; // Activate the current focused actor; - TouchEvent touchEventUp; - touchEventUp.points.push_back( TouchPoint ( 0, TouchPoint::Up, 0.0f, 0.0f ) ); - OnTilePressed(mPressedActor, touchEventUp); + DoTilePress( mPressedActor, PointState::UP ); } } @@ -970,44 +915,48 @@ bool DaliTableView::OnTileHovered( Actor actor, const HoverEvent& event ) void DaliTableView::OnLogoTapped( Dali::Actor actor, const Dali::TapGesture& tap ) { - if ( !mVersionPopupShown ) + // Only show if currently fully hidden. If transitioning-out, the transition will not be interrupted. + if ( !mVersionPopup || ( mVersionPopup.GetDisplayState() == Toolkit::Popup::HIDDEN ) ) { if ( !mVersionPopup ) { std::ostringstream stream; - stream << "DALi Core: " << CORE_MAJOR_VERSION << "." << CORE_MINOR_VERSION << "." << CORE_MICRO_VERSION << std::endl << "(" << CORE_BUILD_DATE << ")" << std::endl << std::endl; - stream << "DALi Adaptor: " << ADAPTOR_MAJOR_VERSION << "." << ADAPTOR_MINOR_VERSION << "." << ADAPTOR_MICRO_VERSION << std::endl << "(" << ADAPTOR_BUILD_DATE << ")" << std::endl << std::endl; - stream << "DALi Toolkit: " << TOOLKIT_MAJOR_VERSION << "." << TOOLKIT_MINOR_VERSION << "." << TOOLKIT_MICRO_VERSION << std::endl << "(" << TOOLKIT_BUILD_DATE << ")"; + 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"; mVersionPopup = Dali::Toolkit::Popup::New(); - mVersionPopup.SetParentOrigin( ParentOrigin::CENTER ); - mVersionPopup.SetAnchorPoint( AnchorPoint::CENTER ); + + Toolkit::TextLabel titleActor = Toolkit::TextLabel::New( "Version information" ); + titleActor.SetName( "titleActor" ); + titleActor.SetProperty( Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" ); + + Toolkit::TextLabel contentActor = Toolkit::TextLabel::New( stream.str() ); + contentActor.SetName( "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 ) ); + + 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.SetResizePolicy( ResizePolicy::FIT_TO_CHILDREN, Dimension::HEIGHT ); - mVersionPopup.SetTitle( stream.str() ); - mVersionPopup.HideTail(); + mVersionPopup.OutsideTouchedSignal().Connect( this, &DaliTableView::HideVersionPopup ); - mVersionPopup.HiddenSignal().Connect( this, &DaliTableView::PopupHidden ); + Stage::GetCurrent().Add( mVersionPopup ); } - mVersionPopup.Show(); - mVersionPopupShown = true; + mVersionPopup.SetDisplayState( Popup::SHOWN ); } } void DaliTableView::HideVersionPopup() { - if ( mVersionPopup ) - { - mVersionPopup.Hide(); - } -} - -void DaliTableView::PopupHidden() -{ - if ( mVersionPopup ) + // Only hide if currently fully shown. If transitioning-in, the transition will not be interrupted. + if ( mVersionPopup && ( mVersionPopup.GetDisplayState() == Toolkit::Popup::SHOWN ) ) { - mVersionPopupShown = false; + mVersionPopup.SetDisplayState( Popup::HIDDEN ); } }