/*
- * Copyright (c) 2018 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.
// EXTERNAL INCLUDES
#include <dali/devel-api/object/handle-devel.h>
#include <dali/devel-api/actors/actor-devel.h>
-#include <dali-toolkit/devel-api/controls/buttons/button-devel.h>
#include <dali-toolkit/devel-api/controls/text-controls/text-label-devel.h>
#include <dali-toolkit/devel-api/text/text-enumerations-devel.h>
#include <dali-toolkit/dali-toolkit.h>
float value;
};
-const float STYLE_BUTTON_POSTION_RELATIVE_TO_STAGE = 0.9f;
-const float BUTTON_SIZE_RATIO_TO_STAGE = 0.1f;
+const float STYLE_BUTTON_POSTION_RELATIVE_TO_WINDOW = 0.9f;
+const float BUTTON_SIZE_RATIO_TO_WINDOW = 0.1f;
const float OUTLINE_WIDTH = 2.0f;
const Vector2 SHADOW_OFFSET = Vector2( 2.0f, 2.0f );
const int GAP_BETWEEN_BUTTONS = 3;
void SetUpExpandingStyleButtons( Vector2 position )
{
mExpandingButtons = Demo::ExpandingButtons::New();
- mExpandingButtons.SetPosition( mButtonSize.width, mStageSize.height * STYLE_BUTTON_POSTION_RELATIVE_TO_STAGE );
+ mExpandingButtons.SetProperty( Actor::Property::POSITION, Vector2( mButtonSize.width, mWindowSize.height * STYLE_BUTTON_POSTION_RELATIVE_TO_WINDOW ));
mExpandingButtons.CollapsingSignal().Connect( this, &TextLabelExample::OnExpandingButtonCollapsing );
- mExpandingButtons.SetSize( mButtonSize );
+ mExpandingButtons.SetProperty( Actor::Property::SIZE, mButtonSize );
// Creates the buttons to be expanded
CreateStyleButtons();
*/
void Create( Application& application )
{
- Stage stage = Stage::GetCurrent();
+ Window window = application.GetWindow();
- stage.KeyEventSignal().Connect(this, &TextLabelExample::OnKeyEvent);
- mStageSize = stage.GetSize();
- mButtonSize = Size( mStageSize.height * 0.1, mStageSize.height * 0.1 ); // Button size 1/10 of stage height
+ window.KeyEventSignal().Connect(this, &TextLabelExample::OnKeyEvent);
+ mWindowSize = window.GetSize();
+ mButtonSize = Size( mWindowSize.height * 0.1, mWindowSize.height * 0.1 ); // Button size 1/10 of window height
mContainer = Control::New();
- mContainer.SetName( "Container" );
- mContainer.SetParentOrigin( ParentOrigin::CENTER );
- mLayoutSize = Vector2(mStageSize.width*0.6f, mStageSize.width*0.6f);
- mContainer.SetSize( mLayoutSize );
- stage.Add( mContainer );
+ mContainer.SetProperty( Dali::Actor::Property::NAME, "Container" );
+ mContainer.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
+ mLayoutSize = Vector2(mWindowSize.width*0.6f, mWindowSize.width*0.6f);
+ mContainer.SetProperty( Actor::Property::SIZE, mLayoutSize );
+ window.Add( mContainer );
// Resize the center layout when the corner is grabbed
mGrabCorner = ImageView::New( BACKGROUND_IMAGE );
- mGrabCorner.SetName( "GrabCorner" );
- mGrabCorner.SetAnchorPoint( AnchorPoint::TOP_CENTER );
- mGrabCorner.SetParentOrigin( ParentOrigin::BOTTOM_RIGHT );
+ mGrabCorner.SetProperty( Dali::Actor::Property::NAME, "GrabCorner" );
+ mGrabCorner.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_CENTER );
+ mGrabCorner.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_RIGHT );
mGrabCorner.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
mContainer.Add( mGrabCorner );
mLabel = TextLabel::New( "\xF0\x9F\x98\x89 A Quick Brown Fox Jumps Over The Lazy Dog" );
- mLabel.SetName( "TextLabel" );
- mLabel.SetAnchorPoint( AnchorPoint::TOP_LEFT );
- mLabel.SetSize(mLayoutSize);
+ mLabel.SetProperty( Dali::Actor::Property::NAME, "TextLabel" );
+ mLabel.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
+ mLabel.SetProperty( Actor::Property::SIZE, mLayoutSize );
mLabel.SetProperty( TextLabel::Property::MULTI_LINE, true );
mLabel.SetProperty( TextLabel::Property::TEXT_COLOR, Color::GREEN );
mLabel.SetBackgroundColor( Color::WHITE );
mContainer.Add( mLabel );
// Clicking ExpandingButton shows the Registered Style buttons, clicking again hides them.
- Vector2 expandingButtonPosition( mButtonSize.width, mStageSize.height * STYLE_BUTTON_POSTION_RELATIVE_TO_STAGE );
+ Vector2 expandingButtonPosition( mButtonSize.width, mWindowSize.height * STYLE_BUTTON_POSTION_RELATIVE_TO_WINDOW );
SetUpExpandingStyleButtons( expandingButtonPosition );
- stage.Add( mExpandingButtons );
+ window.Add( mExpandingButtons );
// Add a border for the container so you can see the container is being resized while grabbing the handle.
mBorder = Control::New();
- mBorder.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+ mBorder.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
mBorder.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH );
mBorder.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::HEIGHT );
border.Insert( BorderVisual::Property::SIZE, 3.f );
mBorder.SetProperty( Control::Property::BACKGROUND, border );
mContainer.Add( mBorder );
- mBorder.SetVisible(false);
+ mBorder.SetProperty( Actor::Property::VISIBLE,false);
mGrabCorner.RaiseToTop();
mHueAngleIndex = mLabel.RegisterProperty( "hue", 0.0f );
Renderer bgRenderer = mLabel.GetRendererAt(0);
- mOverrideMixColorIndex = DevelHandle::GetPropertyIndex( bgRenderer, ColorVisual::Property::MIX_COLOR );
+ mOverrideMixColorIndex = bgRenderer.GetPropertyIndex( ColorVisual::Property::MIX_COLOR );
Constraint constraint = Constraint::New<Vector3>( bgRenderer, mOverrideMixColorIndex, HSVColorConstraint(0.0f, 0.5f, 0.8f));
constraint.AddSource( Source( mLabel, mHueAngleIndex ) );
case SHADOW :
{
Vector2 shadowOffset( SHADOW_OFFSET ); // Will be set to zeros if color already set
- Property::Value value = mLabel.GetProperty( TextLabel::Property::SHADOW_COLOR );
+ Property::Value value = mLabel.GetProperty( TextLabel::Property::SHADOW );
Vector4 currentShadowColor;
value.Get( currentShadowColor );
{
if ( mColorButtons[i] )
{
- mColorButtons[ i ].SetProperty( Toolkit::DevelButton::Property::SELECTED, true );
+ mColorButtons[ i ].SetProperty( Toolkit::Button::Property::SELECTED, true );
}
break;
}
if ( ! mColorButtons[index] )
{
mColorButtons[index] = RadioButton::New();
- mColorButtons[index].SetSize( mButtonSize );
+ mColorButtons[index].SetProperty( Actor::Property::SIZE, mButtonSize );
mColorButtons[index].ClickedSignal().Connect( this, &TextLabelExample::OnColorSelected );
mColorButtons[index].SetProperty( Button::Property::TOGGLABLE, true );
Property::Map propertyMap;
propertyMap.Insert(Visual::Property::TYPE, Visual::COLOR);
propertyMap.Insert(ColorVisual::Property::MIX_COLOR, AVAILABLE_COLORS[ index ]);
- mColorButtons[index].SetProperty( Toolkit::DevelButton::Property::UNSELECTED_BACKGROUND_VISUAL, propertyMap );
- mColorButtons[index].SetProperty( Toolkit::DevelButton::Property::UNSELECTED_VISUAL, propertyMap );
+ mColorButtons[index].SetProperty( Toolkit::Button::Property::UNSELECTED_BACKGROUND_VISUAL, propertyMap );
+ mColorButtons[index].SetProperty( Toolkit::Button::Property::UNSELECTED_VISUAL, propertyMap );
mColorButtons[index].SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_CENTER );
mColorButtons[index].SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_CENTER );
propertyMap.Insert(Visual::Property::TYPE, Visual::COLOR);
propertyMap.Insert(ColorVisual::Property::MIX_COLOR, AVAILABLE_COLORS[ index ]);
- mColorButtons[index].SetProperty( Toolkit::DevelButton::Property::SELECTED_BACKGROUND_VISUAL, propertyMap );
+ mColorButtons[index].SetProperty( Toolkit::Button::Property::SELECTED_BACKGROUND_VISUAL, propertyMap );
- mColorButtons[index].SetProperty( Toolkit::DevelButton::Property::SELECTED_VISUAL,
+ mColorButtons[index].SetProperty( Toolkit::Button::Property::SELECTED_VISUAL,
Property::Map().Add( Visual::Property::TYPE, Visual::BORDER )
.Add( BorderVisual::Property::COLOR, Color::WHITE )
.Add( BorderVisual::Property::SIZE, 4.0f )
// Use a white button with 50% transparency as a clear color button
if ( Color::WHITE == AVAILABLE_COLORS[ index ] && styleButtonIndex != StyleType::TEXT_COLOR )
{
- mColorButtons[index].SetOpacity(0.5f);
+ mColorButtons[index].SetProperty( Actor::Property::OPACITY,0.5f);
mColorButtons[index].SetProperty( Toolkit::Button::Property::LABEL,
Property::Map().Add( Toolkit::Visual::Property::TYPE, Toolkit::Visual::TEXT )
mColorButtons[index].Lower();
// Position button using nice animation
- mColorButtons[index].SetY( -GAP_BETWEEN_BUTTONS );
+ mColorButtons[index].SetProperty( Actor::Property::POSITION_Y, -GAP_BETWEEN_BUTTONS );
float desiredPosition = -( mButtonSize.height + GAP_BETWEEN_BUTTONS ) * (index);
AlphaFunction focusedAlphaFunction = AlphaFunction( Vector2 ( 0.32f, 0.08f ), Vector2( 0.38f, 1.72f ) );
mColorButtonsAnimation.AnimateBy( Property( mColorButtons[index], Actor::Property::POSITION_Y ), desiredPosition, focusedAlphaFunction );
if ( ! mStyleButtons[index] )
{
mStyleButtons[index] = PushButton::New();
- mStyleButtons[index].SetProperty( Toolkit::DevelButton::Property::UNSELECTED_BACKGROUND_VISUAL, BUTTON_IMAGES[ index ] );
- mStyleButtons[index].SetProperty( Toolkit::DevelButton::Property::SELECTED_BACKGROUND_VISUAL, STYLE_SELECTED_IMAGE );
+ mStyleButtons[index].SetProperty( Toolkit::Button::Property::UNSELECTED_BACKGROUND_VISUAL, BUTTON_IMAGES[ index ] );
+ mStyleButtons[index].SetProperty( Toolkit::Button::Property::SELECTED_BACKGROUND_VISUAL, STYLE_SELECTED_IMAGE );
mStyleButtons[index].SetProperty( Dali::Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
- mStyleButtons[index].SetSize( mButtonSize );
+ mStyleButtons[index].SetProperty( Actor::Property::SIZE, mButtonSize );
mStyleButtons[index].ClickedSignal().Connect( this, &TextLabelExample::OnStyleButtonClicked );
}
}
}
// Only show the border during the panning
- mBorder.SetVisible(true);
+ mBorder.SetProperty( Actor::Property::VISIBLE,true);
HideStyleAndColorButtons();
}
if( mLayoutSize.x >= 2.0f ||
mLayoutSize.y >= 2.0f )
{
- mLayoutSize.x = std::min ( mLayoutSize.x, mStageSize.width );
- mLayoutSize.y = std::min ( mLayoutSize.y, mStageSize.height*.9f );
+ mLayoutSize.x = std::min ( mLayoutSize.x, mWindowSize.width );
+ mLayoutSize.y = std::min ( mLayoutSize.y, mWindowSize.height*.9f );
// Avoid pixel mis-alignment issue
Vector2 clampedSize = Vector2( std::max( ConvertToEven( static_cast<int>( mLayoutSize.x )), 2 ),
std::max( ConvertToEven( static_cast<int>( mLayoutSize.y )), 2 ) );
- mContainer.SetSize( clampedSize );
+ mContainer.SetProperty( Actor::Property::SIZE, clampedSize );
}
if( gesture.state == Gesture::Cancelled || gesture.state == Gesture::Finished )
{
// Resize the text label to match the container size when panning is finished
- mLabel.SetSize(mLayoutSize);
- mBorder.SetVisible(false);
+ mLabel.SetProperty( Actor::Property::SIZE, mLayoutSize );
+ mBorder.SetProperty( Actor::Property::VISIBLE,false);
}
}
case KEY_ZERO: // fall through
case KEY_ONE:
{
- mLabel.SetProperty( TextLabel::Property::RENDERING_BACKEND, event.keyCode - 10 );
+ mLabel.SetProperty( DevelTextLabel::Property::RENDERING_BACKEND, event.keyCode - 10 );
break;
}
case KEY_A: // Animate text colour
}
case KEY_S: // Shadow color
{
- if( Color::BLACK == mLabel.GetProperty<Vector4>( TextLabel::Property::SHADOW_COLOR ) )
+ Property::Value value = mLabel.GetProperty( TextLabel::Property::SHADOW );
+ Vector4 shadowColor;
+ value.Get( shadowColor );
+ Property::Map shadowMap;
+ if( Color::BLACK == shadowColor )
{
- mLabel.SetProperty( TextLabel::Property::SHADOW_COLOR, Color::RED );
+ shadowMap.Insert( "color", Color::RED );
+ mLabel.SetProperty( TextLabel::Property::SHADOW, shadowMap );
}
else
{
- mLabel.SetProperty( TextLabel::Property::SHADOW_COLOR, Color::BLACK );
+ shadowMap.Insert( "color", Color::BLACK );
+ mLabel.SetProperty( TextLabel::Property::SHADOW, shadowMap );
}
break;
}
}
case KEY_PLUS: // Increase shadow offset
{
- mLabel.SetProperty( TextLabel::Property::SHADOW_OFFSET, mLabel.GetProperty<Vector2>( TextLabel::Property::SHADOW_OFFSET ) + Vector2( 1.0f, 1.0f ) );
+ Property::Value value = mLabel.GetProperty( TextLabel::Property::SHADOW );
+ Vector2 shadowOffset;
+ value.Get( shadowOffset );
+ shadowOffset += Vector2( 1.0f, 1.0f );
+
+ Property::Map shadowMap;
+ shadowMap.Insert( "offset", shadowOffset );
+ mLabel.SetProperty( TextLabel::Property::SHADOW, shadowMap );
break;
}
case KEY_MINUS: // Decrease shadow offset
{
- mLabel.SetProperty( TextLabel::Property::SHADOW_OFFSET, mLabel.GetProperty<Vector2>( TextLabel::Property::SHADOW_OFFSET ) - Vector2( 1.0f, 1.0f ) );
+ Property::Value value = mLabel.GetProperty( TextLabel::Property::SHADOW );
+ Vector2 shadowOffset;
+ value.Get( shadowOffset );
+ shadowOffset -= Vector2( 1.0f, 1.0f );
+
+ Property::Map shadowMap;
+ shadowMap.Insert( "offset", shadowOffset );
+ mLabel.SetProperty( TextLabel::Property::SHADOW, shadowMap );
break;
}
Animation mColorButtonsAnimation;
- Size mStageSize;
+ Size mWindowSize;
Size mButtonSize;
unsigned int mLanguageId;