From: Adeel Kazmi Date: Wed, 17 Apr 2019 18:20:43 +0000 (+0100) Subject: Changed some examples to use initializer list for Maps & Arrays X-Git-Tag: dali_1.4.17~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F77%2F203777%2F2;p=platform%2Fcore%2Fuifw%2Fdali-demo.git Changed some examples to use initializer list for Maps & Arrays Change-Id: If3a80248f266d114150350cf8f553331d018b9b2 --- diff --git a/examples/contact-cards/contact-card.cpp b/examples/contact-cards/contact-card.cpp index d9f55e0..92c97d2 100644 --- a/examples/contact-cards/contact-card.cpp +++ b/examples/contact-cards/contact-card.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * Copyright (c) 2019 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. @@ -112,8 +112,8 @@ ContactCard::ContactCard( // Create a control which will be used for the background and to clip the contents mContactCard = Control::New(); mContactCard.SetProperty( Control::Property::BACKGROUND, - Property::Map().Add( Toolkit::Visual::Property::TYPE, Visual::COLOR ) - .Add( ColorVisual::Property::MIX_COLOR, Color::WHITE ) ); + Property::Map{ { Toolkit::Visual::Property::TYPE, Visual::COLOR }, + { ColorVisual::Property::MIX_COLOR, Color::WHITE } } ); mContactCard.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN ); mContactCard.SetParentOrigin( ParentOrigin::TOP_LEFT ); mContactCard.SetAnchorPoint( AnchorPoint::TOP_LEFT ); @@ -125,8 +125,8 @@ ContactCard::ContactCard( mHeader = Control::New(); mHeader.SetSize( mContactCardLayoutInfo.headerSize ); mHeader.SetProperty( Control::Property::BACKGROUND, - Property::Map().Add( Toolkit::Visual::Property::TYPE, Visual::COLOR ) - .Add( ColorVisual::Property::MIX_COLOR, HEADER_COLOR ) ); + Property::Map{ { Toolkit::Visual::Property::TYPE, Visual::COLOR }, + { ColorVisual::Property::MIX_COLOR, HEADER_COLOR } } ); mHeader.SetParentOrigin( ParentOrigin::TOP_LEFT ); mHeader.SetAnchorPoint( AnchorPoint::TOP_LEFT ); mHeader.SetPosition( mContactCardLayoutInfo.headerFoldedPosition.x, mContactCardLayoutInfo.headerFoldedPosition.y ); diff --git a/examples/contact-cards/masked-image.cpp b/examples/contact-cards/masked-image.cpp index abf7001..ede6e75 100644 --- a/examples/contact-cards/masked-image.cpp +++ b/examples/contact-cards/masked-image.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * Copyright (c) 2019 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,9 +37,9 @@ Dali::Toolkit::Control Create( const std::string& imagePath ) Control maskedImage = ImageView::New(); maskedImage.SetProperty( Toolkit::ImageView::Property::IMAGE, - Property::Map().Add( Visual::Property::TYPE, Toolkit::Visual::Type::IMAGE ) - .Add( ImageVisual::Property::URL, imagePath ) - .Add( ImageVisual::Property::ALPHA_MASK_URL, IMAGE_MASK ) + Property::Map{ { Visual::Property::TYPE, Toolkit::Visual::Type::IMAGE }, + { ImageVisual::Property::URL, imagePath }, + { ImageVisual::Property::ALPHA_MASK_URL, IMAGE_MASK } } ); return maskedImage; } diff --git a/examples/cube-transition-effect/cube-transition-effect-example.cpp b/examples/cube-transition-effect/cube-transition-effect-example.cpp index f728418..300b92a 100644 --- a/examples/cube-transition-effect/cube-transition-effect-example.cpp +++ b/examples/cube-transition-effect/cube-transition-effect-example.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2019 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. @@ -222,9 +222,9 @@ void CubeTransitionApp::OnInit( Application& application ) Toolkit::ToggleButton effectChangeToggleButton = Toolkit::ToggleButton::ToggleButton::New(); effectChangeToggleButton.SetProperty( Toolkit::ToggleButton::Property::STATE_VISUALS, - Property::Array().Add( EFFECT_WAVE_IMAGE ) - .Add( EFFECT_CROSS_IMAGE) - .Add( EFFECT_FOLD_IMAGE ) + Property::Array{ EFFECT_WAVE_IMAGE, + EFFECT_CROSS_IMAGE, + EFFECT_FOLD_IMAGE } ); effectChangeToggleButton.ClickedSignal().Connect( this, &CubeTransitionApp::OnEffectButtonClicked ); diff --git a/examples/gestures/gesture-example.cpp b/examples/gestures/gesture-example.cpp index bbae267..08efc8b 100644 --- a/examples/gestures/gesture-example.cpp +++ b/examples/gestures/gesture-example.cpp @@ -24,15 +24,23 @@ using namespace Dali::Toolkit; namespace { -const Vector4 BACKGROUND_GRADIENT_1 = Vector4( 167.0f, 207.0f, 223.0f, 255.0f ) / 255.0f; -const Vector4 BACKGROUND_GRADIENT_2 = Vector4( 0.0f, 64.0f, 137.0f, 255.0f ) / 255.0f; -const Vector2 BACKGROUND_GRADIENT_START_POSITION( 0.0f, -0.5f ); -const Vector2 BACKGROUND_GRADIENT_END_POSITION( 0.0f, 0.5f ); +const Property::Value BACKGROUND +{ + { Toolkit::Visual::Property::TYPE, Visual::GRADIENT }, + { GradientVisual::Property::STOP_COLOR, Property::Array{ Vector4( 167.0f, 207.0f, 223.0f, 255.0f ) / 255.0f, + Vector4( 0.0f, 64.0f, 137.0f, 255.0f ) / 255.0f } }, + { GradientVisual::Property::START_POSITION, Vector2( 0.0f, -0.5f ) }, + { GradientVisual::Property::END_POSITION, Vector2( 0.0f, 0.5f ) } +}; -const Vector4 CONTROL_GRADIENT_1 = Vector4( 234.0f, 185.0f, 45.0f, 255.0f ) / 255.0f; -const Vector4 CONTROL_GRADIENT_2 = Vector4( 199.0f, 152.0f, 16.0f, 255.0f ) / 255.0f; -const Vector2 CONTROL_GRADIENT_CENTER( Vector2::ZERO ); -const float CONTROL_GRADIENT_RADIUS( 0.5f ); +const Property::Value CONTROL_BACKGROUND +{ + { Toolkit::Visual::Property::TYPE, Visual::GRADIENT }, + { GradientVisual::Property::STOP_COLOR, Property::Array{ Vector4( 234.0f, 185.0f, 45.0f, 255.0f ) / 255.0f, + Vector4( 199.0f, 152.0f, 16.0f, 255.0f ) / 255.0f } }, + { GradientVisual::Property::CENTER, Vector2::ZERO }, + { GradientVisual::Property::RADIUS, 0.5f } +}; const float HELP_ANIMATION_DURATION( 25.0f ); const float HELP_ANIMATION_SEGMENT_TIME( 5.0f ); @@ -58,45 +66,6 @@ const Vector3 MAXIMUM_SCALE( Vector3::ONE * 2.0f ); const float SCALE_BACK_ANIMATION_DURATION( 0.25f ); /** - * @brief Creates a background with a linear gradient which matches parent size & is placed in the center. - */ -Actor CreateBackground() -{ - Actor background = Control::New(); - background.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); - background.SetParentOrigin( ParentOrigin::CENTER ); - background.SetProperty( - Control::Property::BACKGROUND, - Property::Map().Add( Toolkit::Visual::Property::TYPE, Visual::GRADIENT ) - .Add( GradientVisual::Property::STOP_COLOR, Property::Array().Add( BACKGROUND_GRADIENT_1 ) - .Add( BACKGROUND_GRADIENT_2 ) ) - .Add( GradientVisual::Property::START_POSITION, BACKGROUND_GRADIENT_START_POSITION ) - .Add( GradientVisual::Property::END_POSITION, BACKGROUND_GRADIENT_END_POSITION ) ); - return background; -} - -/** - * @brief Create a control with a circular gradient & a specific size & is placed in the center of its parent. - * - * @param[in] size The size we want the control to be. - */ -Actor CreateTouchControl( const Vector2& size ) -{ - Actor touchControl = Control::New(); - touchControl.SetSize( size ); - touchControl.SetParentOrigin( ParentOrigin::CENTER ); - touchControl.SetProperty( - Control::Property::BACKGROUND, - Property::Map().Add( Toolkit::Visual::Property::TYPE, Visual::GRADIENT ) - .Add( GradientVisual::Property::STOP_COLOR, Property::Array().Add( CONTROL_GRADIENT_1 ) - .Add( CONTROL_GRADIENT_2 ) ) - .Add( GradientVisual::Property::CENTER, CONTROL_GRADIENT_CENTER ) - .Add( GradientVisual::Property::RADIUS, CONTROL_GRADIENT_RADIUS ) - ); - return touchControl; -} - -/** * @brief Shows the given string between the given start and end times. * * Appropriately animates the string into and out of the scene. @@ -170,12 +139,18 @@ private: Stage stage = Stage::GetCurrent(); stage.KeyEventSignal().Connect(this, &GestureExample::OnKeyEvent); - // Create a background with a gradient - Actor background = CreateBackground(); + // Create a background with a linear gradient which matches parent size & is placed in the center. + Actor background = Control::New(); + background.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); + background.SetParentOrigin( ParentOrigin::CENTER ); + background.SetProperty( Control::Property::BACKGROUND, BACKGROUND ); stage.Add( background ); - // Create a control that we'll use for the gestures to be a quarter of the size of the stage - Actor touchControl = CreateTouchControl( stage.GetSize() * 0.25f ); + // Create a control with a circular gradient that we'll use for the gestures and be a quarter of the size of the stage. + Actor touchControl = Control::New(); + touchControl.SetSize( stage.GetSize() * 0.25f ); + touchControl.SetParentOrigin( ParentOrigin::CENTER ); + touchControl.SetProperty( Control::Property::BACKGROUND, CONTROL_BACKGROUND ); background.Add( touchControl ); // Connect to the touch signal diff --git a/examples/layouting/layouting-examples.cpp b/examples/layouting/layouting-examples.cpp index 74d5ed7..f91823e 100644 --- a/examples/layouting/layouting-examples.cpp +++ b/examples/layouting/layouting-examples.cpp @@ -37,10 +37,14 @@ using namespace Dali::Toolkit; namespace { -const Vector4 BACKGROUND_GRADIENT_1 = Vector4( 0.0f, 0.352941176f, 0.654901961f, 1.0f ); -const Vector4 BACKGROUND_GRADIENT_2 = Vector4( 1.0f, 0.992156863f, 0.894117647f, 1.0f ); -const Vector2 BACKGROUND_GRADIENT_START_POSITION( 0.0f, -0.5f ); -const Vector2 BACKGROUND_GRADIENT_END_POSITION( 0.0f, 0.5f ); +const Property::Value BACKGROUND +{ + { Toolkit::Visual::Property::TYPE, Visual::GRADIENT }, + { GradientVisual::Property::STOP_COLOR, Property::Array{ Vector4( 0.0f, 0.352941176f, 0.654901961f, 1.0f ), + Vector4( 1.0f, 0.992156863f, 0.894117647f, 1.0f ) } }, + { GradientVisual::Property::START_POSITION, Vector2( 0.0f, -0.5f ) }, + { GradientVisual::Property::END_POSITION, Vector2( 0.0f, 0.5f ) } +}; const char* TOOLBAR_IMAGE( DEMO_IMAGE_DIR "top-bar.png" ); @@ -84,13 +88,7 @@ private: auto bg = Control::New(); bg.SetParentOrigin( ParentOrigin::CENTER ); bg.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); - bg.SetProperty( - Control::Property::BACKGROUND, - Property::Map().Add( Toolkit::Visual::Property::TYPE, Visual::GRADIENT ) - .Add( GradientVisual::Property::STOP_COLOR, Property::Array().Add( BACKGROUND_GRADIENT_1 ) - .Add( BACKGROUND_GRADIENT_2 ) ) - .Add( GradientVisual::Property::START_POSITION, BACKGROUND_GRADIENT_START_POSITION ) - .Add( GradientVisual::Property::END_POSITION, BACKGROUND_GRADIENT_END_POSITION ) ); + bg.SetProperty( Control::Property::BACKGROUND, BACKGROUND ); stage.Add( bg ); auto toolbar = ImageView::New( TOOLBAR_IMAGE ); toolbar.SetParentOrigin( ParentOrigin::TOP_CENTER ); diff --git a/examples/tooltip/tooltip-example.cpp b/examples/tooltip/tooltip-example.cpp index 885c55e..9068d2b 100644 --- a/examples/tooltip/tooltip-example.cpp +++ b/examples/tooltip/tooltip-example.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2019 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. @@ -94,21 +94,21 @@ private: SetLabel( customFromCode, "Custom From Code" ); Layout( customFromCode, stageSize ); customFromCode.SetProperty( DevelControl::Property::TOOLTIP, - Property::Map().Add( Tooltip::Property::CONTENT, - Property::Array().Add( Property::Map().Add( Toolkit::Visual::Property::TYPE, Visual::IMAGE ) - .Add( ImageVisual::Property::URL, DEMO_IMAGE_DIR "Logo-for-demo.png" ) ) - .Add( Property::Map().Add( Toolkit::Visual::Property::TYPE, Visual::TEXT ) - .Add( TextVisual::Property::TEXT_COLOR, Color::WHITE ) - .Add( TextVisual::Property::TEXT, "Custom coded style\nat hover point" ) - .Add( TextVisual::Property::MULTI_LINE, true ) - .Add( TextVisual::Property::HORIZONTAL_ALIGNMENT, "CENTER" ) - .Add( TextVisual::Property::POINT_SIZE, 16 ) ) ) - .Add( Tooltip::Property::LAYOUT, Vector2( 2, 1 ) ) - .Add( Tooltip::Property::POSITION, Tooltip::Position::HOVER_POINT ) - .Add( Tooltip::Property::BACKGROUND, - Property::Map().Add( Tooltip::Background::Property::VISUAL, DEMO_IMAGE_DIR "tooltip.9.png" ) - .Add( Tooltip::Background::Property::BORDER, Rect< int >( 1, 5, 5, 1 ) ) ) - ); + { { Tooltip::Property::CONTENT, + Property::Array{ { { { Toolkit::Visual::Property::TYPE, Visual::IMAGE }, + { ImageVisual::Property::URL, DEMO_IMAGE_DIR "Logo-for-demo.png" } } }, + { { { Toolkit::Visual::Property::TYPE, Visual::TEXT }, + { TextVisual::Property::TEXT_COLOR, Color::WHITE }, + { TextVisual::Property::TEXT, "Custom coded style\nat hover point" }, + { TextVisual::Property::MULTI_LINE, true }, + { TextVisual::Property::HORIZONTAL_ALIGNMENT, "CENTER" }, + { TextVisual::Property::POINT_SIZE, 16 } } } } }, + { Tooltip::Property::LAYOUT, Vector2( 2, 1 ) }, + { Tooltip::Property::POSITION, Tooltip::Position::HOVER_POINT }, + { Tooltip::Property::BACKGROUND, + { { Tooltip::Background::Property::VISUAL, DEMO_IMAGE_DIR "tooltip.9.png" }, + { Tooltip::Background::Property::BORDER, Rect< int >( 1, 5, 5, 1 ) } } } + } ); stage.Add( customFromCode ); }