Previously, this reset any values that were set by the application/stylesheet.
Change-Id: Ib91f29fefc927a804b03b6d1b0b458d55c100f5d
#include <dali.h>
#include <dali-toolkit/dali-toolkit.h>
+#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
+#include <dali-toolkit/devel-api/align-enums.h>
+
#include "dummy-control.h"
using namespace Dali;
END_TEST;
}
+
+int UtcDaliControlSetTransformSize(void)
+{
+ ToolkitTestApplication application;
+ Control control = Control::New();
+
+ Property::Map transformMap;
+ transformMap.Add( DevelVisual::Transform::Property::OFFSET, Vector2( 10, 10 ) )
+ .Add( DevelVisual::Transform::Property::ANCHOR_POINT, Align::BOTTOM_END )
+ .Add( DevelVisual::Transform::Property::ORIGIN, Align::BOTTOM_END )
+ .Add( DevelVisual::Transform::Property::SIZE, Vector2( 10, 20 ) );
+
+ control.SetProperty( Control::Property::BACKGROUND, Property::Map().Add( Visual::Property::TYPE, Visual::COLOR )
+ .Add( DevelVisual::Property::TRANSFORM, transformMap ) );
+
+ tet_infoline( "Test to ensure that the control background transform does not get overwritten when adding to the stage" );
+
+ Stage::GetCurrent().Add( control );
+
+ application.SendNotification();
+ application.Render();
+
+ // Ensure the transform property still matches what we set
+ Property::Value value = control.GetProperty( Control::Property::BACKGROUND );
+ Property::Map* map = value.GetMap();
+ DALI_TEST_CHECK( map );
+ Property::Value* transformValue = map->Find( DevelVisual::Property::TRANSFORM );
+ DALI_TEST_CHECK( transformValue );
+
+ Property::Map* retMap = transformValue->GetMap();
+ DALI_TEST_CHECK( retMap );
+ DALI_TEST_EQUALS( retMap->Find( DevelVisual::Transform::Property::OFFSET )->Get< Vector2 >(), Vector2( 10, 10 ), TEST_LOCATION );
+ DALI_TEST_EQUALS( retMap->Find( DevelVisual::Transform::Property::ANCHOR_POINT )->Get< int >(), (int)Align::BOTTOM_END, TEST_LOCATION );
+ DALI_TEST_EQUALS( retMap->Find( DevelVisual::Transform::Property::ORIGIN )->Get< int >(), (int)Align::BOTTOM_END, TEST_LOCATION );
+ DALI_TEST_EQUALS( retMap->Find( DevelVisual::Transform::Property::SIZE )->Get< Vector2 >(), Vector2( 10, 20 ), TEST_LOCATION );
+
+ END_TEST;
+}
/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * 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.
//Set a new transform
transform.Clear();
+ transform = DefaultTransform();
transform.Insert( DevelVisual::Transform::Property::OFFSET, Vector2(20.0f, 20.0f) );
transform.Insert( DevelVisual::Transform::Property::SIZE, Vector2(100.0f, 100.0f) );
transform.Insert( DevelVisual::Transform::Property::OFFSET_SIZE_MODE, Vector4(0.0f, 0.0f, 1.0f,1.0f) );
Renderer renderer = dummyControl.GetRendererAt(0u);
Property::Index index = renderer.GetPropertyIndex("size");
- tet_infoline( "Test that the TextVisual overrides anything set by developer" );
- DALI_TEST_EQUALS( renderer.GetProperty<Vector2>(index), Vector2( 1.0, 1.0 ), 0.001f, TEST_LOCATION );
+ tet_infoline( "Test that the TextVisual has NOT overridden what was set by developer" );
+ DALI_TEST_EQUALS( renderer.GetProperty<Vector2>(index), Vector2( 0.5f, 0.5f ), 0.001f, TEST_LOCATION );
END_TEST;
}
void Visual::Base::SetTransformAndSize( const Property::Map& transform, Size controlSize )
{
mImpl->mControlSize = controlSize;
- mImpl->mTransform.SetPropertyMap( transform );
+ mImpl->mTransform.UpdatePropertyMap( transform );
#if defined(DEBUG_ENABLED)
std::ostringstream oss;
return visualHandle;
}
-void SetDefaultTransform( Property::Map& propertyMap )
-{
- propertyMap.Clear();
- propertyMap
- .Add( Toolkit::DevelVisual::Transform::Property::OFFSET, Vector2(0.0f, 0.0f) )
- .Add( Toolkit::DevelVisual::Transform::Property::SIZE, Vector2(1.0f, 1.0f) )
- .Add( Toolkit::DevelVisual::Transform::Property::ORIGIN, Toolkit::Align::CENTER )
- .Add( Toolkit::DevelVisual::Transform::Property::ANCHOR_POINT, Toolkit::Align::CENTER )
- .Add( Toolkit::DevelVisual::Transform::Property::OFFSET_SIZE_MODE, Vector4::ZERO );
-}
-
/**
* Creates control through type registry
*/
if( visual )
{
Vector2 size( targetSize );
- Property::Map transformMap;
- SetDefaultTransform( transformMap );
- visual.SetTransformAndSize( transformMap, size );
+ visual.SetTransformAndSize( Property::Map(), size ); // Send an empty map as we do not want to modify the visual's set transform
}
}
Toolkit::Visual::Base visual = GetVisual( Toolkit::Control::Property::BACKGROUND );
if( visual )
{
- Vector2 controlSize( size );
- Property::Map transformMap;
- SetDefaultTransform( transformMap );
- visual.SetTransformAndSize( transformMap, controlSize );
+ visual.SetTransformAndSize( Property::Map(), size ); // Send an empty map as we do not want to modify the visual's set transform
}
}