From a6f3e736b329550feb5a76dbda528e4c8b707c8b Mon Sep 17 00:00:00 2001 From: Kimmo Hoikka Date: Thu, 23 Jul 2015 13:42:26 +0100 Subject: [PATCH] Stop setting crazy Z value when SetSize(width,height) is used Change-Id: Ic428a491ec271748eac7930a3126c4f9fb5132e3 --- .../src/dali-internal/utc-Dali-Internal-Image-Culling.cpp | 14 +++++++------- automated-tests/src/dali/utc-Dali-Actor.cpp | 6 +++--- automated-tests/src/dali/utc-Dali-ImageActor.cpp | 4 ++-- dali/internal/event/actors/actor-impl.cpp | 12 ++++-------- dali/internal/event/actors/actor-impl.h | 10 +--------- dali/internal/event/actors/image-actor-impl.cpp | 3 ++- 6 files changed, 19 insertions(+), 30 deletions(-) diff --git a/automated-tests/src/dali-internal/utc-Dali-Internal-Image-Culling.cpp b/automated-tests/src/dali-internal/utc-Dali-Internal-Image-Culling.cpp index 7297524..178f981 100644 --- a/automated-tests/src/dali-internal/utc-Dali-Internal-Image-Culling.cpp +++ b/automated-tests/src/dali-internal/utc-Dali-Internal-Image-Culling.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2015 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. @@ -126,7 +126,7 @@ void TestImageInside( TestApplication& application, int width, int height ) imageActor.SetPosition(0.0f, 0.0f, 0.0f); Vector3 imageSize = imageActor.GetCurrentSize(); - DALI_TEST_EQUALS( imageSize, Vector3(width, height, std::min(width, height)), TEST_LOCATION); + DALI_TEST_EQUALS( imageSize, Vector3(width, height, 0), TEST_LOCATION); drawTrace.Reset(); imageActor.SetParentOrigin(ParentOrigin::TOP_LEFT); @@ -228,7 +228,7 @@ void SphereTestImageAtBoundary( TestApplication& application, int width, int hei ImageActor imageActor = CreateOnStageActor(application, image, width, height, true); Vector3 imageSize = imageActor.GetCurrentSize(); - DALI_TEST_EQUALS( imageSize, Vector3(width, height, std::min(width, height)), TEST_LOCATION); + DALI_TEST_EQUALS( imageSize, Vector3(width, height, 0), TEST_LOCATION); imageSize.z = 0.0f; float radius = imageSize.Length() * 0.5f; // Radius of bounding box @@ -279,7 +279,7 @@ void OBBTestImageAtBoundary( TestApplication& application, int width, int height ImageActor imageActor = CreateOnStageActor(application, image, width, height, true); Vector3 imageSize = imageActor.GetCurrentSize(); - DALI_TEST_EQUALS( imageSize, Vector3(width, height, std::min(width, height)), TEST_LOCATION); + DALI_TEST_EQUALS( imageSize, Vector3(width, height, 0), TEST_LOCATION); imageSize.z = 0.0f; tet_printf("Testing Stage Size: (%3.0f, %3.0f) image size:(%3.0f, %3.0f) \n", @@ -336,7 +336,7 @@ void SphereTestImageOutsideBoundary( TestApplication& application, int width, in ImageActor imageActor = CreateOnStageActor(application, image, width, height, true); Vector3 imageSize = imageActor.GetCurrentSize(); - DALI_TEST_EQUALS( imageSize, Vector3(width, height, std::min(width, height)), TEST_LOCATION); + DALI_TEST_EQUALS( imageSize, Vector3(width, height, 0), TEST_LOCATION); imageSize.z = 0.0f; float radius = imageSize.Length() * 0.5f; // Radius of bounding box @@ -380,7 +380,7 @@ void OBBTestImageOutsideBoundary( TestApplication& application, int width, int h ImageActor imageActor = CreateOnStageActor(application, image, width, height, true); Vector3 imageSize = imageActor.GetCurrentSize(); - DALI_TEST_EQUALS( imageSize, Vector3(width, height, std::min(width, height)), TEST_LOCATION); + DALI_TEST_EQUALS( imageSize, Vector3(width, height, 0), TEST_LOCATION); imageSize.z = 0.0f; tet_printf("Testing Stage Size: (%3.0f, %3.0f) image size:(%3.0f, %3.0f)\n", @@ -817,7 +817,7 @@ int UtcDaliImageCulling_Disable(void) ImageActor imageActor = CreateOnStageActor(application, image, width, height, true); Vector3 imageSize = imageActor.GetCurrentSize(); - DALI_TEST_EQUALS( imageSize, Vector3(width, height, std::min(width, height)), TEST_LOCATION); + DALI_TEST_EQUALS( imageSize, Vector3(width, height, 0), TEST_LOCATION); imageSize.z = 0.0f; diff --git a/automated-tests/src/dali/utc-Dali-Actor.cpp b/automated-tests/src/dali/utc-Dali-Actor.cpp index 3ba9bd9..d8cc27d 100644 --- a/automated-tests/src/dali/utc-Dali-Actor.cpp +++ b/automated-tests/src/dali/utc-Dali-Actor.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2015 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. @@ -663,7 +663,7 @@ int UtcDaliActorSetSize01(void) TestApplication application; Actor actor = Actor::New(); - Vector3 vector(100.0f, 100.0f, 100.0f); + Vector3 vector(100.0f, 100.0f, 0.0f); DALI_TEST_CHECK(vector != actor.GetCurrentSize()); @@ -703,7 +703,7 @@ int UtcDaliActorSetSize03(void) TestApplication application; Actor actor = Actor::New(); - Vector3 vector(100.0f, 100.0f, 100.0f); + Vector3 vector(100.0f, 100.0f, 0.0f); DALI_TEST_CHECK(vector != actor.GetCurrentSize()); diff --git a/automated-tests/src/dali/utc-Dali-ImageActor.cpp b/automated-tests/src/dali/utc-Dali-ImageActor.cpp index 6c44479..56525af 100644 --- a/automated-tests/src/dali/utc-Dali-ImageActor.cpp +++ b/automated-tests/src/dali/utc-Dali-ImageActor.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2015 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. @@ -198,7 +198,7 @@ int UtcDaliImageActorSetSize01(void) actor.SetShaderEffect( effect ); const float INVALID_SIZE = float(1u<<31); - Vector3 vector( INVALID_SIZE, INVALID_SIZE, INVALID_SIZE ); + Vector3 vector( INVALID_SIZE, INVALID_SIZE, 0.0f ); DALI_TEST_CHECK(vector != actor.GetCurrentSize()); diff --git a/dali/internal/event/actors/actor-impl.cpp b/dali/internal/event/actors/actor-impl.cpp index 2bd9b83..ea6f1d0 100644 --- a/dali/internal/event/actors/actor-impl.cpp +++ b/dali/internal/event/actors/actor-impl.cpp @@ -1077,23 +1077,19 @@ void Actor::SetSize( float width, float height, float depth ) void Actor::SetSize( const Vector2& size ) { - SetSize( Vector3( size.width, size.height, CalculateSizeZ( size ) ) ); + SetSize( Vector3( size.width, size.height, 0.f ) ); } void Actor::SetSizeInternal( const Vector2& size ) { - SetSizeInternal( Vector3( size.width, size.height, CalculateSizeZ( size ) ) ); -} - -float Actor::CalculateSizeZ( const Vector2& size ) const -{ - return std::min( size.width, size.height ); + SetSizeInternal( Vector3( size.width, size.height, 0.f ) ); } void Actor::SetSize( const Vector3& size ) { if( IsRelayoutEnabled() && !mRelayoutData->insideRelayout ) { + // TODO we cannot just ignore the given Z but that means rewrite the size negotiation!! SetPreferredSize( size.GetVectorXY() ); } else @@ -4041,7 +4037,7 @@ Vector2 Actor::GetPreferredSize() const { if ( mRelayoutData ) { - return mRelayoutData->preferredSize; + return Vector2( mRelayoutData->preferredSize ); } return GetDefaultPreferredSize(); diff --git a/dali/internal/event/actors/actor-impl.h b/dali/internal/event/actors/actor-impl.h index 6887d8b..6be3f77 100644 --- a/dali/internal/event/actors/actor-impl.h +++ b/dali/internal/event/actors/actor-impl.h @@ -1542,16 +1542,8 @@ protected: */ bool IsNodeConnected() const; - /** - * Calculate the size of the z dimension for a 2D size - * - * @param[in] size The 2D size (X, Y) to calculate Z from - * - * @return Return the Z dimension for this size - */ - float CalculateSizeZ( const Vector2& size ) const; - public: + // Default property extensions from Object /** diff --git a/dali/internal/event/actors/image-actor-impl.cpp b/dali/internal/event/actors/image-actor-impl.cpp index 5c6b028..601a699 100644 --- a/dali/internal/event/actors/image-actor-impl.cpp +++ b/dali/internal/event/actors/image-actor-impl.cpp @@ -104,6 +104,7 @@ ImageActorPtr ImageActor::New() void ImageActor::OnInitialize() { + // TODO: Remove this, at the moment its needed for size negotiation to work SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS ); } @@ -208,7 +209,7 @@ ImageActor::~ImageActor() Vector3 ImageActor::GetNaturalSize() const { Vector2 naturalSize( CalculateNaturalSize() ); - return Vector3( naturalSize.width, naturalSize.height, CalculateSizeZ( naturalSize ) ); + return Vector3( naturalSize.width, naturalSize.height, 0.f ); } Vector2 ImageActor::CalculateNaturalSize() const -- 2.7.4