From 0cd1506a8e484fc79b5cc157232479e216885362 Mon Sep 17 00:00:00 2001 From: Kingsley Stephens Date: Tue, 14 Apr 2015 13:59:24 +0100 Subject: [PATCH] Size negotiation patch 4: Remove SetRelayoutEnabled Change-Id: I051397fc53fe326ee377c8d36ac0b623201a4ea2 --- .../utc-Dali-Internal-RelayoutController.cpp | 8 +--- automated-tests/src/dali/utc-Dali-Actor.cpp | 23 ---------- automated-tests/src/dali/utc-Dali-CustomActor.cpp | 6 +-- .../src/dali/utc-Dali-HitTestAlgorithm.cpp | 2 - .../src/dali/utc-Dali-HoverProcessing.cpp | 2 - automated-tests/src/dali/utc-Dali-ImageActor.cpp | 42 +---------------- .../src/dali/utc-Dali-TouchProcessing.cpp | 2 - automated-tests/src/dali/utc-Dali-TypeRegistry.cpp | 2 +- dali/internal/event/actors/actor-impl.cpp | 30 +++---------- dali/internal/event/actors/actor-impl.h | 23 ++++------ .../event/actors/custom-actor-internal.cpp | 1 + dali/internal/event/actors/image-actor-impl.cpp | 52 +++------------------- dali/internal/event/actors/image-actor-impl.h | 25 ----------- dali/internal/event/actors/layer-impl.cpp | 2 - dali/internal/event/common/stage-impl.cpp | 1 - dali/internal/event/common/system-overlay-impl.cpp | 1 - .../size-negotiation/relayout-controller-impl.cpp | 4 +- dali/public-api/actors/actor.cpp | 15 ------- dali/public-api/actors/actor.h | 24 ---------- dali/public-api/actors/custom-actor-impl.cpp | 21 +++------ dali/public-api/actors/custom-actor-impl.h | 41 ++++++++++------- dali/public-api/actors/image-actor.cpp | 5 --- dali/public-api/actors/image-actor.h | 14 ------ 23 files changed, 59 insertions(+), 287 deletions(-) diff --git a/automated-tests/src/dali-internal/utc-Dali-Internal-RelayoutController.cpp b/automated-tests/src/dali-internal/utc-Dali-Internal-RelayoutController.cpp index 6cb2657..a610359 100644 --- a/automated-tests/src/dali-internal/utc-Dali-Internal-RelayoutController.cpp +++ b/automated-tests/src/dali-internal/utc-Dali-Internal-RelayoutController.cpp @@ -75,8 +75,6 @@ Actor NewRelayoutActor( bool expectedWidthDirty, bool expectedHeightDirty, Resiz { Actor actor = Actor::New(); - actor.SetRelayoutEnabled( true ); - actor.SetResizePolicy( widthPolicy, Dimension::WIDTH ); actor.SetResizePolicy( heightPolicy, Dimension::HEIGHT ); @@ -140,7 +138,6 @@ int UtcDaliRelayoutControllerRequestRelayout(void) TestApplication application; Actor actor = Actor::New(); - actor.SetRelayoutEnabled( true ); Internal::Actor& actorImpl = GetImplementation( actor ); @@ -148,7 +145,7 @@ int UtcDaliRelayoutControllerRequestRelayout(void) Internal::RelayoutController* controller = Internal::RelayoutController::Get(); controller->RequestRelayout( actor ); - DALI_TEST_CHECK( actorImpl.IsLayoutDirty() ); + DALI_TEST_CHECK( !actorImpl.IsLayoutDirty() ); END_TEST; } @@ -470,7 +467,6 @@ int UtcDaliRelayoutControllerRequestRelayoutTree(void) TestApplication application; Actor actor = Actor::New(); - actor.SetRelayoutEnabled( true ); Internal::Actor& actorImpl = GetImplementation( actor ); @@ -483,7 +479,7 @@ int UtcDaliRelayoutControllerRequestRelayoutTree(void) // Request default enable (false) controller->RequestRelayoutTree( actor ); - DALI_TEST_CHECK( actorImpl.IsLayoutDirty() ); + DALI_TEST_CHECK( !actorImpl.IsLayoutDirty() ); END_TEST; } diff --git a/automated-tests/src/dali/utc-Dali-Actor.cpp b/automated-tests/src/dali/utc-Dali-Actor.cpp index fcf2c03..ac6fcb6 100644 --- a/automated-tests/src/dali/utc-Dali-Actor.cpp +++ b/automated-tests/src/dali/utc-Dali-Actor.cpp @@ -2627,7 +2627,6 @@ const PropertyStringIndex PROPERTY_TABLE[] = { "position-inheritance", Actor::Property::POSITION_INHERITANCE, Property::STRING }, { "draw-mode", Actor::Property::DRAW_MODE, Property::STRING }, { "size-mode-factor", Actor::Property::SIZE_MODE_FACTOR, Property::VECTOR3 }, - { "relayout-enabled", Actor::Property::RELAYOUT_ENABLED, Property::BOOLEAN }, { "width-resize-policy", Actor::Property::WIDTH_RESIZE_POLICY, Property::STRING }, { "height-resize-policy", Actor::Property::HEIGHT_RESIZE_POLICY, Property::STRING }, { "size-scale-policy", Actor::Property::SIZE_SCALE_POLICY, Property::STRING }, @@ -2656,28 +2655,6 @@ int UtcDaliActorProperties(void) END_TEST; } -int UtcDaliRelayoutProperties_RelayoutEnabled(void) -{ - TestApplication app; - - Actor actor = Actor::New(); - - // Defaults - DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::RELAYOUT_ENABLED ).Get< bool >(), false, TEST_LOCATION ); - - // Set relayout disabled - actor.SetProperty( Actor::Property::RELAYOUT_ENABLED, false ); - - DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::RELAYOUT_ENABLED ).Get< bool >(), false, TEST_LOCATION ); - - // Set relayout enabled - actor.SetProperty( Actor::Property::RELAYOUT_ENABLED, true ); - - DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::RELAYOUT_ENABLED ).Get< bool >(), true, TEST_LOCATION ); - - END_TEST; -} - int UtcDaliRelayoutProperties_ResizePolicies(void) { TestApplication app; diff --git a/automated-tests/src/dali/utc-Dali-CustomActor.cpp b/automated-tests/src/dali/utc-Dali-CustomActor.cpp index 87dd3ca..dbe3a12 100644 --- a/automated-tests/src/dali/utc-Dali-CustomActor.cpp +++ b/automated-tests/src/dali/utc-Dali-CustomActor.cpp @@ -56,13 +56,11 @@ struct TestCustomActor : public CustomActorImpl * Constructor */ TestCustomActor() - : CustomActorImpl( true ), // requires touch + : CustomActorImpl( ActorFlags( REQUIRES_TOUCH_EVENTS | REQUIRES_MOUSE_WHEEL_EVENTS | REQUIRES_HOVER_EVENTS | DISABLE_SIZE_NEGOTIATION ) ), mDaliProperty( Property::INVALID_INDEX ), mSizeSet( Vector3::ZERO ), mTargetSize( Vector3::ZERO ) { - SetRequiresMouseWheelEvents(true); - SetRequiresHoverEvents(true); } /** @@ -451,7 +449,7 @@ public: * Constructor */ SimpleTestCustomActor() - : CustomActorImpl( true ) // requires touch + : CustomActorImpl( ActorFlags( REQUIRES_TOUCH_EVENTS | DISABLE_SIZE_NEGOTIATION ) ) { } diff --git a/automated-tests/src/dali/utc-Dali-HitTestAlgorithm.cpp b/automated-tests/src/dali/utc-Dali-HitTestAlgorithm.cpp index 19a3662..e645849 100644 --- a/automated-tests/src/dali/utc-Dali-HitTestAlgorithm.cpp +++ b/automated-tests/src/dali/utc-Dali-HitTestAlgorithm.cpp @@ -381,7 +381,6 @@ int UtcDaliHitTestAlgorithmStencil(void) Actor stencil = ImageActor::New(Dali::BufferImage::WHITE() ); stencil.SetAnchorPoint( AnchorPoint::TOP_LEFT ); stencil.SetParentOrigin( ParentOrigin::TOP_LEFT ); - stencil.SetRelayoutEnabled( false ); stencil.SetSize( 50.0f, 50.0f ); stencil.SetDrawMode( DrawMode::STENCIL ); stencil.SetName( "stencil" ); @@ -389,7 +388,6 @@ int UtcDaliHitTestAlgorithmStencil(void) // Create a renderable actor and add that to the layer Actor layerHitActor = ImageActor::New(); - layerHitActor.SetRelayoutEnabled( false ); layerHitActor.SetSize( 100.0f, 100.0f ); layerHitActor.SetAnchorPoint( AnchorPoint::TOP_LEFT ); layerHitActor.SetParentOrigin( ParentOrigin::TOP_LEFT ); diff --git a/automated-tests/src/dali/utc-Dali-HoverProcessing.cpp b/automated-tests/src/dali/utc-Dali-HoverProcessing.cpp index 13388f6..deac90f 100644 --- a/automated-tests/src/dali/utc-Dali-HoverProcessing.cpp +++ b/automated-tests/src/dali/utc-Dali-HoverProcessing.cpp @@ -1001,13 +1001,11 @@ int UtcDaliHoverMultipleRenderableActors(void) Vector2 stageSize ( stage.GetSize() ); Actor parent = ImageActor::New(); - parent.SetRelayoutEnabled( false ); parent.SetSize( 100.0f, 100.0f ); parent.SetAnchorPoint(AnchorPoint::TOP_LEFT); stage.Add(parent); Actor actor = ImageActor::New(); - actor.SetRelayoutEnabled( false ); actor.SetSize( 100.0f, 100.0f ); actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); parent.Add(actor); diff --git a/automated-tests/src/dali/utc-Dali-ImageActor.cpp b/automated-tests/src/dali/utc-Dali-ImageActor.cpp index 47b0efc..93530b0 100644 --- a/automated-tests/src/dali/utc-Dali-ImageActor.cpp +++ b/automated-tests/src/dali/utc-Dali-ImageActor.cpp @@ -181,7 +181,6 @@ int UtcDaliImageActorSetSize01(void) BufferImage img = BufferImage::New( 1,1 ); ImageActor actor = ImageActor::New( img ); - actor.SetRelayoutEnabled( false ); ShaderEffect effect = ShaderEffect::New( " ", " ", GEOMETRY_TYPE_IMAGE, ShaderEffect::HINT_GRID ); actor.SetShaderEffect( effect ); @@ -210,7 +209,6 @@ int UtcDaliImageActorGetCurrentSize01(void) Vector2 initialImageSize(100, 50); BufferImage image = BufferImage::New( initialImageSize.width, initialImageSize.height ); ImageActor actor = ImageActor::New( image ); - actor.SetRelayoutEnabled( false ); Stage::GetCurrent().Add(actor); application.SendNotification(); @@ -238,11 +236,6 @@ int UtcDaliImageActorGetCurrentSize01(void) // natural size is not used as setsize is called DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), size, TEST_LOCATION ); - actor.SetToNaturalSize(); - application.SendNotification(); - application.Render(9); - DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), Vector2( area.width, area.height ), TEST_LOCATION ); - END_TEST; } @@ -258,7 +251,6 @@ int UtcDaliImageActorGetCurrentSize02(void) Image image = ResourceImage::New("image.jpg"); ImageActor actor = ImageActor::New( image ); - actor.SetRelayoutEnabled( false ); Stage::GetCurrent().Add(actor); application.SendNotification(); // Flush update messages @@ -290,10 +282,6 @@ int UtcDaliImageActorGetCurrentSize02(void) application.Render(); DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), size, TEST_LOCATION ); - actor.SetToNaturalSize(); - application.SendNotification(); - application.Render(); - DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), initialImageSize, TEST_LOCATION ); END_TEST; } @@ -311,7 +299,6 @@ int UtcDaliImageActorGetCurrentSize03(void) attrs.SetSize( requestedSize.width, requestedSize.height ); Image image = ResourceImage::New("image.jpg", attrs); ImageActor actor = ImageActor::New( image ); - actor.SetRelayoutEnabled( false ); Stage::GetCurrent().Add(actor); application.SendNotification(); // Flush update messages @@ -335,19 +322,6 @@ int UtcDaliImageActorGetCurrentSize03(void) DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), requestedSize, TEST_LOCATION ); - // Test that setting a size on the actor can be 'undone' with SetNaturalSize() - Vector2 size(200.0f, 200.0f); - actor.SetSize(size); - - // flush the queue and render once - application.SendNotification(); - application.Render(); - DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), size, TEST_LOCATION ); - - actor.SetToNaturalSize(); - application.SendNotification(); - application.Render(); - DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), requestedSize, TEST_LOCATION ); END_TEST; } @@ -365,7 +339,6 @@ int UtcDaliImageActorGetCurrentSize04(void) attrs.SetSize( requestedSize.width, requestedSize.height ); Image image = ResourceImage::New("image.jpg", attrs); ImageActor actor = ImageActor::New( image ); - actor.SetRelayoutEnabled( false ); Stage::GetCurrent().Add(actor); application.SendNotification(); // Flush update messages @@ -428,11 +401,6 @@ int UtcDaliImageActorGetCurrentSize04(void) // Ensure the actor size is kept DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), size, TEST_LOCATION ); - actor.SetToNaturalSize(); - application.SendNotification(); - application.Render(); - // Ensure the actor size gets the new image's natural size - DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), request2Size, TEST_LOCATION ); END_TEST; } @@ -450,7 +418,6 @@ int UtcDaliImageActorGetCurrentSize05(void) attrs.SetSize( requestedSize.width, requestedSize.height ); Image image = ResourceImage::New("image.jpg", attrs); ImageActor actor = ImageActor::New( image ); - actor.SetRelayoutEnabled( false ); Stage::GetCurrent().Add(actor); application.SendNotification(); // Flush update messages @@ -530,7 +497,6 @@ int UtcDaliImageActorNaturalPixelAreaSize01(void) attrs.SetSize( requestedSize.width, requestedSize.height ); Image image = ResourceImage::New("image.jpg", attrs); ImageActor actor = ImageActor::New( image ); - actor.SetRelayoutEnabled( false ); Stage::GetCurrent().Add(actor); application.SendNotification(); // Flush update messages @@ -594,7 +560,6 @@ int UtcDaliImageActorNaturalPixelAreaSize02(void) attrs.SetSize( requestedSize.width, requestedSize.height ); Image image = ResourceImage::New("image.jpg", attrs); ImageActor actor = ImageActor::New( image ); - actor.SetRelayoutEnabled( false ); Stage::GetCurrent().Add(actor); application.SendNotification(); // Flush update messages @@ -641,13 +606,8 @@ int UtcDaliImageActorNaturalPixelAreaSize02(void) application.Render(); // Process LoadComplete DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), Vector2(100, 100), TEST_LOCATION ); - // Use natural size - expect actor to change to pixel area - actor.SetToNaturalSize(); - application.SendNotification(); // Process event messages - application.Render(); // Process LoadComplete - DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), Vector2(40, 40), TEST_LOCATION ); - // Clearing pixel area should change actor size to image size + actor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS ); actor.ClearPixelArea(); application.SendNotification(); // Process event messages application.Render(); // Process LoadComplete diff --git a/automated-tests/src/dali/utc-Dali-TouchProcessing.cpp b/automated-tests/src/dali/utc-Dali-TouchProcessing.cpp index d31c7bb..1d46199 100644 --- a/automated-tests/src/dali/utc-Dali-TouchProcessing.cpp +++ b/automated-tests/src/dali/utc-Dali-TouchProcessing.cpp @@ -1001,13 +1001,11 @@ int UtcDaliTouchMultipleRenderableActors(void) Vector2 stageSize ( stage.GetSize() ); Actor parent = ImageActor::New(); - parent.SetRelayoutEnabled( false ); parent.SetSize(100.0f, 100.0f); parent.SetAnchorPoint(AnchorPoint::TOP_LEFT); stage.Add(parent); Actor actor = ImageActor::New(); - actor.SetRelayoutEnabled( false ); actor.SetSize(100.0f, 100.0f); actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); parent.Add(actor); diff --git a/automated-tests/src/dali/utc-Dali-TypeRegistry.cpp b/automated-tests/src/dali/utc-Dali-TypeRegistry.cpp index 78fbb04..f3d2cb4 100644 --- a/automated-tests/src/dali/utc-Dali-TypeRegistry.cpp +++ b/automated-tests/src/dali/utc-Dali-TypeRegistry.cpp @@ -191,7 +191,7 @@ struct MyTestCustomActor : public CustomActorImpl typedef Signal< void ()> SignalType; typedef Signal< void (float)> SignalTypeFloat; - MyTestCustomActor() : CustomActorImpl( true ) // requires touch + MyTestCustomActor() : CustomActorImpl( ActorFlags( REQUIRES_TOUCH_EVENTS ) ) { } virtual ~MyTestCustomActor() diff --git a/dali/internal/event/actors/actor-impl.cpp b/dali/internal/event/actors/actor-impl.cpp index edbc52d..e1bdc83 100644 --- a/dali/internal/event/actors/actor-impl.cpp +++ b/dali/internal/event/actors/actor-impl.cpp @@ -226,7 +226,6 @@ DALI_PROPERTY( "color-mode", STRING, true, false, false, Dali::Actor::Property:: DALI_PROPERTY( "position-inheritance", STRING, true, false, false, Dali::Actor::Property::POSITION_INHERITANCE ) DALI_PROPERTY( "draw-mode", STRING, true, false, false, Dali::Actor::Property::DRAW_MODE ) DALI_PROPERTY( "size-mode-factor", VECTOR3, true, false, false, Dali::Actor::Property::SIZE_MODE_FACTOR ) -DALI_PROPERTY( "relayout-enabled", BOOLEAN, true, false, false, Dali::Actor::Property::RELAYOUT_ENABLED ) DALI_PROPERTY( "width-resize-policy", STRING, true, false, false, Dali::Actor::Property::WIDTH_RESIZE_POLICY ) DALI_PROPERTY( "height-resize-policy", STRING, true, false, false, Dali::Actor::Property::HEIGHT_RESIZE_POLICY ) DALI_PROPERTY( "size-scale-policy", STRING, true, false, false, Dali::Actor::Property::SIZE_SCALE_POLICY ) @@ -1318,6 +1317,9 @@ void Actor::SetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimensio } } + // If calling SetResizePolicy, assume we want relayout enabled + SetRelayoutEnabled( true ); + OnSetResizePolicy( policy, dimension ); // Trigger relayout on this control @@ -2857,12 +2859,6 @@ void Actor::SetDefaultProperty( Property::Index index, const Property::Value& pr break; } - case Dali::Actor::Property::RELAYOUT_ENABLED: - { - SetRelayoutEnabled( property.Get< bool >() ); - break; - } - case Dali::Actor::Property::WIDTH_RESIZE_POLICY: { SetResizePolicy( Scripting::GetEnumeration< ResizePolicy::Type >( property.Get< std::string >().c_str(), ResizePolicy::TypeTable, ResizePolicy::TypeTableCount ), Dimension::WIDTH ); @@ -3315,12 +3311,6 @@ Property::Value Actor::GetDefaultProperty( Property::Index index ) const break; } - case Dali::Actor::Property::RELAYOUT_ENABLED: - { - value = IsRelayoutEnabled(); - break; - } - case Dali::Actor::Property::WIDTH_RESIZE_POLICY: { value = Scripting::GetLinearEnumerationName< ResizePolicy::Type >( GetResizePolicy( Dimension::WIDTH ), ResizePolicy::TypeTable, ResizePolicy::TypeTableCount ); @@ -4152,7 +4142,7 @@ float Actor::CalculateSize( Dimension::Type dimension, const Vector2& maximumSiz return 0.0f; // Default } -float Actor::ConstrainDimension( float size, Dimension::Type dimension ) +float Actor::ClampDimension( float size, Dimension::Type dimension ) { const float minSize = GetMinimumSize( dimension ); const float maxSize = GetMaximumSize( dimension ); @@ -4220,7 +4210,7 @@ void Actor::NegotiateDimension( Dimension::Type dimension, const Vector2& alloca OnCalculateRelayoutSize( dimension ); // All dependencies checked, calculate the size and set negotiated flag - const float newSize = ConstrainDimension( CalculateSize( dimension, allocatedSize ), dimension ); + const float newSize = ClampDimension( CalculateSize( dimension, allocatedSize ), dimension ); SetNegotiatedDimension( newSize, dimension ); SetLayoutNegotiated( true, dimension ); @@ -4380,16 +4370,6 @@ void Actor::RelayoutRequest( Dimension::Type dimension ) } } -void Actor::RelayoutRequestTree() -{ - Internal::RelayoutController* relayoutController = Internal::RelayoutController::Get(); - if( relayoutController ) - { - Dali::Actor self( this ); - relayoutController->RequestRelayoutTree( self ); - } -} - void Actor::PropagateRelayoutFlags() { Internal::RelayoutController* relayoutController = Internal::RelayoutController::Get(); diff --git a/dali/internal/event/actors/actor-impl.h b/dali/internal/event/actors/actor-impl.h index b476a0d..bbc6287 100644 --- a/dali/internal/event/actors/actor-impl.h +++ b/dali/internal/event/actors/actor-impl.h @@ -939,12 +939,16 @@ public: Dimension::Type GetDimensionDependency( Dimension::Type dimension ) const; /** - * @copydoc Dali::Actor::SetRelayoutEnabled() + * @brief Set the size negotiation relayout enabled on this actor + * + * @param[in] relayoutEnabled Boolean to enable or disable relayout */ void SetRelayoutEnabled( bool relayoutEnabled ); /** - * @copydoc Dali::Actor::IsRelayoutEnabled() + * @brief Return if relayout is enabled + * + * @return Return if relayout is enabled or not for this actor */ bool IsRelayoutEnabled() const; @@ -993,15 +997,6 @@ public: */ void RelayoutRequest( Dimension::Type dimension = Dimension::ALL_DIMENSIONS ); - /** - * @brief Request to relayout of all actors in the sub-tree below the given actor. - * - * This flags the actor and all actors below it for relayout. The actual - * relayout is performed at the end of the frame. This means that multiple calls to relayout - * will not cause multiple relayouts to occur. - */ - void RelayoutRequestTree(); - /* * @copydoc Dali::Actor::PropagateRelayoutFlags */ @@ -1056,13 +1051,13 @@ public: float CalculateSize( Dimension::Type dimension, const Vector2& maximumSize ); /** - * @brief Constain a dimension given the relayout constraints on this actor + * @brief Clamp a dimension given the relayout constraints on this actor * * @param[in] size The size to constrain * @param[in] dimension The dimension the size exists in - * @return Return the constrained size + * @return Return the clamped size */ - float ConstrainDimension( float size, Dimension::Type dimension ); + float ClampDimension( float size, Dimension::Type dimension ); /** * Negotiate a dimension based on the size of the parent diff --git a/dali/internal/event/actors/custom-actor-internal.cpp b/dali/internal/event/actors/custom-actor-internal.cpp index 273b6ac..b0a12bf 100644 --- a/dali/internal/event/actors/custom-actor-internal.cpp +++ b/dali/internal/event/actors/custom-actor-internal.cpp @@ -42,6 +42,7 @@ CustomActor::CustomActor(CustomActorImpl& extension) mDerivedRequiresTouch = extension.RequiresTouchEvents(); mDerivedRequiresHover = extension.RequiresHoverEvents(); mDerivedRequiresMouseWheelEvent = extension.RequiresMouseWheelEvents(); + SetRelayoutEnabled( extension.IsRelayoutEnabled() ); } CustomActor::~CustomActor() diff --git a/dali/internal/event/actors/image-actor-impl.cpp b/dali/internal/event/actors/image-actor-impl.cpp index 9768ed8..b2da7e3 100644 --- a/dali/internal/event/actors/image-actor-impl.cpp +++ b/dali/internal/event/actors/image-actor-impl.cpp @@ -131,7 +131,8 @@ void ImageActor::SetImage( ImagePtr& image ) } // set the actual image (normal or 9 patch) and natural size based on that mImageAttachment->SetImage( newImage ); - SetNaturalSize(); + + RelayoutRequest(); } ImagePtr ImageActor::GetImage() @@ -139,18 +140,11 @@ ImagePtr ImageActor::GetImage() return mImageAttachment->GetImage(); } -void ImageActor::SetToNaturalSize() -{ - mUsingNaturalSize = true; - - SetNaturalSize(); -} - void ImageActor::SetPixelArea( const PixelArea& pixelArea ) { mImageAttachment->SetPixelArea( pixelArea ); - SetNaturalSize(); + RelayoutRequest(); } const ImageActor::PixelArea& ImageActor::GetPixelArea() const @@ -167,16 +161,7 @@ void ImageActor::ClearPixelArea() { mImageAttachment->ClearPixelArea(); - if( mUsingNaturalSize ) - { - ImagePtr image = mImageAttachment->GetImage(); - if( image ) - { - mInternalSetSize = true; - SetSizeInternal( image->GetNaturalSize() ); - mInternalSetSize = false; - } - } + RelayoutRequest(); } void ImageActor::SetStyle( Style style ) @@ -211,28 +196,14 @@ RenderableAttachment& ImageActor::GetRenderableAttachment() const } ImageActor::ImageActor() -: RenderableActor(), - mUsingNaturalSize(true), - mInternalSetSize(false) +: RenderableActor() { - // Size negotiate disabled by default, so turn it on for this actor - SetRelayoutEnabled( true ); } ImageActor::~ImageActor() { } -void ImageActor::SetNaturalSize() -{ - if( mUsingNaturalSize ) - { - mInternalSetSize = true; - SetSizeInternal( CalculateNaturalSize() ); - mInternalSetSize = false; - } -} - Vector3 ImageActor::GetNaturalSize() const { Vector2 naturalSize( CalculateNaturalSize() ); @@ -262,19 +233,6 @@ Vector2 ImageActor::CalculateNaturalSize() const return size; } -void ImageActor::OnSizeSet( const Vector3& targetSize ) -{ - if( !mInternalSetSize ) - { - mUsingNaturalSize = false; - } -} - -void ImageActor::OnSizeAnimation(Animation& animation, const Vector3& targetSize) -{ - mUsingNaturalSize = false; -} - void ImageActor::OnStageConnectionInternal() { } diff --git a/dali/internal/event/actors/image-actor-impl.h b/dali/internal/event/actors/image-actor-impl.h index 75c09ea..9ea53ce 100644 --- a/dali/internal/event/actors/image-actor-impl.h +++ b/dali/internal/event/actors/image-actor-impl.h @@ -79,11 +79,6 @@ public: ImagePtr GetImage(); /** - * @copydoc Dali::ImageActor::SetToNaturalSize() - */ - void SetToNaturalSize(); - - /** * @copydoc Dali::ImageActor::SetPixelArea() */ void SetPixelArea( const PixelArea& pixelArea ); @@ -210,11 +205,6 @@ protected: private: /** - * Helper to set the actor to the image's natural size - */ - void SetNaturalSize(); - - /** * Calculate the natural size of this image actor * * @return Return the natural size as a Vector2 @@ -222,17 +212,6 @@ private: Vector2 CalculateNaturalSize() const; /** - * From Actor. - * This is called after SizeSet() has been called. - */ - virtual void OnSizeSet( const Vector3& targetSize ); - - /** - * @copydoc Actor::OnSizeAnimation( Animation& animation, const Vector3& targetSize ) - */ - virtual void OnSizeAnimation(Animation& animation, const Vector3& targetSize); - - /** * From Actor; used to trigger fade-in animations. */ virtual void OnStageConnectionInternal(); @@ -246,10 +225,6 @@ private: ImageAttachmentPtr mImageAttachment; ///< Used to display the image (holds a pointer to currently showed Image) - // flags, compressed to bitfield (uses only 1 byte) - bool mUsingNaturalSize:1; ///< True only when the actor is using - bool mInternalSetSize:1; ///< True whilst setting size internally, false at all other times - }; } // namespace Internal diff --git a/dali/internal/event/actors/layer-impl.cpp b/dali/internal/event/actors/layer-impl.cpp index e986a57..a258b69 100644 --- a/dali/internal/event/actors/layer-impl.cpp +++ b/dali/internal/event/actors/layer-impl.cpp @@ -112,8 +112,6 @@ Layer::Layer( Actor::DerivedType type ) mTouchConsumed(false), mHoverConsumed(false) { - // Size negotiate disabled by default, so turn it on for this actor - SetRelayoutEnabled( true ); } void Layer::OnInitialize() diff --git a/dali/internal/event/common/stage-impl.cpp b/dali/internal/event/common/stage-impl.cpp index 9c9d6d7..31d8178 100644 --- a/dali/internal/event/common/stage-impl.cpp +++ b/dali/internal/event/common/stage-impl.cpp @@ -98,7 +98,6 @@ void Stage::Initialize() // The stage owns the default layer mRootLayer = Layer::NewRoot( *mLayerList, mUpdateManager, false/*not system-level*/ ); mRootLayer->SetName("RootLayer"); - mRootLayer->SetRelayoutEnabled( false ); // Exclude from size negotiation // Create the default camera actor first; this is needed by the RenderTaskList CreateDefaultCameraActor(); diff --git a/dali/internal/event/common/system-overlay-impl.cpp b/dali/internal/event/common/system-overlay-impl.cpp index 2ab705c..2733568 100644 --- a/dali/internal/event/common/system-overlay-impl.cpp +++ b/dali/internal/event/common/system-overlay-impl.cpp @@ -130,7 +130,6 @@ void SystemOverlay::CreateRootLayer() { mRootLayer = Layer::NewRoot( *mLayerList, mEventThreadServices.GetUpdateManager(), true/*system layer*/ ); mRootLayer->SetName("SystemOverlayRoot"); - mRootLayer->SetRelayoutEnabled( false ); // Exclude from size negotiation mRootLayer->SetSize( mSize.width, mSize.height ); } } diff --git a/dali/internal/event/size-negotiation/relayout-controller-impl.cpp b/dali/internal/event/size-negotiation/relayout-controller-impl.cpp index 81d0310..6fa43f3 100644 --- a/dali/internal/event/size-negotiation/relayout-controller-impl.cpp +++ b/dali/internal/event/size-negotiation/relayout-controller-impl.cpp @@ -69,7 +69,7 @@ void PrintChildren( Dali::Actor actor, int level ) output << ", Dirty: (" << ( GetImplementation( actor ).IsLayoutDirty( Dimension::WIDTH ) ? "TRUE" : "FALSE" ) << "," << ( GetImplementation( actor ).IsLayoutDirty( Dimension::HEIGHT ) ? "TRUE" : "FALSE" ) << ")"; output << ", Negotiated: (" << ( GetImplementation( actor ).IsLayoutNegotiated( Dimension::WIDTH ) ? "TRUE" : "FALSE" ) << "," << ( GetImplementation( actor ).IsLayoutNegotiated( Dimension::HEIGHT ) ? "TRUE" : "FALSE" ) << ")"; - output << ", Enabled: " << ( actor.IsRelayoutEnabled() ? "TRUE" : "FALSE" ); + output << ", Enabled: " << ( GetImplementation( actor ).IsRelayoutEnabled() ? "TRUE" : "FALSE" ); output << ", (" << actor.GetObjectPtr() << ")" << std::endl; @@ -213,7 +213,7 @@ void RelayoutController::RequestRelayoutTree( Dali::Actor& actor ) { // If parent is not in relayout we are at the top of a new sub-tree Dali::Actor parent = actor.GetParent(); - if( !parent || !parent.IsRelayoutEnabled() ) + if( !parent || !GetImplementation( parent ).IsRelayoutEnabled() ) { AddRequest( actor ); } diff --git a/dali/public-api/actors/actor.cpp b/dali/public-api/actors/actor.cpp index 335be73..1fd4d43 100644 --- a/dali/public-api/actors/actor.cpp +++ b/dali/public-api/actors/actor.cpp @@ -444,16 +444,6 @@ bool Actor::IsKeyboardFocusable() const return GetImplementation(*this).IsKeyboardFocusable(); } -void Actor::SetRelayoutEnabled( bool enabled ) -{ - GetImplementation(*this).SetRelayoutEnabled( enabled ); -} - -bool Actor::IsRelayoutEnabled() const -{ - return GetImplementation(*this).IsRelayoutEnabled(); -} - void Actor::SetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension ) { GetImplementation(*this).SetResizePolicy( policy, dimension ); @@ -489,11 +479,6 @@ float Actor::GetRelayoutSize( Dimension::Type dimension ) const return GetImplementation(*this).GetRelayoutSize( dimension ); } -void Actor::RelayoutRequestTree() -{ - GetImplementation(*this).RelayoutRequestTree(); -} - void Actor::PropagateRelayoutFlags() { GetImplementation(*this).PropagateRelayoutFlags(); diff --git a/dali/public-api/actors/actor.h b/dali/public-api/actors/actor.h index 5c35143..6ebfcdb 100644 --- a/dali/public-api/actors/actor.h +++ b/dali/public-api/actors/actor.h @@ -292,7 +292,6 @@ public: POSITION_INHERITANCE, ///< name "position-inheritance", type std::string DRAW_MODE, ///< name "draw-mode", type std::string SIZE_MODE_FACTOR, ///< name "size-mode-factor", type Vector3 - RELAYOUT_ENABLED, ///< name "relayout-enabled", type Boolean WIDTH_RESIZE_POLICY, ///< name "width-resize-policy", type String HEIGHT_RESIZE_POLICY, ///< name "height-resize-policy", type String SIZE_SCALE_POLICY, ///< name "size-scale-policy", type String @@ -1147,20 +1146,6 @@ public: // SIZE NEGOTIATION /** - * @brief Set if the actor should do relayout in size negotiation or not. - * - * @param[in] enabled Flag to specify if actor should do relayout or not. - */ - void SetRelayoutEnabled( bool enabled ); - - /** - * @brief Is the actor included in relayout or not. - * - * @return Return if the actor is involved in size negotiation or not. - */ - bool IsRelayoutEnabled() const; - - /** * Set the resize policy to be used for the given dimension(s) * * @param[in] policy The resize policy to use @@ -1236,15 +1221,6 @@ public: float GetRelayoutSize( Dimension::Type dimension ) const; /** - * @brief Request to relayout of all actors in the sub-tree below the given actor. - * - * This flags the actor and all actors below it for relayout. The actual - * relayout is performed at the end of the frame. This means that multiple calls to relayout - * will not cause multiple relayouts to occur. - */ - void RelayoutRequestTree(); - - /** * @brief Force propagate relayout flags through the tree. This actor and all actors * dependent on it will have their relayout flags reset. * diff --git a/dali/public-api/actors/custom-actor-impl.cpp b/dali/public-api/actors/custom-actor-impl.cpp index f9d2558..9640b87 100644 --- a/dali/public-api/actors/custom-actor-impl.cpp +++ b/dali/public-api/actors/custom-actor-impl.cpp @@ -38,11 +38,9 @@ void CustomActorImpl::OnPropertySet( Property::Index index, Property::Value prop { } -CustomActorImpl::CustomActorImpl(bool requiresTouchEvents) +CustomActorImpl::CustomActorImpl( ActorFlags flags ) : mOwner(NULL), - mRequiresTouchEvents(requiresTouchEvents), - mRequiresHoverEvents(false), - mRequiresMouseWheelEvents(false) + mFlags( flags ) { } @@ -60,27 +58,22 @@ Internal::CustomActor* CustomActorImpl::GetOwner() const bool CustomActorImpl::RequiresTouchEvents() const { - return mRequiresTouchEvents; + return ( mFlags & REQUIRES_TOUCH_EVENTS ); } bool CustomActorImpl::RequiresHoverEvents() const { - return mRequiresHoverEvents; -} - -void CustomActorImpl::SetRequiresHoverEvents(bool requiresHoverEvents) -{ - mRequiresHoverEvents = requiresHoverEvents; + return ( mFlags & REQUIRES_HOVER_EVENTS ); } bool CustomActorImpl::RequiresMouseWheelEvents() const { - return mRequiresMouseWheelEvents; + return ( mFlags & REQUIRES_MOUSE_WHEEL_EVENTS ); } -void CustomActorImpl::SetRequiresMouseWheelEvents(bool requiresMouseWheelEvents) +bool CustomActorImpl::IsRelayoutEnabled() const { - mRequiresMouseWheelEvents = requiresMouseWheelEvents; + return ( mFlags & DISABLE_SIZE_NEGOTIATION ) == 0; } void CustomActorImpl::RelayoutRequest() diff --git a/dali/public-api/actors/custom-actor-impl.h b/dali/public-api/actors/custom-actor-impl.h index 9d7948a..4797f45 100644 --- a/dali/public-api/actors/custom-actor-impl.h +++ b/dali/public-api/actors/custom-actor-impl.h @@ -23,6 +23,7 @@ #include #include #include +#include namespace Dali { @@ -270,23 +271,25 @@ public: protected: // For derived classes - /** - * @brief Create a CustomActorImpl. - * @param[in] requiresTouchEvents True if the OnTouchEvent() callback is required. - */ - CustomActorImpl(bool requiresTouchEvents); + // Flags for the constructor + enum ActorFlags + { + ACTOR_BEHAVIOUR_NONE = 0, + DISABLE_SIZE_NEGOTIATION = 1 << 0, ///< True if control does not need size negotiation, i.e. it can be skipped in the algorithm + REQUIRES_TOUCH_EVENTS = 1 << 1, ///< True if the OnTouchEvent() callback is required. + REQUIRES_HOVER_EVENTS = 1 << 2, ///< True if the OnHoverEvent() callback is required. + REQUIRES_MOUSE_WHEEL_EVENTS = 1 << 3, ///< True if the OnMouseWheelEvent() callback is required. - /** - * @brief Set whether the custom actor requires hover events. - * @param[in] requiresHoverEvents True if the OnHoverEvent() callback is required. - */ - void SetRequiresHoverEvents(bool requiresHoverEvents); + LAST_ACTOR_FLAG ///< Special marker for last actor flag + }; + + static const int ACTOR_FLAG_COUNT = Log< LAST_ACTOR_FLAG - 1 >::value + 1; ///< Value for deriving classes to continue on the flag enum /** - * @brief Set whether the custom actor requires mouse wheel events. - * @param[in] requiresMouseWheelEvents True if the OnMouseWheelEvent() callback is required. + * @brief Create a CustomActorImpl. + * @param[in] flags Bitfield of ActorFlags to define behaviour */ - void SetRequiresMouseWheelEvents(bool requiresMouseWheelEvents); + CustomActorImpl( ActorFlags flags ); /** * @brief Request a relayout, which means performing a size negotiation on this actor, its parent and children (and potentially whole scene) @@ -354,12 +357,16 @@ public: // Not intended for application developers */ bool RequiresMouseWheelEvents() const; + /** + * @brief Called when ownership of the CustomActorImpl is passed to a CustomActor. + * @return Return true if relayout is enabled on the custom actor + */ + bool IsRelayoutEnabled() const; + private: - Internal::CustomActor* mOwner; ///< Internal owner of this custom actor implementation - bool mRequiresTouchEvents; ///< Whether the OnTouchEvent() callback is required - bool mRequiresHoverEvents; ///< Whether the OnHoverEvent() callback is required - bool mRequiresMouseWheelEvents; ///< Whether the OnMouseWheelEvent() callback is required + Internal::CustomActor* mOwner; ///< Internal owner of this custom actor implementation + ActorFlags mFlags :ACTOR_FLAG_COUNT; ///< ActorFlags flags to determine behaviour }; } // namespace Dali diff --git a/dali/public-api/actors/image-actor.cpp b/dali/public-api/actors/image-actor.cpp index 5d80724..9968067 100644 --- a/dali/public-api/actors/image-actor.cpp +++ b/dali/public-api/actors/image-actor.cpp @@ -89,11 +89,6 @@ Image ImageActor::GetImage() return Dali::Image( imagePtr.Get() ); } -void ImageActor::SetToNaturalSize() -{ - GetImplementation(*this).SetToNaturalSize(); -} - void ImageActor::SetPixelArea(const PixelArea& pixelArea) { GetImplementation(*this).SetPixelArea(pixelArea); diff --git a/dali/public-api/actors/image-actor.h b/dali/public-api/actors/image-actor.h index 1727b46..69f77cf 100644 --- a/dali/public-api/actors/image-actor.h +++ b/dali/public-api/actors/image-actor.h @@ -46,8 +46,6 @@ class ImageActor; * Setting a size on the ImageActor, e.g through the SetSize api or through an animation will * stop the natural size being used. * - * Such a set size can be changed back to the image's size by calling SetToNaturalSize(). - * * If a pixel area is set on an ImageActor with natural size, the actor size will change * to match the pixel area. If a pixel area is set on an ImageActor that has had it's size set, * then the size doesn't change, and the partial image will be stretched to fill the set size. @@ -249,18 +247,6 @@ public: Image GetImage(); /** - * @brief Tell the image actor to use the natural size of the current image - * or future images. - * - * Calling SetSize on this actor or animating the size of the actor - * overrides this behaviour. - * - * @post The image actor uses the natural image size after an image - * has been loaded. - */ - void SetToNaturalSize(); - - /** * @brief Set a region of the image to display, in pixels. * * When the image is loaded the actor's size will be reset to the pixelArea, -- 2.7.4