*
*/
+#include <cstdlib>
+
#include <dali-toolkit-test-suite-utils.h>
// GTest fails to compile with "error: return-statement with a value, in function returning 'void'" error
// if using dali assert function so define new assert with returning void.
fprintf(stderr, \
"Following expression is not true:\n" \
"%s\n", #exp); \
- return; \
+ std::abort(); \
}
#include <gtest/gtest.h>
#undef GTEST_HAS_DEATH_TEST
int UtcDaliFlexboxLayoutTest(void)
{
- ToolkitTestApplication application;
tet_infoline("UtcDaliFlexboxLayoutTest");
- int argc = 0;
- testing::InitGoogleTest( &argc, static_cast<char**>(nullptr) );
+ int argc = 1;
+ const char* argv = "yoga-gtest";
+ testing::InitGoogleTest( &argc, const_cast< char** >( &argv ) );
// The test function is a 3rd party function that should return true if the test passes
if( !RUN_ALL_TESTS() )
Property::Value DummyControlImpl::GetProperty( BaseObject* object, Dali::Property::Index propertyIndex )
{
- Dali::Property::Value value;
+ Toolkit::DummyControl control = Toolkit::DummyControl::DownCast( Dali::BaseHandle( object ) );
+ DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>( control.GetImplementation() );
+
+ Visual::Base visual = dummyImpl.GetVisual( propertyIndex );
+ Property::Map map;
+ if( visual )
+ {
+ visual.CreatePropertyMap( map );
+ }
+ Dali::Property::Value value = map;
+
return value;
}
return control;
}
+int Impl::DummyControl::constructorCount;
+int Impl::DummyControl::destructorCount;
Impl::DummyControl::DummyControl()
: DummyControlImpl(),
keyInputFocusGained(false),
keyInputFocusLost(false)
{
+ ++constructorCount;
}
-Impl::DummyControl::~DummyControl() { }
-
+Impl::DummyControl::~DummyControl()
+{
+ ++destructorCount;
+}
void Impl::DummyControl::OnInitialize() { initializeCalled = true; }
bool Impl::DummyControl::OnAccessibilityActivated() { activatedCalled = true; return true; }
bool keyEventCalled;
bool keyInputFocusGained;
bool keyInputFocusLost;
+ static int constructorCount;
+ static int destructorCount;
Property::Map mLayouts;
RelayoutCallbackFunc mRelayoutCallback;
#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
#include <dali-toolkit/devel-api/visuals/image-visual-properties-devel.h>
#include <dali-toolkit/devel-api/visuals/animated-vector-image-visual-actions-devel.h>
+#include <dali-toolkit/devel-api/visuals/animated-vector-image-visual-signals-devel.h>
#include "dummy-control.h"
using namespace Dali;
const char* TEST_VECTOR_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/insta_camera.json";
+bool gAnimationFinishedSignalFired = false;
+
+void VisualEventSignal( Control control, Dali::Property::Index visualIndex, Dali::Property::Index signalId )
+{
+ if( visualIndex == DummyControl::Property::TEST_VISUAL && signalId == DevelAnimatedVectorImageVisual::Signal::ANIMATION_FINISHED )
+ {
+ gAnimationFinishedSignalFired = true;
+ }
+}
+
}
int UtcDaliVisualFactoryGetAnimatedVectorImageVisual01(void)
DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
- // test
+ Property::Map map = dummyControl.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
+ Property::Value* value = map.Find( DevelImageVisual::Property::PLAY_STATE );
+ DALI_TEST_CHECK( value->Get< int >() == static_cast< int >( DevelImageVisual::PlayState::PLAYING ) );
tet_infoline( "Test Pause action" );
DevelControl::DoAction( dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PAUSE, attributes );
application.SendNotification();
application.Render(16);
- // test
+ map = dummyControl.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
+ value = map.Find( DevelImageVisual::Property::PLAY_STATE );
+ DALI_TEST_CHECK( value->Get< int >() == static_cast< int >( DevelImageVisual::PlayState::PAUSED ) );
- tet_infoline( "Test Resume action" );
- DevelControl::DoAction( dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::RESUME, attributes );
+ tet_infoline( "Test Play action" );
+ DevelControl::DoAction( dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes );
application.SendNotification();
application.Render(16);
- // test
+ map = dummyControl.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
+ value = map.Find( DevelImageVisual::Property::PLAY_STATE );
+ DALI_TEST_CHECK( value->Get< int >() == static_cast< int >( DevelImageVisual::PlayState::PLAYING ) );
tet_infoline( "Test Stop action" );
DevelControl::DoAction( dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::STOP, attributes );
application.SendNotification();
application.Render(16);
- // test
+ map = dummyControl.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
+ value = map.Find( DevelImageVisual::Property::PLAY_STATE );
+ DALI_TEST_CHECK( value->Get< int >() == static_cast< int >( DevelImageVisual::PlayState::STOPPED ) );
tet_infoline( "Test Stop action again" );
DevelControl::DoAction( dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::STOP, attributes );
application.SendNotification();
application.Render(16);
- // test
+ map = dummyControl.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
+ value = map.Find( DevelImageVisual::Property::PLAY_STATE );
+ DALI_TEST_CHECK( value->Get< int >() == static_cast< int >( DevelImageVisual::PlayState::STOPPED ) );
tet_infoline( "Test Play action" );
DevelControl::DoAction( dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes );
application.SendNotification();
application.Render(16);
- // test
+ map = dummyControl.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
+ value = map.Find( DevelImageVisual::Property::PLAY_STATE );
+ DALI_TEST_CHECK( value->Get< int >() == static_cast< int >( DevelImageVisual::PlayState::PLAYING ) );
- dummyControl.SetSize( 100.0f, 100.0f );
+ // Change Size
+ Vector3 newSize( 100.0f, 100.0f, 0.0f );
+ dummyControl.SetSize( newSize );
application.SendNotification();
application.Render(16);
- // test
// Size should be changed
+ Vector3 naturalSize = dummyControl.GetNaturalSize();
+ DALI_TEST_CHECK( naturalSize == newSize );
dummyControl.Unparent();
}
application.SendNotification();
application.Render();
- DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
+ // Trigger count is 2 - resource ready and animation finished
+ DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 2 ), true, TEST_LOCATION );
// renderer is added to actor
DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
END_TEST;
}
+
+int UtcDaliAnimatedVectorImageVisualAnimationFinishedSignal(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( "UtcDaliAnimatedVectorImageVisualAnimationFinishedSignal" );
+
+ Property::Map propertyMap;
+ propertyMap.Add( Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE )
+ .Add( ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME )
+ .Add( DevelImageVisual::Property::LOOP_COUNT, 3 );
+
+ Visual::Base visual = VisualFactory::Get().CreateVisual( propertyMap );
+ DALI_TEST_CHECK( visual );
+
+ DummyControl actor = DummyControl::New( true );
+ DummyControlImpl& dummyImpl = static_cast< DummyControlImpl& >( actor.GetImplementation() );
+ dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
+
+ DevelControl::VisualEventSignal( actor ).Connect( &VisualEventSignal );
+
+ Vector2 controlSize( 20.f, 30.f );
+ actor.SetSize( controlSize );
+
+ Stage::GetCurrent().Add( actor );
+
+ Property::Map attributes;
+ DevelControl::DoAction( actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes );
+
+ application.SendNotification();
+ application.Render();
+
+ // Wait for animation finish
+ DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 2 ), true, TEST_LOCATION );
+
+ Property::Map map = actor.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
+ Property::Value* value = map.Find( DevelImageVisual::Property::PLAY_STATE );
+ DALI_TEST_CHECK( value->Get< int >() == static_cast< int >( DevelImageVisual::PlayState::STOPPED ) );
+
+ DALI_TEST_EQUALS( gAnimationFinishedSignalFired, true, TEST_LOCATION );
+
+ END_TEST;
+}
DALI_TEST_CHECK( !value.Get( url ) );
Property::Map map;
- DALI_TEST_CHECK( !value.Get( map ) );
+ value.Get( map );
+ DALI_TEST_CHECK( map.Empty() );
END_TEST;
}
DALI_TEST_CHECK( !value.Get( url ) );
Property::Map map;
- DALI_TEST_CHECK( !value.Get( map ) );
+ value.Get( map );
+ DALI_TEST_CHECK( map.Empty() );
END_TEST;
}
DALI_TEST_CHECK( !value.Get( url ) );
Property::Map map;
- DALI_TEST_CHECK( !value.Get( map ) );
+ value.Get( map );
+ DALI_TEST_CHECK( map.Empty() );
std::string resource_url;
Property::Value val = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
application.Render( 16 );
DALI_TEST_CHECK( ! value.Get( url ) ); // Value should be empty
- DALI_TEST_CHECK( ! value.Get( map ) ); // Value should be empty
+ value.Get( map );
+ DALI_TEST_CHECK( map.Empty() ); // Value should be empty
DALI_TEST_CHECK( ! visual ); // Visual should be invalid
// Set a URL
visual = DevelControl::GetVisual( controlImpl, ImageView::Property::IMAGE );
DALI_TEST_CHECK( ! value.Get( url ) ); // Value should be empty
- DALI_TEST_CHECK( ! value.Get( map ) ); // Value should be empty
+ value.Get( map );
+ DALI_TEST_CHECK( map.Empty() ); // Value should be empty
DALI_TEST_CHECK( ! visual ); // Visual should be invalid
// Set an Image
visual = DevelControl::GetVisual( controlImpl, ImageView::Property::IMAGE );
DALI_TEST_CHECK( ! value.Get( url ) ); // Value should be empty
- DALI_TEST_CHECK( ! value.Get( map ) ); // Value should be empty
+ value.Get( map );
+ DALI_TEST_CHECK( map.Empty() ); // Value should be empty
DALI_TEST_CHECK( ! visual ); // Visual should be invalid
// Set a URL in property map
#include <dali-toolkit/devel-api/layouting/layout-group-impl.h>
#include <../custom-layout.h>
+#include <dummy-control.h>
#include <layout-utils.h>
END_TEST;
}
+int UtcDaliLayouting_CheckResourceLeak01(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliLayouting_CheckResourceLeak01 - Remove animating layout and add child to stage" );
+
+ Dali::Toolkit::Impl::DummyControl::constructorCount = 0;
+ Dali::Toolkit::Impl::DummyControl::destructorCount = 0;
+
+ Stage stage = Stage::GetCurrent();
+ auto container = Control::New();
+ auto linearLayout = LinearLayout::New();
+ linearLayout.SetAnimateLayout( true );
+
+ DevelControl::SetLayout( container, linearLayout );
+ container.SetName( "Container" );
+
+ stage.Add( container );
+
+ DummyControl control = DummyControl::New( true );
+ control.SetName( "DummyControl01" );
+ control.SetSize( 100, 100 );
+ container.Add( control );
+
+ control = DummyControl::New( true );
+ control.SetName( "DummyControl02" );
+ control.SetSize( 100, 100 );
+ container.Add( control );
+
+ linearLayout.SetAnimateLayout( true );
+
+ DALI_TEST_EQUALS( Dali::Toolkit::Impl::DummyControl::constructorCount, 2, TEST_LOCATION );
+ DALI_TEST_EQUALS( Dali::Toolkit::Impl::DummyControl::destructorCount, 0, TEST_LOCATION );
+
+ // Initial rendering done
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>( 0.5f * 1000.0f ) + 1u /*just after the end of the animation*/ );
+
+ DALI_TEST_EQUALS( Dali::Toolkit::Impl::DummyControl::constructorCount, 2, TEST_LOCATION );
+ DALI_TEST_EQUALS( Dali::Toolkit::Impl::DummyControl::destructorCount, 0, TEST_LOCATION );
+
+ stage.Remove( container );
+ container.Reset();
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>( 0.5f * 1000.0f ) + 1u /*just after the end of the animation*/ );
+
+ DALI_TEST_EQUALS( Dali::Toolkit::Impl::DummyControl::constructorCount, 2, TEST_LOCATION );
+ DALI_TEST_EQUALS( Dali::Toolkit::Impl::DummyControl::destructorCount, 1, TEST_LOCATION );
+
+ Stage::GetCurrent().Add( control );
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>( 0.5f * 1000.0f ) + 1u /*just after the end of the animation*/ );
+
+ DALI_TEST_EQUALS( Dali::Toolkit::Impl::DummyControl::constructorCount, 2, TEST_LOCATION );
+ DALI_TEST_EQUALS( Dali::Toolkit::Impl::DummyControl::destructorCount, 1, TEST_LOCATION );
+
+ stage.Remove( control );
+ control.Reset();
+
+ application.SendNotification();
+ application.Render(static_cast<unsigned int>( 0.5f * 1000.0f ) + 1u /*just after the end of the animation*/ );
+
+ DALI_TEST_EQUALS( Dali::Toolkit::Impl::DummyControl::constructorCount, 2, TEST_LOCATION );
+ DALI_TEST_EQUALS( Dali::Toolkit::Impl::DummyControl::destructorCount, 2, TEST_LOCATION );
+
+ END_TEST;
+}
+
const char* const PROPERTY_NAME_VERTICAL_ALIGNMENT = "verticalAlignment";
const char* const PROPERTY_NAME_TEXT_COLOR = "textColor";
const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR = "placeholderTextColor";
-const char* const PROPERTY_NAME_SHADOW_OFFSET = "shadowOffset";
-const char* const PROPERTY_NAME_SHADOW_COLOR = "shadowColor";
const char* const PROPERTY_NAME_PRIMARY_CURSOR_COLOR = "primaryCursorColor";
const char* const PROPERTY_NAME_SECONDARY_CURSOR_COLOR = "secondaryCursorColor";
const char* const PROPERTY_NAME_ENABLE_CURSOR_BLINK = "enableCursorBlink";
DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_VERTICAL_ALIGNMENT ) == TextField::Property::VERTICAL_ALIGNMENT );
DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextField::Property::TEXT_COLOR );
DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR ) == TextField::Property::PLACEHOLDER_TEXT_COLOR );
- DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SHADOW_OFFSET ) == TextField::Property::SHADOW_OFFSET );
- DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SHADOW_COLOR ) == TextField::Property::SHADOW_COLOR );
DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PRIMARY_CURSOR_COLOR ) == TextField::Property::PRIMARY_CURSOR_COLOR );
DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SECONDARY_CURSOR_COLOR ) == TextField::Property::SECONDARY_CURSOR_COLOR );
DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_CURSOR_BLINK ) == TextField::Property::ENABLE_CURSOR_BLINK );
field.SetProperty( TextField::Property::PLACEHOLDER_TEXT_COLOR, Color::RED );
DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::PLACEHOLDER_TEXT_COLOR ), Color::RED, TEST_LOCATION );
- // Check shadow properties.
- field.SetProperty( TextField::Property::SHADOW_OFFSET, Vector2( 1.f, 1.f ) );
- DALI_TEST_EQUALS( field.GetProperty<Vector2>( TextField::Property::SHADOW_OFFSET ), Vector2( 1.f, 1.f ), TEST_LOCATION );
- field.SetProperty( TextField::Property::SHADOW_COLOR, Color::GREEN );
- DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SHADOW_COLOR ), Color::GREEN, TEST_LOCATION );
-
// Check cursor properties
field.SetProperty( TextField::Property::PRIMARY_CURSOR_COLOR, Color::RED );
DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::PRIMARY_CURSOR_COLOR ), Color::RED, TEST_LOCATION );
/*
- * 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.
const char* const PROPERTY_NAME_HORIZONTAL_ALIGNMENT = "horizontalAlignment";
const char* const PROPERTY_NAME_VERTICAL_ALIGNMENT = "verticalAlignment";
const char* const PROPERTY_NAME_TEXT_COLOR = "textColor";
-const char* const PROPERTY_NAME_SHADOW_OFFSET = "shadowOffset";
-const char* const PROPERTY_NAME_SHADOW_COLOR = "shadowColor";
-const char* const PROPERTY_NAME_UNDERLINE_ENABLED = "underlineEnabled";
-const char* const PROPERTY_NAME_UNDERLINE_COLOR = "underlineColor";
-const char* const PROPERTY_NAME_UNDERLINE_HEIGHT = "underlineHeight";
const char* const PROPERTY_NAME_ENABLE_MARKUP = "enableMarkup";
const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL = "enableAutoScroll";
const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL_SPEED = "autoScrollSpeed";
DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextLabel::Property::HORIZONTAL_ALIGNMENT );
DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_VERTICAL_ALIGNMENT ) == TextLabel::Property::VERTICAL_ALIGNMENT );
DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextLabel::Property::TEXT_COLOR );
- DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_SHADOW_OFFSET ) == TextLabel::Property::SHADOW_OFFSET );
- DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_SHADOW_COLOR ) == TextLabel::Property::SHADOW_COLOR );
- DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_UNDERLINE_ENABLED ) == TextLabel::Property::UNDERLINE_ENABLED );
- DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_UNDERLINE_COLOR ) == TextLabel::Property::UNDERLINE_COLOR );
- DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_UNDERLINE_HEIGHT) == TextLabel::Property::UNDERLINE_HEIGHT );
DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP) == TextLabel::Property::ENABLE_MARKUP );
DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL ) == TextLabel::Property::ENABLE_AUTO_SCROLL );
DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL_SPEED ) == TextLabel::Property::AUTO_SCROLL_SPEED );
// Check that text color can be properly set
label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::BLUE );
DALI_TEST_EQUALS( label.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ), Color::BLUE, TEST_LOCATION );
- // The underline color is changed as well.
- DALI_TEST_EQUALS( label.GetProperty<Vector4>( TextLabel::Property::UNDERLINE_COLOR ), Color::BLUE, TEST_LOCATION );
Property::Map underlineMapSet;
Property::Map underlineMapGet;
DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
- // Check that shadow parameters can be correctly set
- label.SetProperty( TextLabel::Property::SHADOW_OFFSET, Vector2( 3.0f, 3.0f ) );
- DALI_TEST_EQUALS( label.GetProperty<Vector2>( TextLabel::Property::SHADOW_OFFSET ), Vector2( 3.0f, 3.0f ), TEST_LOCATION );
- label.SetProperty( TextLabel::Property::SHADOW_COLOR, Color::BLUE );
- DALI_TEST_EQUALS( label.GetProperty<Vector4>( TextLabel::Property::SHADOW_COLOR ), Color::BLUE, TEST_LOCATION );
-
- // Check that underline parameters can be correctly set
- label.SetProperty( TextLabel::Property::UNDERLINE_ENABLED, true );
- DALI_TEST_EQUALS( label.GetProperty<bool>( TextLabel::Property::UNDERLINE_ENABLED ), true, TEST_LOCATION );
- label.SetProperty( TextLabel::Property::UNDERLINE_COLOR, Color::RED );
- DALI_TEST_EQUALS( label.GetProperty<Vector4>( TextLabel::Property::UNDERLINE_COLOR ), Color::RED, TEST_LOCATION );
- label.SetProperty( TextLabel::Property::UNDERLINE_HEIGHT, 1.0f );
- DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::UNDERLINE_HEIGHT ), 1.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
-
TextLabel label2 = TextLabel::New( "New text" );
DALI_TEST_CHECK( label2 );
DALI_TEST_EQUALS( label2.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("New text"), TEST_LOCATION );
// test natural size with multi-line and line spacing
{
TextLabel label3 = TextLabel::New("Some text here\nend there\nend here");
- Vector3 expected0(414.f, 192.f, 0.0f);
- Vector3 expected1(414.f, 252.f, 0.0f);
+ Vector3 oneLineNaturalSize = label3.GetNaturalSize();
label3.SetProperty(TextLabel::Property::MULTI_LINE, true);
label3.SetProperty(TextLabel::Property::LINE_SPACING, 0);
- DALI_TEST_EQUALS(expected0, label3.GetNaturalSize(), TEST_LOCATION);
- label3.SetProperty(TextLabel::Property::LINE_SPACING, 20);
- DALI_TEST_EQUALS(expected1, label3.GetNaturalSize(), TEST_LOCATION);
+ Vector3 multiLineNaturalSize = label3.GetNaturalSize();
+
+ // The width of the text when multi-line is enabled will be smaller (lines separated on '\n')
+ // The height of the text when multi-line is enabled will be larger
+ DALI_TEST_CHECK( oneLineNaturalSize.width > multiLineNaturalSize.width );
+ DALI_TEST_CHECK( oneLineNaturalSize.height < multiLineNaturalSize.height );
+
+ // Change line spacing, meaning height will increase by 3 times the amount specified as we have three lines
+ // Everything else will remain the same
+ int lineSpacing = 20;
+ label3.SetProperty( TextLabel::Property::LINE_SPACING, lineSpacing );
+ Vector3 expectedAfterLineSpacingApplied( multiLineNaturalSize );
+ expectedAfterLineSpacingApplied.height += 3 * lineSpacing;
+ DALI_TEST_EQUALS( expectedAfterLineSpacingApplied, label3.GetNaturalSize(), TEST_LOCATION );
}
- // single line, line spacing must not affect natural size
+ // single line, line spacing must not affect natural size of the text, only add the spacing to the height
{
- const Vector3 expected0(948.f, 64.f, 0.0f);
- const Vector3 expected1(948.f, 84.f, 0.0f);
TextLabel label3 = TextLabel::New("Some text here end there end here");
label3.SetProperty(TextLabel::Property::MULTI_LINE, false);
label3.SetProperty(TextLabel::Property::LINE_SPACING, 0);
- DALI_TEST_EQUALS(expected0, label3.GetNaturalSize(), TEST_LOCATION);
- label3.SetProperty(TextLabel::Property::LINE_SPACING, 20);
- DALI_TEST_EQUALS(expected1, label3.GetNaturalSize(), TEST_LOCATION);
+ Vector3 textNaturalSize = label3.GetNaturalSize();
+ int lineSpacing = 20;
+ label3.SetProperty( TextLabel::Property::LINE_SPACING, lineSpacing );
+ Vector3 expectedNaturalSizeWithLineSpacing( textNaturalSize );
+ expectedNaturalSizeWithLineSpacing.height += lineSpacing;
+ DALI_TEST_EQUALS( expectedNaturalSizeWithLineSpacing, label3.GetNaturalSize(), TEST_LOCATION );
}
// Check the line spacing property
DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
// Turn on all the effects
label.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
label.SetProperty( TextLabel::Property::MULTI_LINE, true );
- label.SetProperty( TextLabel::Property::UNDERLINE_ENABLED, true );
- label.SetProperty( TextLabel::Property::UNDERLINE_COLOR, Color::RED );
- label.SetProperty( TextLabel::Property::SHADOW_OFFSET, Vector2( 1.0f, 1.0f ) );
- label.SetProperty( TextLabel::Property::SHADOW_COLOR, Color::BLUE );
+
+ Property::Map underlineMap;
+ underlineMap.Insert( "enable", "true" );
+ underlineMap.Insert( "color", "red" );
+ label.SetProperty( TextLabel::Property::UNDERLINE, underlineMap );
+
+ Property::Map shadowMap;
+ shadowMap.Insert( "color", Color::BLUE );
+ shadowMap.Insert( "offset", Vector2( 1.0f, 1.0f ) );
+ label.SetProperty( TextLabel::Property::SHADOW, shadowMap );
try
{
/*
- * 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.
int UtcDaliVisualSize(void)
{
ToolkitTestApplication application;
- tet_infoline( "UtcDaliVisualGetNaturalSize" );
+ tet_infoline( "UtcDaliVisualSize" );
VisualFactory factory = VisualFactory::Get();
Vector2 controlSize( 20.f, 30.f );
propertyMap.Clear();
propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::TEXT );
propertyMap.Insert( TextVisual::Property::ENABLE_MARKUP, true );
- propertyMap.Insert( TextVisual::Property::TEXT, "<font family='TizenSans' size='12'>Hello world</font>" );
+ propertyMap.Insert( TextVisual::Property::TEXT, "<font family='TizenSansRegular' size='12'>Hello world</font>" );
propertyMap.Insert( TextVisual::Property::MULTI_LINE, true );
Visual::Base textVisual = factory.CreateVisual( propertyMap );
textVisual.GetNaturalSize( naturalSize );
- DALI_TEST_EQUALS( naturalSize, Size( 80.f, 20.f ), TEST_LOCATION );
+ DALI_TEST_EQUALS( naturalSize, Size( 86.f, 20.f ), TEST_LOCATION );
const float height = textVisual.GetHeightForWidth( 40.f );
- DALI_TEST_EQUALS( height, 40.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+ DALI_TEST_EQUALS( height, 57.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
//AnimatedImageVisual
Visual::Base animatedImageVisual = factory.CreateVisual( TEST_GIF_FILE_NAME, ImageDimensions() );
ALIASES += SINCE_1_1="@since 1.1"
ALIASES += SINCE_1_2="@since 1.2"
ALIASES += SINCE_1_3="@since 1.3"
+ALIASES += SINCE_1_4="@since 1.4"
# Extra tags for Tizen 3.0
ALIASES += SINCE_1_2_2="@since 1.2.2"
ALIASES += DEPRECATED_1_2_10="@deprecated Deprecated since 1.2.10"
ALIASES += DEPRECATED_1_2="@deprecated Deprecated since 1.2"
ALIASES += DEPRECATED_1_3="@deprecated Deprecated since 1.3"
+ALIASES += DEPRECATED_1_4="@deprecated Deprecated since 1.4"
ALIASES += PLATFORM=""
ALIASES += PRIVLEVEL_PLATFORM=""
#ALIASES += SINCE_1_1="\par Since:\n 3.0, DALi version 1.1"
#ALIASES += SINCE_1_2="\par Since:\n 4.0, DALi version 1.2"
#ALIASES += SINCE_1_3="\par Since:\n 5.0, DALi version 1.3"
+#ALIASES += SINCE_1_4="\par Since:\n 6.0, DALi version 1.4"
## Extra tags for Tizen 3.0
#ALIASES += SINCE_1_2_2="\par Since:\n 3.0, DALi version 1.2.2"
#ALIASES += DEPRECATED_1_2_10="@deprecated Deprecated since 3.0, DALi version 1.2.10"
#ALIASES += DEPRECATED_1_2="@deprecated Deprecated since 4.0, DALi version 1.2"
#ALIASES += DEPRECATED_1_3="@deprecated Deprecated since 5.0, DALi version 1.3"
+#ALIASES += DEPRECATED_1_4="@deprecated Deprecated since 6.0, DALi version 1.4"
#ALIASES += PLATFORM="@platform"
#ALIASES += PRIVLEVEL_PLATFORM="\par Privilege Level:\n platform"
return controlDataImpl.IsLayoutingRequired();
}
+VisualEventSignalType& VisualEventSignal( Control control )
+{
+ Internal::Control& internalControl = Toolkit::Internal::GetImplementation( control );
+ Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get( internalControl );
+ return controlDataImpl.VisualEventSignal();
+}
+
} // namespace DevelControl
} // namespace Toolkit
*/
DALI_TOOLKIT_API void SetInputMethodContext( Internal::Control& control, InputMethodContext& inputMethodContext );
-/*
+/**
* @brief Get the layout associated with this control, if any.
*
* @return A handle to the layout, or empty.
*/
DALI_TOOLKIT_API Toolkit::LayoutItem GetLayout( Internal::Control& control );
-/*
+/**
* @brief Get the layout associated with a control, if any.
*
* @return A handle to the layout, or empty.
*/
DALI_TOOLKIT_API bool IsLayoutingRequired( Control control );
+/**
+ * @brief Visual Event signal type
+ */
+using VisualEventSignalType = Signal< void ( Control, Dali::Property::Index, Dali::Property::Index ) >;
+
+/**
+ * @brief This signal is emitted when a visual has an event to notify.
+ *
+ * A callback of the following type may be connected:
+ * @code
+ * void YourCallbackName( Control control, Dali::Property::Index visualIndex, Dali::Property::Index signalId );
+ * @endcode
+ * @return The signal to connect to
+ */
+DALI_TOOLKIT_API VisualEventSignalType& VisualEventSignal( Control control );
+
} // namespace DevelControl
} // namespace Toolkit
VERTICAL_ALIGNMENT = Dali::Toolkit::TextField::Property::VERTICAL_ALIGNMENT,
TEXT_COLOR = Dali::Toolkit::TextField::Property::TEXT_COLOR,
PLACEHOLDER_TEXT_COLOR = Dali::Toolkit::TextField::Property::PLACEHOLDER_TEXT_COLOR,
- SHADOW_OFFSET = Dali::Toolkit::TextField::Property::SHADOW_OFFSET,
- SHADOW_COLOR = Dali::Toolkit::TextField::Property::SHADOW_COLOR,
PRIMARY_CURSOR_COLOR = Dali::Toolkit::TextField::Property::PRIMARY_CURSOR_COLOR,
SECONDARY_CURSOR_COLOR = Dali::Toolkit::TextField::Property::SECONDARY_CURSOR_COLOR,
ENABLE_CURSOR_BLINK = Dali::Toolkit::TextField::Property::ENABLE_CURSOR_BLINK,
HORIZONTAL_ALIGNMENT = Dali::Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT,
VERTICAL_ALIGNMENT = Dali::Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT,
UNUSED_PROPERTY_TEXT_COLOR = Dali::Toolkit::TextLabel::Property::UNUSED_PROPERTY_TEXT_COLOR,
- SHADOW_OFFSET = Dali::Toolkit::TextLabel::Property::SHADOW_OFFSET,
- SHADOW_COLOR = Dali::Toolkit::TextLabel::Property::SHADOW_COLOR,
- UNDERLINE_ENABLED = Dali::Toolkit::TextLabel::Property::UNDERLINE_ENABLED,
- UNDERLINE_COLOR = Dali::Toolkit::TextLabel::Property::UNDERLINE_COLOR,
- UNDERLINE_HEIGHT = Dali::Toolkit::TextLabel::Property::UNDERLINE_HEIGHT,
ENABLE_MARKUP = Dali::Toolkit::TextLabel::Property::ENABLE_MARKUP,
ENABLE_AUTO_SCROLL = Dali::Toolkit::TextLabel::Property::ENABLE_AUTO_SCROLL,
AUTO_SCROLL_SPEED = Dali::Toolkit::TextLabel::Property::AUTO_SCROLL_SPEED,
$(devel_api_src_dir)/visuals/animated-gradient-visual-properties-devel.h \
$(devel_api_src_dir)/visuals/animated-image-visual-actions-devel.h \
$(devel_api_src_dir)/visuals/animated-vector-image-visual-actions-devel.h \
+ $(devel_api_src_dir)/visuals/animated-vector-image-visual-signals-devel.h \
$(devel_api_src_dir)/visuals/color-visual-properties-devel.h \
$(devel_api_src_dir)/visuals/image-visual-properties-devel.h \
$(devel_api_src_dir)/visuals/image-visual-actions-devel.h \
{
// An object with a unique_ptr to an opaque structure must define it's destructor in the translation unit
// where the opaque structure is defined. It cannot use the default method in the header file.
+ RemoveAll();
}
Toolkit::LayoutGroup::LayoutId LayoutGroup::Add( LayoutItem& child )
if( childLayout )
{
Remove( *childLayout.Get() );
- RequestLayout( Dali::Toolkit::LayoutTransitionData::Type::ON_CHILD_REMOVE, child, Actor() );
+ RequestLayout( Dali::Toolkit::LayoutTransitionData::Type::ON_CHILD_REMOVE, Actor(), child );
}
}
}
void LayoutItem::Initialize( Handle& owner, const std::string& containerType )
{
- mImpl->mOwner = &(owner.GetBaseObject());
+ mImpl->mOwner = owner;
RegisterChildProperties( containerType );
OnInitialize(); // Ensure direct deriving class gets initialized
}
Handle LayoutItem::GetOwner() const
{
- return Handle::DownCast(BaseHandle(mImpl->mOwner));
+ return mImpl->mOwner.GetHandle();
}
void LayoutItem::Unparent()
SetParent(nullptr);
// Last, clear owner
- mImpl->mOwner = NULL;
+ mImpl->mOwner.Reset();
}
LayoutTransitionDataPtr LayoutItem::GetDefaultTransition()
Extents LayoutItem::GetPadding() const
{
- Toolkit::Control control = Toolkit::Control::DownCast( mImpl->mOwner );
+ Toolkit::Control control = Toolkit::Control::DownCast( GetOwner() );
if( control )
{
Extents padding = control.GetProperty<Extents>( Toolkit::Control::Property::PADDING );
Extents LayoutItem::GetMargin() const
{
- Toolkit::Control control = Toolkit::Control::DownCast( mImpl->mOwner );
+ Toolkit::Control control = Toolkit::Control::DownCast( GetOwner() );
if ( control )
{
return control.GetProperty<Extents>( Toolkit::Control::Property::MARGIN );
void LayoutItem::RequestLayout()
{
- Toolkit::Control control = Toolkit::Control::DownCast( mImpl->mOwner );
+ Toolkit::Control control = Toolkit::Control::DownCast( GetOwner() );
if( control )
{
DALI_LOG_INFO( gLayoutFilter, Debug::Verbose, "LayoutItem::RequestLayout control(%s)\n",
control.GetName().c_str() );
+
+ // @todo Enforce failure if called in Measure/Layout passes.
+ mImpl->SetPrivateFlag( Impl::PRIVATE_FLAG_FORCE_LAYOUT );
+ Toolkit::LayoutController layoutController = Toolkit::LayoutController::Get();
+ layoutController.RequestLayout( Toolkit::LayoutItem( this ) );
}
- // @todo Enforce failure if called in Measure/Layout passes.
- mImpl->SetPrivateFlag( Impl::PRIVATE_FLAG_FORCE_LAYOUT );
- Toolkit::LayoutController layoutController = Toolkit::LayoutController::Get();
- layoutController.RequestLayout( Toolkit::LayoutItem( this ) );
}
void LayoutItem::RequestLayout( Dali::Toolkit::LayoutTransitionData::Type layoutAnimationType )
{
- Toolkit::Control control = Toolkit::Control::DownCast( mImpl->mOwner );
+ Toolkit::Control control = Toolkit::Control::DownCast( GetOwner() );
if ( control )
{
DALI_LOG_INFO( gLayoutFilter, Debug::Verbose, "LayoutItem::RequestLayout control(%s) layoutTranstionType(%d)\n",
control.GetName().c_str(), (int)layoutAnimationType );
+
+ // @todo Enforce failure if called in Measure/Layout passes.
+ mImpl->SetPrivateFlag( Impl::PRIVATE_FLAG_FORCE_LAYOUT );
+ Toolkit::LayoutController layoutController = Toolkit::LayoutController::Get();
+ layoutController.RequestLayout( Toolkit::LayoutItem(this), layoutAnimationType );
}
- // @todo Enforce failure if called in Measure/Layout passes.
- mImpl->SetPrivateFlag( Impl::PRIVATE_FLAG_FORCE_LAYOUT );
- Toolkit::LayoutController layoutController = Toolkit::LayoutController::Get();
- layoutController.RequestLayout( Toolkit::LayoutItem(this), layoutAnimationType );
}
void LayoutItem::RequestLayout( Dali::Toolkit::LayoutTransitionData::Type layoutAnimationType, Actor gainedChild, Actor lostChild )
{
- Toolkit::Control control = Toolkit::Control::DownCast( mImpl->mOwner );
+ Toolkit::Control control = Toolkit::Control::DownCast( GetOwner() );
if ( control )
{
DALI_LOG_INFO( gLayoutFilter, Debug::Verbose, "LayoutItem::RequestLayout control(%s) layoutTranstionType(%d)\n",
control.GetName().c_str(), (int)layoutAnimationType );
+
+ // @todo Enforce failure if called in Measure/Layout passes.
+ mImpl->SetPrivateFlag( Impl::PRIVATE_FLAG_FORCE_LAYOUT );
+ Toolkit::LayoutController layoutController = Toolkit::LayoutController::Get();
+ layoutController.RequestLayout( Toolkit::LayoutItem(this), layoutAnimationType, gainedChild, lostChild );
}
- // @todo Enforce failure if called in Measure/Layout passes.
- mImpl->SetPrivateFlag( Impl::PRIVATE_FLAG_FORCE_LAYOUT );
- Toolkit::LayoutController layoutController = Toolkit::LayoutController::Get();
- layoutController.RequestLayout( Toolkit::LayoutItem(this), layoutAnimationType, gainedChild, lostChild );
}
bool LayoutItem::IsLayoutRequested() const
LayoutLength LayoutItem::GetSuggestedMinimumWidth() const
{
auto owner = GetOwner();
- auto actor = Actor::DownCast(owner);
+ auto actor = Actor::DownCast( owner );
auto naturalSize = actor ? actor.GetNaturalSize() : Vector3::ZERO;
return std::max( mImpl->mMinimumSize.GetWidth(), LayoutLength( naturalSize.width ) );
LayoutLength LayoutItem::GetSuggestedMinimumHeight() const
{
auto owner = GetOwner();
- auto actor = Actor::DownCast(owner);
+ auto actor = Actor::DownCast( owner );
auto naturalSize = actor ? actor.GetNaturalSize() : Vector3::ZERO;
return std::max( mImpl->mMinimumSize.GetHeight(), LayoutLength( naturalSize.height ) );
{
PLAY, ///< Play the animated vector image.
PAUSE, ///< Pause the animated vector image.
- RESUME, ///< Resume the animated vector image.
STOP ///< Stop the animated vector image. This is also Default playback mode.
};
--- /dev/null
+#ifndef DALI_TOOLKIT_DEVEL_API_VISUALS_ANIMATED_VECTOR_IMAGE_VISUAL_SIGNALS_DEVEL_H
+#define DALI_TOOLKIT_DEVEL_API_VISUALS_ANIMATED_VECTOR_IMAGE_VISUAL_SIGNALS_DEVEL_H
+
+/*
+ * Copyright (c) 2018 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace DevelAnimatedVectorImageVisual
+{
+
+/**
+ * @brief Signal that the animated vector image visual can emit.
+ */
+namespace Signal
+{
+/**
+ * @brief The available signals for this visual
+ */
+enum Type
+{
+ ANIMATION_FINISHED ///< Animation has finished.
+};
+
+} // namespace Signal
+
+} // namespace DevelAnimatedVectorImageVisual
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // DALI_TOOLKIT_DEVEL_API_VISUALS_ANIMATED_VECTOR_IMAGE_VISUAL_SIGNALS_DEVEL_H
* @details Name "playRange", Type Property::VECTOR2, between 0 and 1
* @note Default 0 and 1
*/
- PLAY_RANGE = ORIENTATION_CORRECTION + 4
+ PLAY_RANGE = ORIENTATION_CORRECTION + 4,
+
+ /**
+ * @brief The playing state the AnimatedVectorImageVisual will use.
+ * @details Name "playState", type PlayState (Property::INTEGER)
+ * @note This property is read-only.
+ */
+ PLAY_STATE = ORIENTATION_CORRECTION + 5
};
} //namespace Property
+/**
+ * @brief Enumeration for what state the animation is in.
+ */
+enum class PlayState
+{
+ STOPPED, ///< Animation has stopped
+ PLAYING, ///< The animation is playing
+ PAUSED ///< The animation is paused
+};
+
} // namespace DevelImageVisual
} // namespace Toolkit
index, DevelControl::IsVisualEnabled( *this, index )?"true":"false" );
// enable the visual if needed for current state
const bool enabled = ( ( index == VISUAL_INDEX_FOR_STATE[ mButtonState ][ BACKGROUND ] )||
- ( index == VISUAL_INDEX_FOR_STATE[ mButtonState ][ FOREGROUND ] ) );
+ ( index == VISUAL_INDEX_FOR_STATE[ mButtonState ][ FOREGROUND ] )||
+ ( index == Toolkit::Button::Property::LABEL ) );
DevelControl::RegisterVisual( *this, index, buttonVisual, enabled, visualDepth );
}
else
/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 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.
void ToggleButton::PrepareVisual(Property::Index index, Toolkit::Visual::Base& visual)
{
- DevelControl::RegisterVisual( *this, index, visual, true );
- DevelControl::EnableVisual( *this, index, false );
+ bool enabled = false; // Disabled by default
+
+ // Unregister the visual with the given index if registered previously
+ if( DevelControl::GetVisual( *this, index ) )
+ {
+ // Check whether it was enabled to ensure we do the same with the new visual we're registering
+ enabled = DevelControl::IsVisualEnabled( *this, index );
+ DevelControl::UnregisterVisual( *this, index );
+ }
+
+ DevelControl::RegisterVisual( *this, index, visual, enabled );
}
void ToggleButton::RelayoutVisual( Property::Index index, const Vector2& size )
mKeyInputFocusGainedSignal(),
mKeyInputFocusLostSignal(),
mResourceReadySignal(),
+ mVisualEventSignal(),
mPinchGestureDetector(),
mPanGestureDetector(),
mTapGestureDetector(),
Internal::Visual::Base& visualImpl = Toolkit::GetImplementation( visual );
// Stop observing the visual
- visualImpl.RemoveResourceObserver( *this );
+ visualImpl.RemoveEventObserver( *this );
}
void Control::Impl::StartObservingVisual( Toolkit::Visual::Base& visual)
{
Internal::Visual::Base& visualImpl = Toolkit::GetImplementation( visual );
- // start observing the visual for resource ready
- visualImpl.AddResourceObserver( *this );
+ // start observing the visual for events
+ visualImpl.AddEventObserver( *this );
}
// Called by a Visual when it's resource is ready
}
}
+void Control::Impl::NotifyVisualEvent( Visual::Base& object, Property::Index signalId )
+{
+ for( auto registeredIter = mVisuals.Begin(), end = mVisuals.End(); registeredIter != end; ++registeredIter )
+ {
+ Internal::Visual::Base& registeredVisualImpl = Toolkit::GetImplementation( (*registeredIter)->visual );
+ if( &object == ®isteredVisualImpl )
+ {
+ Dali::Toolkit::Control handle( mControlImpl.GetOwner() );
+ mVisualEventSignal.Emit( handle, (*registeredIter)->index, signalId );
+ break;
+ }
+ }
+}
+
bool Control::Impl::IsResourceReady() const
{
// Iterate through and check all the enabled visuals are ready
return mControlImpl.mImpl->mIsLayoutingRequired;
}
+DevelControl::VisualEventSignalType& Control::Impl::VisualEventSignal()
+{
+ return mVisualEventSignal;
+}
+
} // namespace Internal
} // namespace Toolkit
#include <string>
// INTERNAL INCLUDES
-#include <dali-toolkit/internal/visuals/visual-resource-observer.h>
+#include <dali-toolkit/internal/visuals/visual-event-observer.h>
#include <dali-toolkit/public-api/controls/control-impl.h>
#include <dali/devel-api/common/owner-container.h>
#include <dali-toolkit/devel-api/layouting/layout-item-impl.h>
/**
* @brief Holds the Implementation for the internal control class
*/
-class Control::Impl : public ConnectionTracker, public Visual::ResourceObserver
+class Control::Impl : public ConnectionTracker, public Visual::EventObserver
{
public:
/**
* @brief Called when a resource is ready.
* @param[in] object The visual whose resources are ready
- * @note Overriding method in Visual::ResourceObserver.
+ * @note Overriding method in Visual::EventObserver.
*/
- virtual void ResourceReady( Visual::Base& object );
+ virtual void ResourceReady( Visual::Base& object ) override;
+
+ /**
+ * @brief Called when an event occurs.
+ * @param[in] object The visual whose events occur
+ * @param[in] signalId The signal to emit. See Visual to find supported signals
+ * @note Overriding method in Visual::EventObserver.
+ */
+ virtual void NotifyVisualEvent( Visual::Base& object, Property::Index signalId ) override;
/**
* @copydoc Dali::Toolkit::DevelControl::RegisterVisual()
*/
bool IsLayoutingRequired();
+ /**
+ * @copydoc DevelControl::VisualEventSignal()
+ */
+ DevelControl::VisualEventSignalType& VisualEventSignal();
+
private:
/**
Toolkit::Control::KeyInputFocusSignalType mKeyInputFocusGainedSignal;
Toolkit::Control::KeyInputFocusSignalType mKeyInputFocusLostSignal;
Toolkit::Control::ResourceReadySignalType mResourceReadySignal;
+ DevelControl::VisualEventSignalType mVisualEventSignal;
// Gesture Detection
PinchGestureDetector mPinchGestureDetector;
Scripting::CreatePropertyMap( impl.mImage, map );
value = map;
}
- else if( !impl.mPropertyMap.Empty() )
+ else
{
- value = impl.mPropertyMap;
+ Property::Map map;
+ Toolkit::Visual::Base visual = DevelControl::GetVisual( impl, Toolkit::ImageView::Property::IMAGE );
+ if( visual )
+ {
+ visual.CreatePropertyMap( map );
+ }
+ value = map;
}
break;
}
DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "verticalAlignment", STRING, VERTICAL_ALIGNMENT )
DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "textColor", VECTOR4, TEXT_COLOR )
DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "placeholderTextColor", VECTOR4, PLACEHOLDER_TEXT_COLOR )
-DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "shadowOffset", VECTOR2, SHADOW_OFFSET )
-DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "shadowColor", VECTOR4, SHADOW_COLOR )
DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "primaryCursorColor", VECTOR4, PRIMARY_CURSOR_COLOR )
DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "secondaryCursorColor", VECTOR4, SECONDARY_CURSOR_COLOR )
DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "enableCursorBlink", BOOLEAN, ENABLE_CURSOR_BLINK )
}
break;
}
- case Toolkit::TextField::Property::SHADOW_OFFSET:
- {
- if( impl.mController )
- {
- const Vector2& shadowOffset = value.Get< Vector2 >();
- DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p SHADOW_OFFSET %f,%f\n", impl.mController.Get(), shadowOffset.x, shadowOffset.y );
-
- if ( impl.mController->GetShadowOffset() != shadowOffset )
- {
- impl.mController->SetShadowOffset( shadowOffset );
- impl.mRenderer.Reset();
- }
- }
- break;
- }
- case Toolkit::TextField::Property::SHADOW_COLOR:
- {
- if( impl.mController )
- {
- const Vector4& shadowColor = value.Get< Vector4 >();
- DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p SHADOW_COLOR %f,%f,%f,%f\n", impl.mController.Get(), shadowColor.r, shadowColor.g, shadowColor.b, shadowColor.a );
-
- if ( impl.mController->GetShadowColor() != shadowColor )
- {
- impl.mController->SetShadowColor( shadowColor );
- impl.mRenderer.Reset();
- }
- }
- break;
- }
case Toolkit::TextField::Property::PRIMARY_CURSOR_COLOR:
{
if( impl.mDecorator )
}
break;
}
- case Toolkit::TextField::Property::SHADOW_OFFSET:
- {
- if ( impl.mController )
- {
- value = impl.mController->GetShadowOffset();
- }
- break;
- }
- case Toolkit::TextField::Property::SHADOW_COLOR:
- {
- if ( impl.mController )
- {
- value = impl.mController->GetShadowColor();
- }
- break;
- }
case Toolkit::TextField::Property::PRIMARY_CURSOR_COLOR:
{
if( impl.mDecorator )
DALI_PROPERTY_REGISTRATION( Toolkit, TextLabel, "horizontalAlignment", STRING, HORIZONTAL_ALIGNMENT )
DALI_PROPERTY_REGISTRATION( Toolkit, TextLabel, "verticalAlignment", STRING, VERTICAL_ALIGNMENT )
DALI_PROPERTY_REGISTRATION( Toolkit, TextLabel, "unusedPropertyTextColor", VECTOR4, UNUSED_PROPERTY_TEXT_COLOR )
-DALI_PROPERTY_REGISTRATION( Toolkit, TextLabel, "shadowOffset", VECTOR2, SHADOW_OFFSET )
-DALI_PROPERTY_REGISTRATION( Toolkit, TextLabel, "shadowColor", VECTOR4, SHADOW_COLOR )
-DALI_PROPERTY_REGISTRATION( Toolkit, TextLabel, "underlineEnabled", BOOLEAN, UNDERLINE_ENABLED )
-DALI_PROPERTY_REGISTRATION( Toolkit, TextLabel, "underlineColor", VECTOR4, UNDERLINE_COLOR )
-DALI_PROPERTY_REGISTRATION( Toolkit, TextLabel, "underlineHeight", FLOAT, UNDERLINE_HEIGHT )
DALI_PROPERTY_REGISTRATION( Toolkit, TextLabel, "enableMarkup", BOOLEAN, ENABLE_MARKUP )
DALI_PROPERTY_REGISTRATION( Toolkit, TextLabel, "enableAutoScroll", BOOLEAN, ENABLE_AUTO_SCROLL )
DALI_PROPERTY_REGISTRATION( Toolkit, TextLabel, "autoScrollSpeed", INTEGER, AUTO_SCROLL_SPEED )
impl.mTextUpdateNeeded = true;
break;
}
-
- case Toolkit::TextLabel::Property::SHADOW_OFFSET:
- {
- if( impl.mController )
- {
- const Vector2& shadowOffset = value.Get< Vector2 >();
- if ( impl.mController->GetShadowOffset() != shadowOffset )
- {
- impl.mController->SetShadowOffset( shadowOffset );
- impl.mTextUpdateNeeded = true;
- }
- }
- break;
- }
- case Toolkit::TextLabel::Property::SHADOW_COLOR:
- {
- if( impl.mController )
- {
- const Vector4& shadowColor = value.Get< Vector4 >();
- if ( impl.mController->GetShadowColor() != shadowColor )
- {
- impl.mController->SetShadowColor( shadowColor );
- impl.mTextUpdateNeeded = true;
- }
- }
- break;
- }
- case Toolkit::TextLabel::Property::UNDERLINE_COLOR:
- {
- if( impl.mController )
- {
- const Vector4& color = value.Get< Vector4 >();
- if ( impl.mController->GetUnderlineColor() != color )
- {
- impl.mController->SetUnderlineColor( color );
- impl.mTextUpdateNeeded = true;
- }
- }
- break;
- }
- case Toolkit::TextLabel::Property::UNDERLINE_ENABLED:
- {
- if( impl.mController )
- {
- const bool enabled = value.Get< bool >();
- if ( impl.mController->IsUnderlineEnabled() != enabled )
- {
- impl.mController->SetUnderlineEnabled( enabled );
- impl.mTextUpdateNeeded = true;
- }
- }
- break;
- }
-
- case Toolkit::TextLabel::Property::UNDERLINE_HEIGHT:
- {
- if( impl.mController )
- {
- float height = value.Get< float >();
- if( fabsf( impl.mController->GetUnderlineHeight() - height ) > Math::MACHINE_EPSILON_1000 )
- {
- impl.mController->SetUnderlineHeight( height );
- impl.mTextUpdateNeeded = true;
- }
- }
- break;
- }
case Toolkit::TextLabel::Property::ENABLE_MARKUP:
{
if( impl.mController )
value = label.GetProperty( Toolkit::TextLabel::Property::TEXT_COLOR );
break;
}
- case Toolkit::TextLabel::Property::SHADOW_OFFSET:
- {
- if ( impl.mController )
- {
- value = impl.mController->GetShadowOffset();
- }
- break;
- }
- case Toolkit::TextLabel::Property::SHADOW_COLOR:
- {
- if ( impl.mController )
- {
- value = impl.mController->GetShadowColor();
- }
- break;
- }
- case Toolkit::TextLabel::Property::UNDERLINE_COLOR:
- {
- if ( impl.mController )
- {
- value = impl.mController->GetUnderlineColor();
- }
- break;
- }
- case Toolkit::TextLabel::Property::UNDERLINE_ENABLED:
- {
- if ( impl.mController )
- {
- value = impl.mController->IsUnderlineEnabled();
- }
- break;
- }
- case Toolkit::TextLabel::Property::UNDERLINE_HEIGHT:
- {
- if ( impl.mController )
- {
- value = impl.mController->GetUnderlineHeight();
- }
- break;
- }
case Toolkit::TextLabel::Property::ENABLE_MARKUP:
{
if( impl.mController )
auto actor = Actor::DownCast( layoutItem.GetOwner() );
if ( actor )
{
- DALI_LOG_INFO( gLogFilter, Debug::Concise, "LayoutController::RequestLayout owner[%s] layoutItem[%p] layoutTransitionType(%d)\n", actor.GetName().c_str(), &layoutItem, layoutTransitionType );
+ DALI_LOG_INFO( gLogFilter, Debug::Concise, "LayoutController::RequestLayout owner[%s] layoutItem[%p] layoutTransitionType(%d) gainedChild[%s] lostChild[%s]\n",
+ actor.GetName().c_str(), &layoutItem, layoutTransitionType,
+ gainedChild ? gainedChild.GetName().c_str() : "",
+ lostChild ? lostChild.GetName().c_str() : "");
}
else
{
continue;
}
- Actor actor = Actor::DownCast( layoutDataElement.handle );
- LayoutDataAnimator animator = layoutData.layoutAnimatorArray[ layoutDataElement.animatorIndex ];
- float width = actor.GetProperty<int>( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION );
- float height = actor.GetProperty<int>( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION );
-
- if( layoutDataElement.AdjustMeasuredSize( width, height, animator.animatorType ) )
+ Actor actor = layoutDataElement.handle.GetHandle();
+ if( actor )
{
- mActorSizeSpecs.push_back( ActorSizeSpec( actor ) );
- actor.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, static_cast<int>( width ) );
- actor.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, static_cast<int>( height ) );
+ LayoutDataAnimator animator = layoutData.layoutAnimatorArray[ layoutDataElement.animatorIndex ];
+ float width = actor.GetProperty<int>( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION );
+ float height = actor.GetProperty<int>( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION );
+
+ if( layoutDataElement.AdjustMeasuredSize( width, height, animator.animatorType ) )
+ {
+ mActorSizeSpecs.push_back( ActorSizeSpec( actor ) );
+ actor.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, static_cast<int>( width ) );
+ actor.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, static_cast<int>( height ) );
+ }
}
}
{
for( auto& actorSizeSpec : mActorSizeSpecs )
{
- Actor actor = actorSizeSpec.actor;
- actor.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, actorSizeSpec.widthSpec );
- actor.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, actorSizeSpec.heightSpec );
+ Actor actor = actorSizeSpec.actor.GetHandle();
+ if( actor )
+ {
+ actor.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, actorSizeSpec.widthSpec );
+ actor.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, actorSizeSpec.heightSpec );
+ }
}
}
for( auto layoutPositionData : layoutPositionDataArray )
{
- Actor actor = Actor::DownCast( layoutPositionData.handle );
+ Actor actor = layoutPositionData.handle.GetHandle();
if( actor && ( !layoutPositionData.animated || all ) )
{
- if ( !layoutPositionData.animated )
+ if( !layoutPositionData.animated )
{
actor.SetPosition( layoutPositionData.left, layoutPositionData.top );
actor.SetSize( layoutPositionData.right - layoutPositionData.left, layoutPositionData.bottom - layoutPositionData.top );
{
if( layoutDataElement.animatorIndex >= 0 )
{
- Actor actor = Actor::DownCast( layoutDataElement.handle );
+ Actor actor = layoutDataElement.handle.GetHandle();
if ( actor )
{
LayoutDataAnimator animator = layoutAnimatorArray[ layoutDataElement.animatorIndex ];
{
}
- Actor actor;
+ WeakHandle<Actor> actor;
int widthSpec;
int heightSpec;
};
{
layoutController.PerformLayoutPositioning( layoutDataPositionArray, true );
layoutController.mAnimationFinishedFunctors.pop_front();
- if (layoutTransitionType != -1)
+ if( layoutTransitionType != -1 )
{
LayoutTransitionDataPtr layoutTransitionDataPtr = layoutItem->GetTransitionData( layoutTransitionType );
layoutTransitionDataPtr->EmitSignalFinish( layoutTransitionType );
LayoutData* LayoutItem::Impl::sLayoutData = nullptr;
LayoutItem::Impl::Impl()
-: mOwner( nullptr ),
+: mOwner(),
mLayoutParent( nullptr ),
mOldWidthMeasureSpec( 0 ),
mOldHeightMeasureSpec( 0 ),
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
+#include <dali/public-api/object/weak-handle.h>
#include <dali-toolkit/devel-api/layouting/layout-item-impl.h>
#include <dali-toolkit/devel-api/layouting/layout-controller.h>
#include <dali-toolkit/devel-api/layouting/layout-size.h>
Impl();
public:
- BaseObject* mOwner; ///< Control or Visual that owns this layout. Raw pointer to prevent cyclic references
+ WeakHandle<Handle> mOwner; ///< Control or Visual that owns this layout. Weak pointer to prevent cyclic references
LayoutParent* mLayoutParent; ///< The containing layout parent.
MeasureSpec mOldWidthMeasureSpec;
return false;
}
- Actor actor = Actor::DownCast( handle );
+ Actor actor = handle.GetHandle();
float animateByMultiplier = ( animatorType == Toolkit::LayoutTransitionData::Animator::Type::ANIMATE_BY ) ? 1.0f : 0.0f;
Vector3 size = actor.GetCurrentSize();
void LayoutDataElement::UpdatePropertyIndex()
{
- if( propertyIndex == -1 && handle && !propertyName.empty() )
+ if( propertyIndex == -1 && !propertyName.empty() )
{
- Actor actor = Actor::DownCast( handle );
- propertyIndex = DevelHandle::GetPropertyIndex( actor, Property::Key( propertyName ) );
+ Actor actor = handle.GetHandle();
+ if( actor )
+ {
+ propertyIndex = DevelHandle::GetPropertyIndex( actor, Property::Key( propertyName ) );
+ }
}
}
}
LayoutTransitionData::PropertyAnimator::PropertyAnimator( )
- : handle( Actor( ) )
+ : handle()
, map()
, interpolation( Animation::Linear )
{
// Add the children animators
for( const LayoutDataElement& iter : layoutData.childrenLayoutDataArray )
{
- if( iter.handle != nullptr && iter.handle != child )
+ Actor actor = iter.handle.GetHandle();
+ if( actor && actor != child )
{
continue;
}
LayoutDataElement layoutDataElement = iter;
+ Actor gainedChild = layoutData.layoutTransition.gainedChild.GetHandle();
+ Actor lostChild = layoutData.layoutTransition.lostChild.GetHandle();
switch ( layoutDataElement.condition )
{
case Dali::Toolkit::LayoutTransitionData::Condition::ON_ADD:
if ( layoutData.layoutTransition.layoutTransitionType != Dali::Toolkit::LayoutTransitionData::ON_CHILD_ADD
- || layoutData.layoutTransition.gainedChild != child )
+ || gainedChild != child )
{
continue;
}
break;
case Dali::Toolkit::LayoutTransitionData::Condition::ON_REMOVE:
if( layoutData.layoutTransition.layoutTransitionType != Dali::Toolkit::LayoutTransitionData::ON_CHILD_REMOVE
- || layoutData.layoutTransition.lostChild != child )
+ || lostChild != child )
{
continue;
}
break;
case Dali::Toolkit::LayoutTransitionData::Condition::ON_FOCUS_GAINED:
if( layoutData.layoutTransition.layoutTransitionType != Dali::Toolkit::LayoutTransitionData::ON_CHILD_FOCUS
- || layoutData.layoutTransition.gainedChild != child )
+ || gainedChild != child )
{
continue;
}
break;
case Dali::Toolkit::LayoutTransitionData::Condition::ON_FOCUS_LOST:
if( layoutData.layoutTransition.layoutTransitionType != Dali::Toolkit::LayoutTransitionData::ON_CHILD_FOCUS
- || layoutData.layoutTransition.lostChild != child )
+ || lostChild != child )
{
continue;
}
// Collect the transition animators
for( const LayoutDataElement& iter : mLayoutDataElements )
{
- if( iter.handle == nullptr || iter.handle != owner )
+ Actor actor = iter.handle.GetHandle();
+ if( !actor || actor != owner )
{
layoutData.childrenLayoutDataArray.push_back( iter );
continue;
#include <dali/public-api/object/base-object.h>
#include <dali/public-api/object/property-map.h>
#include <dali/public-api/object/type-registry.h>
+#include <dali/public-api/object/weak-handle.h>
#include <dali/public-api/actors/actor-enumerations.h>
#include <dali/public-api/animation/animation.h>
LayoutItemPtr layoutItem;
int layoutTransitionType;
- Actor gainedChild;
- Actor lostChild;
+ WeakHandle<Actor> gainedChild;
+ WeakHandle<Actor> lostChild;
};
const float DEFAULT_TRANSITION_DURATION( 0.5f );
struct LayoutPositionData
{
- LayoutPositionData( Handle handle, float left, float top, float right, float bottom, bool animated ) :
+ LayoutPositionData( Actor handle, float left, float top, float right, float bottom, bool animated ) :
handle( handle ), left( left ), top( top ), right( right ), bottom( bottom ), animated( animated ), updateWithCurrentSize(false)
{
};
- BaseHandle handle;
+ WeakHandle<Actor> handle;
float left;
float top;
float right;
void UpdateAnimatorIndex( const LayoutAnimatorArray& animators );
void UpdatePositionDataIndex( LayoutData& layoutData );
- BaseHandle handle;
+ WeakHandle<Actor> handle;
std::string propertyName;
Property::Index propertyIndex;
Property::Value initialValue;
PropertyAnimator( Actor actor, Property::Map map, Path path, Vector3 forward );
PropertyAnimator( Actor actor, Property::Map map, KeyFrames keyFrames, Animation::Interpolation interpolation );
- BaseHandle handle;
+ WeakHandle<Actor> handle;
Property::Map map;
attribute mediump vec2 aTexCoord;
attribute mediump vec4 aColor;
uniform mediump vec2 uOffset;
-uniform mediump mat4 uMvpMatrix;
+uniform highp mat4 uMvpMatrix;
varying mediump vec2 vTexCoord;
varying mediump vec4 vColor;
/*
- * 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.
mImpl->mTextUpdateInfo.mFullRelayoutNeeded = true;
mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending | layoutOperations );
+ // Need to recalculate natural size
+ mImpl->mRecalculateNaturalSize = true;
+
mImpl->RequestRelayout();
}
}
#include <dali-toolkit/public-api/visuals/image-visual-properties.h>
#include <dali-toolkit/public-api/visuals/visual-properties.h>
#include <dali-toolkit/devel-api/visuals/image-visual-properties-devel.h>
+#include <dali-toolkit/devel-api/visuals/animated-vector-image-visual-signals-devel.h>
#include <dali-toolkit/internal/visuals/image-visual-shader-factory.h>
#include <dali-toolkit/internal/visuals/visual-factory-cache.h>
#include <dali-toolkit/internal/visuals/visual-string-constants.h>
}
map.Insert( Toolkit::DevelImageVisual::Property::LOOP_COUNT, static_cast< int >( mLoopCount ) );
map.Insert( Toolkit::DevelImageVisual::Property::PLAY_RANGE, static_cast< Vector2 >( mPlayRange ) );
+
+ if( mVectorRasterizeThread )
+ {
+ map.Insert( Toolkit::DevelImageVisual::Property::PLAY_STATE, static_cast< int >( mVectorRasterizeThread->GetPlayState() ) );
+ }
+ else
+ {
+ map.Insert( Toolkit::DevelImageVisual::Property::PLAY_STATE, static_cast< int >( DevelImageVisual::PlayState::STOPPED ) );
+ }
}
void AnimatedVectorImageVisual::DoCreateInstancePropertyMap( Property::Map& map ) const
mVectorRasterizeThread = std::unique_ptr< VectorRasterizeThread >( new VectorRasterizeThread( mUrl.GetUrl(), mImpl->mRenderer, width, height ) );
mVectorRasterizeThread->SetResourceReadyCallback( new EventThreadCallback( MakeCallback( this, &AnimatedVectorImageVisual::OnResourceReady ) ) );
+ mVectorRasterizeThread->SetAnimationFinishedCallback( new EventThreadCallback( MakeCallback( this, &AnimatedVectorImageVisual::OnAnimationFinished ) ) );
mVectorRasterizeThread->SetLoopCount( mLoopCount );
mVectorRasterizeThread->SetPlayRange( mPlayRange );
void AnimatedVectorImageVisual::OnDoAction( const Property::Index actionId, const Property::Value& attributes )
{
- if( actionId == mActionStatus )
- {
- return;
- }
-
// Check if action is valid for this visual type and perform action if possible
switch( actionId )
{
mActionStatus = DevelAnimatedVectorImageVisual::Action::PAUSE;
break;
}
- case DevelAnimatedVectorImageVisual::Action::RESUME:
- {
- if( mVectorRasterizeThread )
- {
- mVectorRasterizeThread->ResumeAnimation();
- DevelStage::SetRenderingBehavior( Stage::GetCurrent(), DevelStage::Rendering::CONTINUOUSLY );
- }
- mActionStatus = DevelAnimatedVectorImageVisual::Action::RESUME;
- break;
- }
case DevelAnimatedVectorImageVisual::Action::STOP:
{
if( mVectorRasterizeThread )
{
+ bool emitSignal = false;
+ if( mVectorRasterizeThread->GetPlayState() != DevelImageVisual::PlayState::STOPPED )
+ {
+ emitSignal = true;
+ }
+
mVectorRasterizeThread->StopAnimation();
DevelStage::SetRenderingBehavior( Stage::GetCurrent(), DevelStage::Rendering::IF_REQUIRED );
+
+ if( emitSignal )
+ {
+ OnAnimationFinished();
+ }
}
mActionStatus = DevelAnimatedVectorImageVisual::Action::STOP;
break;
}
}
+void AnimatedVectorImageVisual::OnAnimationFinished()
+{
+ if( mImpl->mEventObserver )
+ {
+ mImpl->mEventObserver->NotifyVisualEvent( *this, DevelAnimatedVectorImageVisual::Signal::ANIMATION_FINISHED );
+ }
+}
+
} // namespace Internal
} // namespace Toolkit
*/
void OnResourceReady();
+ /**
+ * @brief Event callback from rasterize thread. This is called after the animation is finished.
+ */
+ void OnAnimationFinished();
+
// Undefined
AnimatedVectorImageVisual( const AnimatedVectorImageVisual& visual ) = delete;
mVectorRenderer(),
mConditionalWait(),
mMutex(),
- mResourceReadyTrigger( NULL ),
+ mResourceReadyTrigger(),
+ mAnimationFinishedTrigger(),
mPlayRange( 0.0f, 1.0f ),
+ mPlayState( DevelImageVisual::PlayState::STOPPED ),
mCurrentFrame( 0 ),
mTotalFrame( 0 ),
mStartFrame( 0 ),
mLoopCount( LOOP_FOREVER ),
mCurrentLoop( 0 ),
mNeedRender( false ),
- mPlaying( false ),
- mPaused( false ),
mDestroyThread( false ),
mResourceReady( false ),
mLogFactory( Dali::Adaptor::Get().GetLogFactory() )
DALI_LOG_INFO( gVectorAnimationLogFilter, Debug::Verbose, "VectorRasterizeThread::~VectorRasterizeThread: Join\n" );
Join();
-
- delete mResourceReadyTrigger;
}
void VectorRasterizeThread::Run()
void VectorRasterizeThread::StartAnimation()
{
ConditionalWait::ScopedLock lock( mConditionalWait );
- if( !mPlaying )
+ if( mPlayState != DevelImageVisual::PlayState::PLAYING )
{
- mPlaying = true;
- mPaused = false;
+ if( mPlayState == DevelImageVisual::PlayState::STOPPED )
+ {
+ // Reset the current frame and the current loop
+ mCurrentFrame = mStartFrame;
+ mCurrentLoop = 0;
+ }
+
+ mPlayState = DevelImageVisual::PlayState::PLAYING;
mConditionalWait.Notify( lock );
DALI_LOG_INFO( gVectorAnimationLogFilter, Debug::Verbose, "VectorRasterizeThread::StartAnimation: Start\n" );
void VectorRasterizeThread::StopAnimation()
{
ConditionalWait::ScopedLock lock( mConditionalWait );
- if( mPlaying )
+ if( mPlayState != DevelImageVisual::PlayState::STOPPED )
{
- mPlaying = false;
- mPaused = false;
+ mPlayState = DevelImageVisual::PlayState::STOPPED;
DALI_LOG_INFO( gVectorAnimationLogFilter, Debug::Verbose, "VectorRasterizeThread::StopAnimation: Stop\n" );
}
void VectorRasterizeThread::PauseAnimation()
{
ConditionalWait::ScopedLock lock( mConditionalWait );
- if( mPlaying && !mPaused )
+ if( mPlayState == DevelImageVisual::PlayState::PLAYING )
{
- mPaused = true;
+ mPlayState = DevelImageVisual::PlayState::PAUSED;
DALI_LOG_INFO( gVectorAnimationLogFilter, Debug::Verbose, "VectorRasterizeThread::PauseAnimation: Pause\n" );
}
}
-void VectorRasterizeThread::ResumeAnimation()
-{
- ConditionalWait::ScopedLock lock( mConditionalWait );
- if( mPlaying && mPaused )
- {
- mPaused = false;
- mConditionalWait.Notify( lock );
-
- DALI_LOG_INFO( gVectorAnimationLogFilter, Debug::Verbose, "VectorRasterizeThread::ResumeAnimation: Resume\n" );
- }
-}
-
void VectorRasterizeThread::RenderFrame()
{
ConditionalWait::ScopedLock lock( mConditionalWait );
void VectorRasterizeThread::SetResourceReadyCallback( EventThreadCallback* callback )
{
ConditionalWait::ScopedLock lock( mConditionalWait );
- mResourceReadyTrigger = callback;
+ mResourceReadyTrigger = std::unique_ptr< EventThreadCallback >( callback );
+}
+
+void VectorRasterizeThread::SetAnimationFinishedCallback( EventThreadCallback* callback )
+{
+ ConditionalWait::ScopedLock lock( mConditionalWait );
+ mAnimationFinishedTrigger = std::unique_ptr< EventThreadCallback >( callback );
}
void VectorRasterizeThread::SetLoopCount( int16_t count )
}
}
+DevelImageVisual::PlayState VectorRasterizeThread::GetPlayState()
+{
+ return mPlayState;
+}
+
bool VectorRasterizeThread::IsThreadReady()
{
ConditionalWait::ScopedLock lock( mConditionalWait );
- if( ( !mPlaying || mPaused ) && !mNeedRender && !mDestroyThread )
+ if( mPlayState != DevelImageVisual::PlayState::PLAYING && !mNeedRender && !mDestroyThread )
{
DALI_LOG_INFO( gVectorAnimationLogFilter, Debug::Verbose, "VectorRasterizeThread::IsThreadReady: Wait\n" );
- if( !mPlaying )
- {
- mCurrentFrame = mStartFrame;
- mCurrentLoop = 0;
- }
-
mConditionalWait.Wait( lock );
}
// Rasterize
mVectorRenderer.Render( mCurrentFrame );
- if( mPlaying && !mPaused )
+ if( mPlayState == DevelImageVisual::PlayState::PLAYING )
{
if( ++mCurrentFrame >= mEndFrame )
{
if( mCurrentLoop >= mLoopCount )
{
// Animation is finished
- mPlaying = false;
+ mPlayState = DevelImageVisual::PlayState::STOPPED;
+
+ mAnimationFinishedTrigger->Trigger();
+
+ DALI_LOG_INFO( gVectorAnimationLogFilter, Debug::Verbose, "VectorRasterizeThread::Rasterize: Animation is finished\n" );
}
else
{
#include <dali/devel-api/threading/thread.h>
#include <dali/integration-api/adaptors/log-factory-interface.h>
#include <string>
+#include <memory>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/devel-api/visuals/image-visual-properties-devel.h>
namespace Dali
{
void PauseAnimation();
/**
- * @brief Resume the vector animation.
- */
- void ResumeAnimation();
-
- /**
* @brief Render one frame. The current frame number will be increased.
*/
void RenderFrame();
void SetResourceReadyCallback( EventThreadCallback* callback );
/**
+ * @brief This callback is called after the animation is finished.
+ * @param[in] callback The animation finished callback
+ */
+ void SetAnimationFinishedCallback( EventThreadCallback* callback );
+
+ /**
* @brief Enable looping for 'count' repeats. -1 means to repeat forever.
* @param[in] count The number of times to loop
*/
*/
void SetPlayRange( Vector2 range );
+ /**
+ * @brief Get the play state
+ * @return The play state
+ */
+ DevelImageVisual::PlayState GetPlayState();
+
protected:
/**
private:
- std::string mUrl;
- VectorAnimationRenderer mVectorRenderer;
- ConditionalWait mConditionalWait;
- Dali::Mutex mMutex;
- EventThreadCallback* mResourceReadyTrigger;
- Vector2 mPlayRange;
- uint32_t mCurrentFrame;
- uint32_t mTotalFrame;
- uint32_t mStartFrame;
- uint32_t mEndFrame;
- uint32_t mWidth;
- uint32_t mHeight;
- int16_t mLoopCount;
- int16_t mCurrentLoop;
- bool mNeedRender;
- bool mPlaying;
- bool mPaused;
- bool mDestroyThread; ///< Whether the thread be destroyed
- bool mResourceReady;
+ std::string mUrl;
+ VectorAnimationRenderer mVectorRenderer;
+ ConditionalWait mConditionalWait;
+ Dali::Mutex mMutex;
+ std::unique_ptr< EventThreadCallback > mResourceReadyTrigger;
+ std::unique_ptr< EventThreadCallback > mAnimationFinishedTrigger;
+ Vector2 mPlayRange;
+ DevelImageVisual::PlayState mPlayState;
+ uint32_t mCurrentFrame;
+ uint32_t mTotalFrame;
+ uint32_t mStartFrame;
+ uint32_t mEndFrame;
+ uint32_t mWidth;
+ uint32_t mHeight;
+ int16_t mLoopCount;
+ int16_t mCurrentLoop;
+ bool mNeedRender;
+ bool mDestroyThread; ///< Whether the thread be destroyed
+ bool mResourceReady;
const Dali::LogFactoryInterface& mLogFactory; ///< The log factory
};
mVisualSize = visualSize;
}
}
+
+ if(mImpl->mRenderer)
+ {
+ mImpl->mTransform.RegisterUniforms(mImpl->mRenderer, Direction::LEFT_TO_RIGHT);
+ }
}
} // namespace Internal
Internal::Visual::Base::Impl::Impl(FittingMode fittingMode)
: mCustomShader( NULL ),
mBlendSlotDelegate( NULL ),
- mResourceObserver( NULL ),
+ mEventObserver( NULL ),
mTransform(),
mMixColor( Color::WHITE ),
mControlSize( Vector2::ZERO ),
// INTERNAL INCLUDES
#include <dali-toolkit/internal/visuals/visual-base-impl.h>
-#include <dali-toolkit/internal/visuals/visual-resource-observer.h>
+#include <dali-toolkit/internal/visuals/visual-event-observer.h>
#include <dali-toolkit/public-api/align-enumerations.h>
#include <dali-toolkit/public-api/visuals/visual-properties.h>
#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
Renderer mRenderer;
CustomShader* mCustomShader;
SlotDelegate<Visual::Base>* mBlendSlotDelegate; ///< Used to own mix color animation connection
- ResourceObserver* mResourceObserver; ///< Allows controls to observe when the visual resources are loaded and ready
+ EventObserver* mEventObserver; ///< Allows controls to observe when the visual has events to notify
std::string mName;
Transform mTransform;
Vector4 mMixColor;
return mImpl->mMixColor;
}
-void Visual::Base::AddResourceObserver( Visual::ResourceObserver& observer)
+void Visual::Base::AddEventObserver( Visual::EventObserver& observer)
{
- mImpl->mResourceObserver = &observer;
+ mImpl->mEventObserver = &observer;
}
-void Visual::Base::RemoveResourceObserver( Visual::ResourceObserver& observer )
+void Visual::Base::RemoveEventObserver( Visual::EventObserver& observer )
{
- mImpl->mResourceObserver = NULL;
+ mImpl->mEventObserver = NULL;
}
void Visual::Base::ResourceReady(Toolkit::Visual::ResourceStatus resourceStatus)
{
mImpl->mResourceStatus = resourceStatus;
- if( mImpl->mResourceObserver )
+ if( mImpl->mEventObserver )
{
// observer is currently a control impl
- mImpl->mResourceObserver->ResourceReady( *this );
+ mImpl->mEventObserver->ResourceReady( *this );
}
}
}
namespace Visual
{
-class ResourceObserver;
+class EventObserver;
using FittingMode = DevelVisual::FittingMode;
Internal::TransitionData::Animator& animator );
/**
- * @brief Add an observer to watch for when the Visuals resources are loaded.
+ * @brief Add an observer to watch for when the Visuals have events to notify
* Currently only supports a single observer
- *
*/
- void AddResourceObserver( Visual::ResourceObserver& observer );
+ void AddEventObserver( Visual::EventObserver& observer );
/**
* @brief Remove an observer
*/
- void RemoveResourceObserver( Visual::ResourceObserver& observer );
+ void RemoveEventObserver( Visual::EventObserver& observer );
/**
* @brief Called when the visuals resources are loaded / ready
--- /dev/null
+#ifndef DALI_INTERNAL_TOOLKIT_VISUAL_EVENT_OBSERVER_H
+#define DALI_INTERNAL_TOOLKIT_VISUAL_EVENT_OBSERVER_H
+
+/*
+ * Copyright (c) 2018 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/object/property-value.h>
+
+namespace Dali
+{
+namespace Toolkit
+{
+namespace Internal
+{
+namespace Visual
+{
+
+class Base;
+
+/**
+ * Observer to be informed when visuals have events.
+ */
+class EventObserver
+{
+public:
+
+ /**
+ * Inform the observer of the object when a resource is ready.
+ * @param[in] object The connection owner
+ */
+ virtual void ResourceReady( Visual::Base& object ) = 0;
+
+ /**
+ * Inform the observer of the object when an event occurs.
+ * @param[in] object The connection owner
+ * @param[in] signalId The signal to emit. See Visual to find supported signals
+ */
+ virtual void NotifyVisualEvent( Visual::Base& object, Property::Index signalId ) = 0;
+
+protected:
+
+ /**
+ * constructor
+ */
+ EventObserver()
+ {
+ }
+
+ /**
+ * virtual destructor
+ */
+ virtual ~EventObserver()
+ {
+ }
+
+ // Undefined copy constructor.
+ EventObserver( const EventObserver& ) = delete;
+
+ // Undefined assignment operator.
+ EventObserver& operator=( const EventObserver& ) = delete;
+};
+
+} // Visual
+} // Internal
+} // Toolkit
+} // Dali
+
+#endif // DALI_INTERNAL_TOOLKIT_VISUAL_EVENT_OBSERVER_H
+++ /dev/null
-#ifndef DALI_INTERNAL_TOOLKIT_VISUAL_RESOURCE_OBSERVER_H
-#define DALI_INTERNAL_TOOLKIT_VISUAL_RESOURCE_OBSERVER_H
-
-/*
- * 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-
-namespace Dali
-{
-namespace Toolkit
-{
-namespace Internal
-{
-namespace Visual
-{
-
-class Base;
-
-
-/**
- * Observer to be informed when a visuals resources are ready.
- */
-class ResourceObserver
-{
- public:
-
- /**
- * Inform the observer of the object that it's connections have changed
- * @param[in] object The connection owner
- */
- virtual void ResourceReady( Visual::Base& object) = 0;
-
- protected:
-
- /**
- * constructor
- */
- ResourceObserver()
- {
- };
-
- /**
- * virtual destructor
- */
- virtual ~ResourceObserver()
- {
- };
-
- // Undefined copy constructor.
- ResourceObserver( const ResourceObserver& );
-
- // Undefined assignment operator.
- ResourceObserver& operator=( const ResourceObserver& );
-};
-} // Visual
-} // Internal
-} // Toolkit
-} // Dali
-
-#endif // DALI_INTERNAL_TOOLKIT_VISUAL_RESOURCE_OBSERVER_H
PLACEHOLDER_TEXT_COLOR,
/**
- * @DEPRECATED_1_1.37 Use SHADOW instead.
- * @brief The drop shadow offset 0 indicates no shadow.
- * @details Name "shadowOffset", type Property::VECTOR2.
- * @SINCE_1_0.0
- */
- SHADOW_OFFSET,
-
- /**
- * @DEPRECATED_1_1.37 Use SHADOW instead.
- * @brief The color of a drop shadow.
- * @details Name "shadowColor", type Property::VECTOR4.
- * @SINCE_1_0.0
- */
- SHADOW_COLOR,
-
- /**
* @brief The color to apply to the primary cursor.
* @details Name "primaryCursorColor", type Property::VECTOR4.
* @SINCE_1_0.0
UNUSED_PROPERTY_TEXT_COLOR,
/**
- * @DEPRECATED_1_1.37 Use SHADOW instead
- * @brief The drop shadow offset 0 indicates no shadow.
- * @details Name "shadowOffset", type Property::VECTOR2.
- */
- SHADOW_OFFSET,
-
- /**
- * @DEPRECATED_1_1.37 Use SHADOW instead
- * @brief The color of a drop shadow.
- * @details Name "shadowColor", type Property::VECTOR4
- */
- SHADOW_COLOR,
-
- /**
- * @DEPRECATED_1_1.37 Use UNDERLINE instead
- * @brief The underline enabled flag.
- * @details Name "underlineEnabled", type Property::BOOLEAN.
- */
- UNDERLINE_ENABLED,
-
- /**
- * @DEPRECATED_1_1.37 Use UNDERLINE instead
- * @brief The color of the underline.
- * @details Name "underlineColor", type Property::VECTOR4.
- */
- UNDERLINE_COLOR,
-
- /**
- * @DEPRECATED_1_1.37 Use UNDERLINE instead
- * @brief Overrides the underline height from font metrics.
- * @details Name "underlineHeight", type Property::FLOAT.
- */
- UNDERLINE_HEIGHT,
-
- /**
* @brief Whether the mark-up processing is enabled.
* @details Name "enableMarkup", type Property::BOOLEAN.
* @SINCE_1_0.0
/*
- * 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.
{
const unsigned int TOOLKIT_MAJOR_VERSION = 1;
-const unsigned int TOOLKIT_MINOR_VERSION = 3;
-const unsigned int TOOLKIT_MICRO_VERSION = 54;
+const unsigned int TOOLKIT_MINOR_VERSION = 4;
+const unsigned int TOOLKIT_MICRO_VERSION = 2;
const char * const TOOLKIT_BUILD_DATE = __DATE__ " " __TIME__;
#ifdef DEBUG_ENABLED
} // namespace Property
/**
- * @brief Visual Transfrom for the offset or size.
+ * @brief Visual Transform for the offset or size.
* @SINCE_1_2.60
*/
namespace Transform
{
/**
- * @brief Enumeration for the type of Transfrom Property.
+ * @brief Enumeration for the type of Transform Property.
* @SINCE_1_2.60
*/
enum Type
"autoScrollLoopCount":2,
"autoScrollGap":50,
"autoScrollSpeed":80,
- "ignoreSpacesAfterText":false,
- "matchSystemLanguageDirection":true
+ "ignoreSpacesAfterText":false
},
"TextLabelFontSize0":
"grabHandleImage" : "{DALI_STYLE_IMAGE_DIR}cursor_handler_drop_center.png",
"selectionHandleImageLeft" : {"filename":"{DALI_STYLE_IMAGE_DIR}selection_handle_drop_left.png" },
"selectionHandleImageRight": {"filename":"{DALI_STYLE_IMAGE_DIR}selection_handle_drop_right.png" },
- "enableSelection":false,
- "matchSystemLanguageDirection":true
+ "enableSelection":false
},
"TextFieldFontSize0":
"enableScrollBar":true,
"scrollBarShowDuration":0.8,
"scrollBarFadeDuration":0.5,
- "enableSelection":false,
- "matchSystemLanguageDirection":true
+ "enableSelection":false
},
"ProgressBar":
{
{ "mono", Dali::MONO},
{ "stereoHorizontal", Dali::STEREO_HORIZONTAL },
{ "stereoVertical", Dali::STEREO_VERTICAL },
- { "stereoInterlaced", Dali::STEREO_INTERLACED },
};
const unsigned int numberViewModes = sizeof( StereoModeTable ) / sizeof( StereoModeTable[0] );
Name: dali-toolkit
Summary: Dali 3D engine Toolkit
-Version: 1.3.54
+Version: 1.4.2
Release: 1
Group: System/Libraries
License: Apache-2.0 and BSD-3-Clause and MIT
{ "COLOR_MODE_USE_OWN_MULTIPLY_PARENT_ALPHA", USE_OWN_MULTIPLY_PARENT_ALPHA },
- { "POSITION_INHERITANCE_INHERIT_PARENT_POSITION", INHERIT_PARENT_POSITION },
- { "POSITION_INHERITANCE_USE_PARENT_POSITION", USE_PARENT_POSITION },
- { "POSITION_INHERITANCE_USE_PARENT_POSITION_PLUS_LOCAL_POSITION", USE_PARENT_POSITION_PLUS_LOCAL_POSITION },
- { "POSITION_INHERITANCE_DONT_INHERIT_POSITION", DONT_INHERIT_POSITION },
-
{ "DRAW_MODE_NORMAL", DrawMode::NORMAL },
{ "DRAW_MODE_OVERLAY_2D", DrawMode::OVERLAY_2D },