/*
- * Copyright (c) 2019 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.
namespace
{
-const Vector4 STAGE_COLOR( 211.0f / 255.0f, 211.0f / 255.0f, 211.0f / 255.0f, 1.0f ); ///< The color of the stage
+const Vector4 WINDOW_COLOR( 211.0f / 255.0f, 211.0f / 255.0f, 211.0f / 255.0f, 1.0f ); ///< The color of the window
const char * const THEME_PATH( DEMO_STYLE_DIR "tooltip-example-theme.json" ); ///< The theme used for this example
const float POSITION_INCREMENTER( 0.2f ); ///< The position difference between the controls along the Y-Axis.
} // unnamed namespace
// The Init signal is received once (only) during the Application lifetime
void Create( Application& application )
{
- // Hide the indicator bar
- application.GetWindow().ShowIndicator( Dali::Window::INVISIBLE );
-
- // Set the stage background color and connect to the stage's key signal to allow Back and Escape to exit.
- Stage stage = Stage::GetCurrent();
- stage.SetBackgroundColor( STAGE_COLOR );
- stage.KeyEventSignal().Connect( this, &TooltipController::OnKeyEvent );
- const Vector2 stageSize = stage.GetSize();
+ // Set the window background color and connect to the window's key signal to allow Back and Escape to exit.
+ Window window = application.GetWindow();
+ window.SetBackgroundColor( WINDOW_COLOR );
+ window.KeyEventSignal().Connect( this, &TooltipController::OnKeyEvent );
+ const Vector2 windowSize = window.GetSize();
// Add a text label at the top for information purposes
Control label = TextLabel::New( "Hover over buttons to see tooltip" );
- label.SetParentOrigin( ParentOrigin::TOP_CENTER );
- label.SetAnchorPoint( AnchorPoint::TOP_CENTER );
+ label.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_CENTER );
+ label.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_CENTER );
label.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "Center" );
- stage.Add( label );
+ window.Add( label );
// Simple tooltip from stylesheet
Control simple = PushButton::New();
simple.SetStyleName( "TooltipTextOnly" );
SetLabel( simple, "Simple" );
- Layout( simple, stageSize );
- stage.Add( simple );
+ Layout( simple, windowSize );
+ window.Add( simple );
// Tooltip with icon and text, from stylesheet
Control iconWithText = PushButton::New();
iconWithText.SetStyleName( "TooltipArray" );
SetLabel( iconWithText, "Icon with Text" );
- Layout( iconWithText, stageSize );
- stage.Add( iconWithText );
+ Layout( iconWithText, windowSize );
+ window.Add( iconWithText );
// Tooltip with custom style, from stylesheet
Control customFromStylesheet = PushButton::New();
customFromStylesheet.SetStyleName( "TooltipCustom" );
SetLabel( customFromStylesheet, "Custom From Stylesheet" );
- Layout( customFromStylesheet, stageSize );
- stage.Add( customFromStylesheet );
+ Layout( customFromStylesheet, windowSize );
+ window.Add( customFromStylesheet );
// Tooltip with custom style, from code
Control customFromCode = PushButton::New();
SetLabel( customFromCode, "Custom From Code" );
- Layout( customFromCode, stageSize );
+ Layout( customFromCode, windowSize );
customFromCode.SetProperty( DevelControl::Property::TOOLTIP,
{ { Tooltip::Property::CONTENT,
Property::Array{ { { { Toolkit::Visual::Property::TYPE, Visual::IMAGE },
{ { Tooltip::Background::Property::VISUAL, DEMO_IMAGE_DIR "tooltip.9.png" },
{ Tooltip::Background::Property::BORDER, Rect< int >( 1, 5, 5, 1 ) } } }
} );
- stage.Add( customFromCode );
+ window.Add( customFromCode );
}
/**
*/
void OnKeyEvent( const KeyEvent& event )
{
- if( event.state == KeyEvent::Down )
+ if( event.GetState() == KeyEvent::Down )
{
if ( IsKey( event, Dali::DALI_KEY_ESCAPE ) || IsKey( event, Dali::DALI_KEY_BACK ) )
{
/**
* @brief Lays out the control in the appropriate location.
* @param[in] control The control to layout.
- * @param[in] stageSize The size of the stage, passing it in so we don't have to retrieve it every time.
+ * @param[in] windowSize The size of the window, passing it in so we don't have to retrieve it every time.
*/
- void Layout( Control control, const Vector2& stageSize )
+ void Layout( Control control, const Vector2& windowSize )
{
if( control )
{
previousPosition += POSITION_INCREMENTER;
control.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS );
- control.SetSizeModeFactor( Vector3( 0.75, 0.1, 1.0 ) );
- control.SetAnchorPoint( AnchorPoint::CENTER );
- control.SetParentOrigin( ParentOrigin::TOP_CENTER );
- control.SetY( stageSize.height * previousPosition );
+ control.SetProperty( Actor::Property::SIZE_MODE_FACTOR, Vector3( 0.75, 0.1, 1.0 ) );
+ control.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
+ control.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_CENTER );
+ control.SetProperty( Actor::Property::POSITION_Y, windowSize.height * previousPosition );
}
}