X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=examples%2Fbuttons%2Fbuttons-example.cpp;h=61dd21783d4ca407c6d963c8ad78fb2994ec53c7;hb=694dced621016315f10a5bdbd3f4552f5e29e380;hp=ce593682772c350f3ac199964f487d02dcbd4821;hpb=9879c76252b384906ea35422547840350a72019c;p=platform%2Fcore%2Fuifw%2Fdali-demo.git diff --git a/examples/buttons/buttons-example.cpp b/examples/buttons/buttons-example.cpp index ce59368..61dd217 100644 --- a/examples/buttons/buttons-example.cpp +++ b/examples/buttons/buttons-example.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. @@ -18,6 +18,7 @@ #include "shared/view.h" #include #include +#include using namespace Dali; @@ -91,10 +92,10 @@ class ButtonsController: public ConnectionTracker // The Init signal is received once (only) during the Application lifetime // Respond to key events - Stage::GetCurrent().KeyEventSignal().Connect(this, &ButtonsController::OnKeyEvent); + application.GetWindow().KeyEventSignal().Connect(this, &ButtonsController::OnKeyEvent); // Creates a default view with a default tool bar. - // The view is added to the stage. + // The view is added to the window. mContentLayer = DemoHelper::CreateView( application, mView, mToolBar, @@ -105,8 +106,8 @@ class ButtonsController: public ConnectionTracker Toolkit::TableView contentTable = Toolkit::TableView::New( 4, 1 ); contentTable.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH ); contentTable.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::HEIGHT ); - contentTable.SetAnchorPoint( AnchorPoint::TOP_LEFT ); - contentTable.SetParentOrigin( ParentOrigin::TOP_LEFT ); + contentTable.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT ); + contentTable.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT ); contentTable.SetCellPadding( Size( MARGIN_SIZE, MARGIN_SIZE * 0.5f ) ); for( unsigned int i = 0; i < contentTable.GetRows(); ++i ) @@ -114,7 +115,7 @@ class ButtonsController: public ConnectionTracker contentTable.SetFitHeight( i ); } - contentTable.SetPosition( 0.0f, TOP_MARGIN ); + contentTable.SetProperty( Actor::Property::POSITION, Vector2( 0.0f, TOP_MARGIN )); mContentLayer.Add( contentTable ); @@ -158,12 +159,12 @@ class ButtonsController: public ConnectionTracker // Radio 1 { Toolkit::ImageView image = Toolkit::ImageView::New( SMALL_IMAGE_1 ); - image.SetSize( DP(RADIO_LABEL_THUMBNAIL_SIZE), DP(RADIO_LABEL_THUMBNAIL_SIZE) ); + image.SetProperty( Actor::Property::SIZE, Vector2( DP(RADIO_LABEL_THUMBNAIL_SIZE), DP(RADIO_LABEL_THUMBNAIL_SIZE) ) ); mRadioButtonImage1 = Dali::Toolkit::RadioButton::New( "1" ); - mRadioButtonImage1.SetParentOrigin( ParentOrigin::TOP_LEFT ); - mRadioButtonImage1.SetAnchorPoint( AnchorPoint::TOP_LEFT ); - mRadioButtonImage1.SetPosition( 0, DP(radioY) ); + mRadioButtonImage1.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT ); + mRadioButtonImage1.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT ); + mRadioButtonImage1.SetProperty( Actor::Property::POSITION, Vector2( 0, DP(radioY) )); mRadioButtonImage1.SetProperty( Toolkit::Button::Property::SELECTED, true ); imageSelectTableView.AddChild( mRadioButtonImage1, Toolkit::TableView::CellPosition( 0, 0 ) ); @@ -175,12 +176,12 @@ class ButtonsController: public ConnectionTracker radioY += RADIO_LABEL_THUMBNAIL_SIZE + RADIO_IMAGE_SPACING; Toolkit::ImageView image = Toolkit::ImageView::New( SMALL_IMAGE_2 ); - image.SetSize( DP(RADIO_LABEL_THUMBNAIL_SIZE), DP(RADIO_LABEL_THUMBNAIL_SIZE) ); + image.SetProperty( Actor::Property::SIZE, Vector2( DP(RADIO_LABEL_THUMBNAIL_SIZE), DP(RADIO_LABEL_THUMBNAIL_SIZE) ) ); mRadioButtonImage2 = Dali::Toolkit::RadioButton::New( "2" ); - mRadioButtonImage2.SetParentOrigin( ParentOrigin::TOP_LEFT ); - mRadioButtonImage2.SetAnchorPoint( AnchorPoint::TOP_LEFT ); - mRadioButtonImage2.SetPosition( 0, DP(radioY) ); + mRadioButtonImage2.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT ); + mRadioButtonImage2.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT ); + mRadioButtonImage2.SetProperty( Actor::Property::POSITION, Vector2( 0, DP(radioY) )); imageSelectTableView.AddChild( mRadioButtonImage2, Toolkit::TableView::CellPosition( 1, 0 ) ); imageSelectTableView.AddChild( image, Toolkit::TableView::CellPosition( 1, 1 ) ); @@ -191,12 +192,12 @@ class ButtonsController: public ConnectionTracker radioY += RADIO_LABEL_THUMBNAIL_SIZE + RADIO_IMAGE_SPACING; Toolkit::ImageView image = Toolkit::ImageView::New( SMALL_IMAGE_3 ); - image.SetSize( DP(RADIO_LABEL_THUMBNAIL_SIZE), DP(RADIO_LABEL_THUMBNAIL_SIZE) ); + image.SetProperty( Actor::Property::SIZE, Vector2( DP(RADIO_LABEL_THUMBNAIL_SIZE), DP(RADIO_LABEL_THUMBNAIL_SIZE) ) ); mRadioButtonImage3 = Dali::Toolkit::RadioButton::New( "3" ); - mRadioButtonImage3.SetParentOrigin( ParentOrigin::TOP_LEFT ); - mRadioButtonImage3.SetAnchorPoint( AnchorPoint::TOP_LEFT ); - mRadioButtonImage3.SetPosition( 0, DP(radioY) ); + mRadioButtonImage3.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT ); + mRadioButtonImage3.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT ); + mRadioButtonImage3.SetProperty( Actor::Property::POSITION, Vector2( 0, DP(radioY) )); imageSelectTableView.AddChild( mRadioButtonImage3, Toolkit::TableView::CellPosition( 2, 0 ) ); imageSelectTableView.AddChild( image, Toolkit::TableView::CellPosition( 2, 1 ) ); @@ -205,7 +206,7 @@ class ButtonsController: public ConnectionTracker // Create select button mUpdateButton = Toolkit::PushButton::New(); mUpdateButton.SetProperty( Toolkit::Button::Property::LABEL, "Select" ); - mUpdateButton.SetName( "selectButton" ); + mUpdateButton.SetProperty( Dali::Actor::Property::NAME, "selectButton" ); mUpdateButton.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS ); mUpdateButton.ClickedSignal().Connect( this, &ButtonsController::OnButtonClicked ); @@ -215,7 +216,7 @@ class ButtonsController: public ConnectionTracker // ImageView to display selected image mImage = Toolkit::ImageView::New( BIG_IMAGE_1 ); mImage.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); - mImage.SetSizeScalePolicy( SizeScalePolicy::FIT_WITH_ASPECT_RATIO ); + mImage.SetProperty( Actor::Property::SIZE_SCALE_POLICY, SizeScalePolicy::FIT_WITH_ASPECT_RATIO ); radioGroup2Background.AddChild( mImage, Toolkit::TableView::CellPosition( 0, 1, 2, 1 ) ); // The enable/disable radio group @@ -254,8 +255,8 @@ class ButtonsController: public ConnectionTracker textLabel.SetProperty( Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" ); Toolkit::ImageView image = Toolkit::ImageView::New( ENABLED_IMAGE ); - image.SetSize( DP(RADIO_LABEL_THUMBNAIL_SIZE), DP(RADIO_LABEL_THUMBNAIL_SIZE) ); - image.SetPadding( Padding( DP(20.0f), 0.0f, 0.0f, 0.0f ) ); + image.SetProperty( Actor::Property::SIZE, Vector2( DP(RADIO_LABEL_THUMBNAIL_SIZE), DP(RADIO_LABEL_THUMBNAIL_SIZE) ) ); + image.SetProperty( Actor::Property::PADDING, Padding( DP(20.0f), 0.0f, 0.0f, 0.0f ) ); tableView.AddChild( image, Toolkit::TableView::CellPosition( 0, 1 ) ); radioButtonsGroup1.Add( tableView ); @@ -263,10 +264,10 @@ class ButtonsController: public ConnectionTracker // First radio button { Toolkit::RadioButton radioButton = Dali::Toolkit::RadioButton::New( "Select enabled" ); - radioButton.SetName( "radioSelectEnable" ); - radioButton.SetParentOrigin( ParentOrigin::TOP_LEFT ); - radioButton.SetAnchorPoint( AnchorPoint::TOP_LEFT ); - radioButton.SetPosition( 0, 0 ); + radioButton.SetProperty( Dali::Actor::Property::NAME, "radioSelectEnable" ); + radioButton.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT ); + radioButton.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT ); + radioButton.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 )); radioButton.SetProperty( Toolkit::Button::Property::SELECTED, true ); radioButton.StateChangedSignal().Connect( this, &ButtonsController::EnableSelectButton ); @@ -277,10 +278,10 @@ class ButtonsController: public ConnectionTracker // Second radio button { Toolkit::RadioButton radioButton = Dali::Toolkit::RadioButton::New( "Select disabled" ); - radioButton.SetName( "radioSelectDisable" ); - radioButton.SetParentOrigin( ParentOrigin::TOP_LEFT ); - radioButton.SetAnchorPoint( AnchorPoint::TOP_LEFT ); - radioButton.SetPosition( 0, DP(50) ); + radioButton.SetProperty( Dali::Actor::Property::NAME, "radioSelectDisable" ); + radioButton.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT ); + radioButton.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT ); + radioButton.SetProperty( Actor::Property::POSITION, Vector2( 0, DP(50) )); radioButton.StateChangedSignal().Connect( this, &ButtonsController::EnableSelectButton ); @@ -303,7 +304,7 @@ class ButtonsController: public ConnectionTracker { mCheckboxButton1 = Toolkit::CheckBoxButton::New(); - mCheckboxButton1.SetName( "checkbox1" ); + mCheckboxButton1.SetProperty( Dali::Actor::Property::NAME, "checkbox1" ); mCheckboxButton1.SetProperty( Toolkit::Button::Property::LABEL, "CheckBox1 is unselected" ); mCheckboxButton1.StateChangedSignal().Connect( this, &ButtonsController::OnCheckBoxesSelected ); mCheckboxButton1.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH ); @@ -313,7 +314,7 @@ class ButtonsController: public ConnectionTracker { mCheckboxButton2 = Toolkit::CheckBoxButton::New(); - mCheckboxButton2.SetName( "checkbox2" ); + mCheckboxButton2.SetProperty( Dali::Actor::Property::NAME, "checkbox2" ); mCheckboxButton2.SetProperty( Toolkit::Button::Property::LABEL, "CheckBox2 is selected" ); mCheckboxButton2.SetProperty( Toolkit::Button::Property::SELECTED, true ); mCheckboxButton2.StateChangedSignal().Connect( this, &ButtonsController::OnCheckBoxesSelected ); @@ -324,7 +325,7 @@ class ButtonsController: public ConnectionTracker { mCheckboxButton3 = Toolkit::CheckBoxButton::New(); - mCheckboxButton3.SetName( "checkbox3" ); + mCheckboxButton3.SetProperty( Dali::Actor::Property::NAME, "checkbox3" ); mCheckboxButton3.SetProperty( Toolkit::Button::Property::LABEL, "CheckBox3 is unselected" ); mCheckboxButton3.StateChangedSignal().Connect( this, &ButtonsController::OnCheckBoxesSelected ); mCheckboxButton3.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH ); @@ -395,7 +396,7 @@ class ButtonsController: public ConnectionTracker return true; } - if( button.GetName() == "radioSelectEnable" ) + if( button.GetProperty< std::string >( Dali::Actor::Property::NAME ) == "radioSelectEnable" ) { mUpdateButton.SetProperty( Toolkit::Button::Property::DISABLED, false ); @@ -409,7 +410,7 @@ class ButtonsController: public ConnectionTracker mToggleButton.SetProperty( Toolkit::Button::Property::DISABLED, false ); } - else if( button.GetName() == "radioSelectDisable" ) + else if( button.GetProperty< std::string >( Dali::Actor::Property::NAME ) == "radioSelectDisable" ) { mUpdateButton.SetProperty( Toolkit::Button::Property::DISABLED, true ); @@ -447,7 +448,7 @@ class ButtonsController: public ConnectionTracker bool OnCheckBoxesSelected( Toolkit::Button button ) { bool isSelected = button.GetProperty( Toolkit::Button::Property::SELECTED ).Get(); - if( button.GetName() == "checkbox1" ) + if( button.GetProperty< std::string >( Dali::Actor::Property::NAME ) == "checkbox1" ) { if( isSelected ) { @@ -459,7 +460,7 @@ class ButtonsController: public ConnectionTracker } } - if( button.GetName() == "checkbox2" ) + if( button.GetProperty< std::string >( Dali::Actor::Property::NAME ) == "checkbox2" ) { if( isSelected ) { @@ -471,7 +472,7 @@ class ButtonsController: public ConnectionTracker } } - if( button.GetName() == "checkbox3" ) + if( button.GetProperty< std::string >( Dali::Actor::Property::NAME ) == "checkbox3" ) { if( isSelected ) {