X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=examples%2Ftransitions%2Ftransition-application.cpp;h=d3acd9831e9b5cc6fb46a73a305b5164f96be042;hb=2c54b5f664a6cab86ce5c857f462ed0448a568b6;hp=ab0daf05caa0ece5b22b50c817e84f57f9e218e0;hpb=06bd7af1f41051697c4087f5f995419c201f2678;p=platform%2Fcore%2Fuifw%2Fdali-demo.git diff --git a/examples/transitions/transition-application.cpp b/examples/transitions/transition-application.cpp index ab0daf0..d3acd98 100644 --- a/examples/transitions/transition-application.cpp +++ b/examples/transitions/transition-application.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 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. @@ -24,7 +24,10 @@ // External includes #include -#include "beat-control.h" +#include +#include +#include +#include "shadow-button.h" #include #include @@ -33,17 +36,29 @@ using namespace Dali; using namespace Dali::Toolkit; +namespace +{ + +void SetLabelText( Button button, const char* label ) +{ + button.SetProperty( Toolkit::Button::Property::LABEL, label ); +} + +} + namespace Demo { const char* TransitionApplication::DEMO_THEME_ONE_PATH( DEMO_STYLE_DIR "style-example-theme-one.json" ); +const char* TransitionApplication::DEMO_THEME_TWO_PATH( DEMO_STYLE_DIR "style-example-theme-two.json" ); TransitionApplication::TransitionApplication( Application& application ) : mApplication( application ), mTitle(), - mBeatControl(), + mShadowButton(), mActionButtons(), + mVisualIndex( Property::INVALID_INDEX ), mActionIndex( Property::INVALID_INDEX ) { application.InitSignal().Connect( this, &TransitionApplication::Create ); @@ -68,8 +83,8 @@ void TransitionApplication::Create( Application& application ) contentLayout.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); contentLayout.SetAnchorPoint( AnchorPoint::TOP_LEFT ); contentLayout.SetParentOrigin( ParentOrigin::TOP_LEFT ); - contentLayout.SetCellPadding( Size( 10, 10 ) ); - + contentLayout.SetCellPadding( Vector2( 0.0f, 5.0f ) ); + contentLayout.SetBackgroundColor( Vector4(0.949, 0.949, 0.949, 1.0) ); // Assign all rows the size negotiation property of fitting to children stage.Add( contentLayout ); @@ -77,63 +92,61 @@ void TransitionApplication::Create( Application& application ) mTitle = TextLabel::New( "Custom Control Transition Example" ); mTitle.SetName( "Title" ); mTitle.SetStyleName("Title"); - mTitle.SetAnchorPoint( AnchorPoint::TOP_CENTER ); - mTitle.SetParentOrigin( ParentOrigin::TOP_CENTER ); mTitle.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH ); mTitle.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::HEIGHT ); mTitle.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" ); contentLayout.Add( mTitle ); - contentLayout.SetFitHeight(0); - - mBeatControl = BeatControl::New(); - mBeatControl.SetName("BeatControl"); - mBeatControl.SetAnchorPoint( AnchorPoint::CENTER ); - mBeatControl.SetParentOrigin( ParentOrigin::CENTER ); - mBeatControl.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); - contentLayout.Add( mBeatControl ); - // beat control should fill the tableview cell, so no change to default parameters - - TableView actionButtonLayout = TableView::New( 1, 4 ); + contentLayout.SetFitHeight(0); // Fill width + + // Provide some padding around the center cell + TableView buttonLayout = TableView::New( 3, 3 ); + buttonLayout.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); + buttonLayout.SetFixedHeight(1, 100 ); + buttonLayout.SetFixedWidth(1, 350 ); + contentLayout.Add( buttonLayout ); + + mShadowButton = ShadowButton::New(); + mShadowButton.SetName("ShadowButton"); + mShadowButton.SetActiveState( false ); + mShadowButton.SetAnchorPoint( AnchorPoint::CENTER ); + mShadowButton.SetParentOrigin( ParentOrigin::CENTER ); + mShadowButton.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); + mShadowButton.SetProperty( DevelControl::Property::STATE, DevelControl::DISABLED ); + mShadowButton.SetProperty( DevelControl::Property::SUB_STATE, "UNCHECKED" ); + + buttonLayout.AddChild( mShadowButton, TableView::CellPosition(1, 1) ); + + TableView actionButtonLayout = TableView::New( 1, NUMBER_OF_ACTION_BUTTONS+1 ); actionButtonLayout.SetName("ThemeButtonsLayout"); - actionButtonLayout.SetCellPadding( Vector2( 6.0f, 0.0f ) ); - - actionButtonLayout.SetAnchorPoint( AnchorPoint::CENTER ); - actionButtonLayout.SetParentOrigin( ParentOrigin::CENTER ); actionButtonLayout.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH ); actionButtonLayout.SetResizePolicy( ResizePolicy::FIT_TO_CHILDREN, Dimension::HEIGHT ); - actionButtonLayout.SetCellPadding( Size( 10, 10 ) ); actionButtonLayout.SetFitHeight( 0 ); TextLabel label = TextLabel::New( "Action: "); label.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS ); label.SetStyleName("ActionLabel"); - label.SetAnchorPoint( AnchorPoint::TOP_CENTER ); - label.SetParentOrigin( ParentOrigin::TOP_CENTER ); actionButtonLayout.AddChild( label, TableView::CellPosition( 0, 0 ) ); actionButtonLayout.SetCellAlignment( TableView::CellPosition( 0, 0 ), HorizontalAlignment::LEFT, VerticalAlignment::CENTER ); - for( int i=0; i<3; ++i ) + for( int i=0; i( mActionIndex ); @@ -141,17 +154,43 @@ bool TransitionApplication::OnActionButtonClicked( Button button ) { case 0: { - mBeatControl.StartBounceAnimation(); + bool activeState = mShadowButton.GetActiveState(); + mShadowButton.SetActiveState( ! activeState ); + if( activeState ) + { + SetLabelText( button, "Enable" ); + mShadowButton.SetProperty( DevelControl::Property::STATE, DevelControl::DISABLED ); + } + else + { + SetLabelText( button, "Disable" ); + mShadowButton.SetProperty( DevelControl::Property::STATE, DevelControl::NORMAL ); + } + mActionButtons[1].SetProperty( Button::Property::DISABLED, activeState ); break; } case 1: { - mBeatControl.StartXAnimation(); + bool checkState = mShadowButton.GetCheckState(); + mShadowButton.SetCheckState( ! checkState ); + if( checkState ) + { + SetLabelText( button, "Check" ); + mShadowButton.SetProperty( DevelControl::Property::SUB_STATE, "UNCHECKED" ); + } + else + { + SetLabelText( button, "Uncheck" ); + mShadowButton.SetProperty( DevelControl::Property::SUB_STATE, "CHECKED" ); + } break; } case 2: { - mBeatControl.StartYAnimation(); + break; + } + case 3: + { break; } }