From 17f28cc04cbb2708a29a6ef7a353ce15fc434b2d Mon Sep 17 00:00:00 2001 From: Radoslaw Cybulski Date: Wed, 30 May 2018 15:53:11 +0200 Subject: [PATCH] [ATSPI] Add CalculateScreenExtents function Adds (real, pixel based) screen position, calculated in render function. Change-Id: Ia34490c59643d0ef3b7f64ae05da51547921f615 --- automated-tests/src/dali/utc-Dali-Actor.cpp | 23 ++++++++++++++++++++++ .../src/dali/utc-Dali-PropertyValue.cpp | 15 ++++++++++++++ dali/devel-api/actors/actor-devel.cpp | 5 +++++ dali/devel-api/actors/actor-devel.h | 9 +++++++++ dali/internal/event/actors/actor-impl.cpp | 9 +++++++++ dali/internal/event/actors/actor-impl.h | 7 +++++++ .../update/gestures/scene-graph-pan-gesture.cpp | 4 ++-- 7 files changed, 70 insertions(+), 2 deletions(-) diff --git a/automated-tests/src/dali/utc-Dali-Actor.cpp b/automated-tests/src/dali/utc-Dali-Actor.cpp index a208e2e..12cbecd 100644 --- a/automated-tests/src/dali/utc-Dali-Actor.cpp +++ b/automated-tests/src/dali/utc-Dali-Actor.cpp @@ -1269,6 +1269,29 @@ int UtcDaliActorGetCurrentSizeImmediate(void) END_TEST; } +int UtcDaliActorCalculateScreenExtents(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + actor.SetPosition(Vector3(2.0f, 2.0f, 16.0f)); + actor.SetSize(Vector3{ 1.0f, 1.0f, 1.0f }); + + application.SendNotification(); + application.Render(); + + auto expectedExtent = Rect<>{ -0.5f, -0.5f, 1.0f, 1.0f }; + auto actualExtent = DevelActor::CalculateScreenExtents( actor ); + DALI_TEST_EQUALS( expectedExtent.x, actualExtent.x, Math::MACHINE_EPSILON_10000, TEST_LOCATION ); + DALI_TEST_EQUALS( expectedExtent.y, actualExtent.y, Math::MACHINE_EPSILON_10000, TEST_LOCATION ); + DALI_TEST_EQUALS( expectedExtent.width, actualExtent.width, Math::MACHINE_EPSILON_10000, TEST_LOCATION ); + DALI_TEST_EQUALS( expectedExtent.height, actualExtent.height, Math::MACHINE_EPSILON_10000, TEST_LOCATION ); + + Stage::GetCurrent().Remove( actor ); + END_TEST; +} + // SetPosition(float x, float y) int UtcDaliActorSetPosition01(void) { diff --git a/automated-tests/src/dali/utc-Dali-PropertyValue.cpp b/automated-tests/src/dali/utc-Dali-PropertyValue.cpp index 3fd0fc6..712f60f 100644 --- a/automated-tests/src/dali/utc-Dali-PropertyValue.cpp +++ b/automated-tests/src/dali/utc-Dali-PropertyValue.cpp @@ -1247,6 +1247,21 @@ int UtcDaliPropertyValueGetExtentsP(void) END_TEST; } +int UtcDaliPropertyValueEnum(void) +{ + enum class E { zero, e }; + Property::Value value( E::e ); + DALI_TEST_EQUALS( static_cast(E::e), static_cast(value.Get()), TEST_LOCATION ); + DALI_TEST_EQUALS( static_cast(E::e), value.Get(), TEST_LOCATION ); + E result; + DALI_TEST_EQUALS( true, value.Get( result ), TEST_LOCATION ); + DALI_TEST_EQUALS( static_cast(E::e), static_cast(result), TEST_LOCATION ); + int result2; + DALI_TEST_EQUALS( true, value.Get( result2 ), TEST_LOCATION ); + DALI_TEST_EQUALS( static_cast(E::e), result2, TEST_LOCATION ); + END_TEST; +} + int UtcDaliPropertyValueOutputStream(void) { TestApplication application; diff --git a/dali/devel-api/actors/actor-devel.cpp b/dali/devel-api/actors/actor-devel.cpp index 9e89f7c..3f3b9ab 100644 --- a/dali/devel-api/actors/actor-devel.cpp +++ b/dali/devel-api/actors/actor-devel.cpp @@ -25,6 +25,11 @@ namespace Dali namespace DevelActor { +Rect<> CalculateScreenExtents( Actor actor ) +{ + return GetImplementation( actor ).CalculateScreenExtents(); +} + VisibilityChangedSignalType& VisibilityChangedSignal( Actor actor ) { return GetImplementation( actor ).VisibilityChangedSignal(); diff --git a/dali/devel-api/actors/actor-devel.h b/dali/devel-api/actors/actor-devel.h index f5fe5d3..ff521de 100644 --- a/dali/devel-api/actors/actor-devel.h +++ b/dali/devel-api/actors/actor-devel.h @@ -20,6 +20,7 @@ // INTERNAL INCLUDES #include +#include namespace Dali { @@ -160,6 +161,14 @@ typedef Signal< void ( Actor, bool, VisibilityChange::Type ) > VisibilityChanged */ DALI_CORE_API VisibilityChangedSignalType& VisibilityChangedSignal( Actor actor ); +/** + * Calculates screen position and size. + * + * @return pair of two values, position of top-left corner on screen and size respectively. + */ +DALI_CORE_API Rect<> CalculateScreenExtents( Actor actor ); + + typedef Signal< void (Actor) > ChildChangedSignalType; ///< Called when the actor has a child added or removed diff --git a/dali/internal/event/actors/actor-impl.cpp b/dali/internal/event/actors/actor-impl.cpp index 324ff45..876182f 100644 --- a/dali/internal/event/actors/actor-impl.cpp +++ b/dali/internal/event/actors/actor-impl.cpp @@ -3472,6 +3472,15 @@ bool Actor::DoAction( BaseObject* object, const std::string& actionName, const P return done; } +Rect<> Actor::CalculateScreenExtents( ) const +{ + auto screenPosition = GetCurrentScreenPosition(); + Vector3 size = GetCurrentSize() * GetCurrentWorldScale(); + Vector3 anchorPointOffSet = size * ( mPositionUsesAnchorPoint ? GetCurrentAnchorPoint() : AnchorPoint::TOP_LEFT ); + Vector2 position = Vector2( screenPosition.x - anchorPointOffSet.x, screenPosition.y - anchorPointOffSet.y ); + return { position.x, position.y, size.x, size.y }; +} + bool Actor::GetCachedPropertyValue( Property::Index index, Property::Value& value ) const { bool valueSet = true; diff --git a/dali/internal/event/actors/actor-impl.h b/dali/internal/event/actors/actor-impl.h index 9a27d81..53fe06a 100755 --- a/dali/internal/event/actors/actor-impl.h +++ b/dali/internal/event/actors/actor-impl.h @@ -250,6 +250,13 @@ public: } /** + * Calculates screen position and size. + * + * @return pair of two values, position of top-left corner on screen and size respectively. + */ + Rect<> CalculateScreenExtents( ) const; + + /** * Sets the size of an actor. * This does not interfere with the actors scale factor. * @param [in] width The new width. diff --git a/dali/internal/update/gestures/scene-graph-pan-gesture.cpp b/dali/internal/update/gestures/scene-graph-pan-gesture.cpp index 4941465..217b78a 100644 --- a/dali/internal/update/gestures/scene-graph-pan-gesture.cpp +++ b/dali/internal/update/gestures/scene-graph-pan-gesture.cpp @@ -551,7 +551,7 @@ bool PanGesture::UpdateProperties( unsigned int lastVSyncTime, unsigned int next mLastGesture = frameGesture; mLastUnmodifiedGesture = unmodifiedGesture; - mInGesture &= ~frameInfo.justFinished; + mInGesture = mInGesture && !frameInfo.justFinished; if( mProfiling && frameInfo.justFinished ) { mProfiling->PrintData(); @@ -1281,7 +1281,7 @@ bool PanGesture::NewAlgorithm( unsigned int lastVSyncTime, unsigned int nextVSyn } } - mInGesture &= ~justFinished; + mInGesture = mInGesture && !justFinished; return performUpdate; } -- 2.7.4