X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Fevent%2Factors%2Factor-impl.h;h=fca059ccf846a026ff2d4ce5d539dac15493a46e;hb=02e4f29516fd16ead7ace2f5ffafbca1db6a8fcd;hp=44047186217e11eea9e33cdfb3018d18285d104d;hpb=199a66447fc65d87cdfffc39465253ddcb0e436b;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/dali/internal/event/actors/actor-impl.h b/dali/internal/event/actors/actor-impl.h old mode 100755 new mode 100644 index 4404718..fca059c --- a/dali/internal/event/actors/actor-impl.h +++ b/dali/internal/event/actors/actor-impl.h @@ -2,7 +2,7 @@ #define DALI_INTERNAL_ACTOR_H /* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 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. @@ -23,25 +23,32 @@ // INTERNAL INCLUDES #include -#include -#include #include +#include #include #include #include #include + +#include +#include + +#include + +#include #include #include #include +#include +#include +#include +#include #include #include -#include #include -#include namespace Dali { - class KeyEvent; class TouchData; class TouchEvent; @@ -49,7 +56,6 @@ class WheelEvent; namespace Internal { - class Actor; class ActorGestureData; class Animation; @@ -57,18 +63,8 @@ class RenderTask; class Renderer; class Scene; -using ActorContainer = std::vector; -using ActorIter = ActorContainer::iterator; -using ActorConstIter = ActorContainer::const_iterator; - -using RendererContainer = std::vector; -using RendererIter = RendererContainer::iterator; - -class ActorDepthTreeNode; -using DepthNodeMemoryPool = Dali::Internal::MemoryPoolObjectAllocator; - /** - * Actor is the primary object which Dali applications interact with. + * Actor is the primary object with which Dali applications interact. * UI controls can be built by combining multiple actors. * Multi-Touch events are received through signals emitted by the actor tree. * @@ -77,46 +73,9 @@ using DepthNodeMemoryPool = Dali::Internal::MemoryPoolObjectAllocator; - -public: - /** * Create a new actor. * @return A smart-pointer to the newly allocated Actor. @@ -133,16 +92,16 @@ public: * Retrieve the name of the actor. * @return The name. */ - const std::string& GetName() const + std::string_view GetName() const { - return mName; + return mName.GetStringView(); } /** * Set the name of the actor. * @param[in] name The new name. */ - void SetName( const std::string& name ); + void SetName(std::string_view name); /** * @copydoc Dali::Actor::GetId @@ -175,7 +134,7 @@ public: bool IsRenderable() const { // inlined as this is called a lot in hit testing - return mRenderers && !mRenderers->empty(); + return mRenderers && !mRenderers->IsEmpty(); } /** @@ -195,20 +154,19 @@ public: Dali::Layer GetLayer(); /** - * Adds a child Actor to this Actor. - * @pre The child actor is not the same as the parent actor. - * @pre The child actor does not already have a parent. - * @param [in] child The child. - * @post The child will be referenced by its parent. + * @copydoc Dali::Internal::ActorParent::Add() + */ + void Add(Actor& child, bool notify = true) override; + + /** + * @copydoc Dali::Internal::ActorParent::Remove() */ - void Add( Actor& child ); + void Remove(Actor& child, bool notify = true) override; /** - * Removes a child Actor from this Actor. - * @param [in] child The child. - * @post The child will be unreferenced. + * @copydoc Dali::DevelActor::SwitchParent() */ - void Remove( Actor& child ); + void SwitchParent(Actor& newParent); /** * @copydoc Dali::Actor::Unparent @@ -216,15 +174,14 @@ public: void Unparent(); /** - * Retrieve the number of children held by the actor. - * @return The number of children + * @copydoc Dali::Internal::ActorParent::GetChildCount() */ - uint32_t GetChildCount() const; + uint32_t GetChildCount() const override; /** - * @copydoc Dali::Actor::GetChildAt + * @copydoc Dali::Internal::ActorParent::GetChildAt */ - ActorPtr GetChildAt( uint32_t index ) const; + ActorPtr GetChildAt(uint32_t index) const override; /** * Retrieve a reference to Actor's children. @@ -232,20 +189,22 @@ public: * @return A reference to the container of children. * @note The internal container is lazily initialized so ensure you check the child count before using the value returned by this method. */ - ActorContainer& GetChildrenInternal() - { - return *mChildren; - } + ActorContainer& GetChildrenInternal(); + + /** + * @copydoc Dali::Internal::ActorParent::FindChildByName + */ + ActorPtr FindChildByName(ConstString actorName) override; /** - * @copydoc Dali::Actor::FindChildByName + * @copydoc Dali::Internal::ActorParent::FindChildById */ - ActorPtr FindChildByName( const std::string& actorName ); + ActorPtr FindChildById(const uint32_t id) override; /** - * @copydoc Dali::Actor::FindChildById + * @copydoc Dali::Internal::ActorParent::UnparentChildren */ - ActorPtr FindChildById( const uint32_t id ); + void UnparentChildren() override; /** * Retrieve the parent of an Actor. @@ -253,7 +212,7 @@ public: */ Actor* GetParent() const { - return mParent; + return static_cast(mParent); } /** @@ -261,7 +220,24 @@ public: * * @return pair of two values, position of top-left corner on screen and size respectively. */ - Rect<> CalculateScreenExtents( ) const; + Rect<> CalculateScreenExtents() const; + + /** + * @copydoc DevelActor::SetNeedGesturePropagation. + */ + void SetNeedGesturePropagation(bool propagation) + { + mNeedGesturePropagation = propagation; + } + + /** + * Retrieve need gesture propagation value + * @return The actor's need gesture propagation value. + */ + bool NeedGesturePropagation() const + { + return mNeedGesturePropagation; + } /** * Sets the size of an actor. @@ -269,7 +245,7 @@ public: * @param [in] width The new width. * @param [in] height The new height. */ - void SetSize( float width, float height ); + void SetSize(float width, float height); /** * Sets the size of an actor. @@ -278,53 +254,39 @@ public: * @param [in] height The size of the actor along the y-axis. * @param [in] depth The size of the actor along the z-axis. */ - void SetSize( float width, float height, float depth ); + void SetSize(float width, float height, float depth); /** * Sets the size of an actor. * This does not interfere with the actors scale factor. * @param [in] size The new size. */ - void SetSize( const Vector2& size ); - - /** - * Sets the update size for an actor. - * - * @param[in] size The size to set. - */ - void SetSizeInternal( const Vector2& size ); + void SetSize(const Vector2& size); /** * Sets the size of an actor. * This does not interfere with the actors scale factor. * @param [in] size The new size. */ - void SetSize( const Vector3& size ); - - /** - * Sets the update size for an actor. - * - * @param[in] size The size to set. - */ - void SetSizeInternal( const Vector3& size ); + void SetSize(const Vector3& size); /** * Set the width component of the Actor's size. * @param [in] width The new width component. */ - void SetWidth( float width ); + void SetWidth(float width); /** * Set the height component of the Actor's size. * @param [in] height The new height component. */ - void SetHeight( float height ); + void SetHeight(float height); /** * Set the depth component of the Actor's size. * @param [in] depth The new depth component. */ - void SetDepth( float depth ); + void SetDepth(float depth); /** * Retrieve the Actor's size from event side. @@ -355,7 +317,7 @@ public: * An actor position is the distance between this origin, and the actors anchor-point. * @param [in] origin The new parent-origin. */ - void SetParentOrigin( const Vector3& origin ); + void SetParentOrigin(const Vector3& origin); /** * Retrieve the parent-origin of an actor. @@ -371,7 +333,7 @@ public: * An actor's rotation is centered around its anchor-point. * @param [in] anchorPoint The new anchor-point. */ - void SetAnchorPoint( const Vector3& anchorPoint ); + void SetAnchorPoint(const Vector3& anchorPoint); /** * Retrieve the anchor-point of an actor. @@ -380,13 +342,20 @@ public: const Vector3& GetCurrentAnchorPoint() const; /** + * If the position uses the anchor point, return the anchor point, otherwise + * return top left. + * @return The anchor point for positioning. + */ + Vector3 GetAnchorPointForPosition() const; + + /** * Sets the position of the Actor. * The coordinates are relative to the Actor's parent. * The Actor's z position will be set to 0.0f. * @param [in] x The new x position * @param [in] y The new y position */ - void SetPosition( float x, float y ); + void SetPosition(float x, float y); /** * Sets the position of the Actor. @@ -395,38 +364,38 @@ public: * @param [in] y The new y position * @param [in] z The new z position */ - void SetPosition( float x, float y, float z ); + void SetPosition(float x, float y, float z); /** * Sets the position of the Actor. * The coordinates are relative to the Actor's parent. * @param [in] position The new position. */ - void SetPosition( const Vector3& position ); + void SetPosition(const Vector3& position); /** * Set the position of an actor along the X-axis. * @param [in] x The new x position */ - void SetX( float x ); + void SetX(float x); /** * Set the position of an actor along the Y-axis. * @param [in] y The new y position. */ - void SetY( float y ); + void SetY(float y); /** * Set the position of an actor along the Z-axis. * @param [in] z The new z position */ - void SetZ( float z ); + void SetZ(float z); /** * Translate an actor relative to its existing position. * @param[in] distance The actor will move by this distance. */ - void TranslateBy( const Vector3& distance ); + void TranslateBy(const Vector3& distance); /** * Retrieve the position of the Actor. @@ -453,7 +422,7 @@ public: /** * @copydoc Dali::Actor::SetInheritPosition() */ - void SetInheritPosition( bool inherit ); + void SetInheritPosition(bool inherit); /** * @copydoc Dali::Actor::IsPositionInherited() @@ -468,26 +437,26 @@ public: * @param [in] angleRadians The new orientation angle in radians. * @param [in] axis The new axis of orientation. */ - void SetOrientation( const Radian& angleRadians, const Vector3& axis ); + void SetOrientation(const Radian& angleRadians, const Vector3& axis); /** * Sets the orientation of the Actor. * @param [in] orientation The new orientation. */ - void SetOrientation( const Quaternion& orientation ); + void SetOrientation(const Quaternion& orientation); /** * Rotate an actor around its existing rotation axis. * @param[in] angleRadians The angle to the rotation to combine with the existing rotation. * @param[in] axis The axis of the rotation to combine with the existing rotation. */ - void RotateBy( const Radian& angleRadians, const Vector3& axis ); + void RotateBy(const Radian& angleRadians, const Vector3& axis); /** * Apply a relative rotation to an actor. * @param[in] relativeRotation The rotation to combine with the actors existing rotation. */ - void RotateBy( const Quaternion& relativeRotation ); + void RotateBy(const Quaternion& relativeRotation); /** * Retreive the Actor's orientation. @@ -500,7 +469,7 @@ public: * Switching this off means that using SetOrientation() sets the actor's world orientation. * @param[in] inherit - true if the actor should inherit orientation, false otherwise. */ - void SetInheritOrientation( bool inherit ); + void SetInheritOrientation(bool inherit); /** * Returns whether the actor inherit's it's parent's orientation. @@ -516,7 +485,7 @@ public: * Note: Only used if ResizePolicy is ResizePolicy::SIZE_RELATIVE_TO_PARENT or ResizePolicy::SIZE_FIXED_OFFSET_FROM_PARENT. * @param[in] factor The vector to multiply the parents size by to get the childs size. */ - void SetSizeModeFactor( const Vector3& factor ); + void SetSizeModeFactor(const Vector3& factor); /** * Gets the factor of the parents size used for the child actor. @@ -534,7 +503,7 @@ public: * Sets a scale factor applied to an actor. * @param [in] scale The scale factor applied on all axes. */ - void SetScale( float scale ); + void SetScale(float scale); /** * Sets a scale factor applied to an actor. @@ -542,37 +511,37 @@ public: * @param [in] scaleY The scale factor applied along the y-axis. * @param [in] scaleZ The scale factor applied along the z-axis. */ - void SetScale( float scaleX, float scaleY, float scaleZ ); + void SetScale(float scaleX, float scaleY, float scaleZ); /** * Sets a scale factor applied to an actor. * @param [in] scale A vector representing the scale factor for each axis. */ - void SetScale( const Vector3& scale ); + void SetScale(const Vector3& scale); /** * Set the x component of the scale factor. * @param [in] x The new x value. */ - void SetScaleX( float x ); + void SetScaleX(float x); /** * Set the y component of the scale factor. * @param [in] y The new y value. */ - void SetScaleY( float y ); + void SetScaleY(float y); /** * Set the z component of the scale factor. * @param [in] z The new z value. */ - void SetScaleZ( float z ); + void SetScaleZ(float z); /** * Apply a relative scale to an actor. * @param[in] relativeScale The scale to combine with the actors existing scale. */ - void ScaleBy( const Vector3& relativeScale ); + void ScaleBy(const Vector3& relativeScale); /** * Retrieve the scale factor applied to an actor. @@ -588,7 +557,7 @@ public: /** * @copydoc Dali::Actor::SetInheritScale() */ - void SetInheritScale( bool inherit ); + void SetInheritScale(bool inherit); /** * @copydoc Dali::Actor::IsScaleInherited() @@ -609,7 +578,7 @@ public: * Sets the visibility flag of an actor. * @param[in] visible The new visibility flag. */ - void SetVisible( bool visible ); + void SetVisible(bool visible); /** * Retrieve the visibility flag of an actor. @@ -621,7 +590,7 @@ public: * Sets the opacity of an actor. * @param [in] opacity The new opacity. */ - void SetOpacity( float opacity ); + void SetOpacity(float opacity); /** * Retrieve the actor's opacity. @@ -658,7 +627,7 @@ public: * @note If an actor's sensitivity is set to false, then it's children will not emit a touch or hover event signal either. * @param[in] sensitive true to enable emission of the touch or hover event signals, false otherwise. */ - void SetSensitive( bool sensitive ) + void SetSensitive(bool sensitive) { mSensitive = sensitive; } @@ -674,9 +643,44 @@ public: } /** + * Sets whether an actor should be enabled all user interaction including touch, focus and activation. + * This value have higher priority over the sensitve and focusable in negative action, + * which means IsSensitive() or IsFocusable() and enable is false, actor will not emits touch or focus event. + * An actor is enabled by default. + * + * If the application wishes to temporarily disable user interaction: + * @code + * actor.SetUserInteractionEnabled(false); + * @endcode + * + * Then, to re-enable user interaction, the application should call: + * @code + * actor.SetUserInteractionEnabled(true); + * @endcode + * + * @see IsSensitive(), IsHittable(), IsKeyboardFocusable() and IsTouchFocusable(). + * @note If an actor's disabled, child still can be enabled. + * @param[in] enabled true to enable user interaction, false otherwise. + */ + void SetUserInteractionEnabled(bool enabled) + { + mUserInteractionEnabled = enabled; + } + + /** + * Query whether an actor is enabled user interaction. + * @see SetSensitive(bool) + * @return true, if user interaction is enabled, false otherwise. + */ + bool IsUserInteractionEnabled() const + { + return mUserInteractionEnabled; + } + + /** * @copydoc Dali::Actor::SetDrawMode */ - void SetDrawMode( DrawMode::Type drawMode ); + void SetDrawMode(DrawMode::Type drawMode); /** * @copydoc Dali::Actor::GetDrawMode @@ -691,7 +695,7 @@ public: */ bool IsOverlay() const { - return ( DrawMode::OVERLAY_2D == mDrawMode ); + return (DrawMode::OVERLAY_2D == mDrawMode); } /** @@ -699,25 +703,25 @@ public: * This final color is applied to the drawable elements of an actor. * @param [in] color The new color. */ - void SetColor( const Vector4& color ); + void SetColor(const Vector4& color); /** * Set the red component of the color. * @param [in] red The new red component. */ - void SetColorRed( float red ); + void SetColorRed(float red); /** * Set the green component of the color. * @param [in] green The new green component. */ - void SetColorGreen( float green ); + void SetColorGreen(float green); /** * Set the blue component of the scale factor. * @param [in] blue The new blue value. */ - void SetColorBlue( float blue ); + void SetColorBlue(float blue); /** * Retrieve the actor's color. @@ -730,7 +734,7 @@ public: * Color mode specifies whether Actor uses its own color or inherits its parent color * @param [in] colorMode to use. */ - void SetColorMode( ColorMode colorMode ); + void SetColorMode(ColorMode colorMode); /** * Returns the actor's color mode. @@ -751,7 +755,7 @@ public: */ inline int32_t GetHierarchyDepth() const { - if( mIsOnScene ) + if(mIsOnScene) { return mDepth; } @@ -760,17 +764,40 @@ public: } /** + * @brief Get the number of layer with 3D behaviour in ancestors include this. It will be 0 if actor is not on scene. + * + * @return currently the number of layer with 3D behaviour in ancestors. + */ + inline int32_t GetLayer3DParentCount() const + { + if(mIsOnScene) + { + return mLayer3DParentsCount; + } + + return 0; + } + + /** * Get the actor's sorting depth * * @return The depth used for hit-testing and renderer sorting */ - uint32_t GetSortingDepth() + inline uint32_t GetSortingDepth() { return mSortedDepth; } -public: + /** + * Set the actor's sorted depth. Used during recreation of depth tree + * @param[in] sortedDepth the new sorted depth + */ + inline void SetSortingDepth(uint32_t sortedDepth) + { + mSortedDepth = sortedDepth; + } +public: // Size negotiation virtual functions /** @@ -789,7 +816,7 @@ public: * @param[in,out] container The control should add actors to this container that it is not able * to allocate a size for. */ - virtual void OnRelayout( const Vector2& size, RelayoutContainer& container ) + virtual void OnRelayout(const Vector2& size, RelayoutContainer& container) { } @@ -799,7 +826,9 @@ public: * @param[in] policy The policy being set * @param[in] dimension The dimension the policy is being set for */ - virtual void OnSetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension ) {} + virtual void OnSetResizePolicy(ResizePolicy::Type policy, Dimension::Type dimension) + { + } /** * @brief Virtual method to notify deriving classes that relayout dependencies have been @@ -807,7 +836,9 @@ public: * * @param dimension The dimension that is about to be calculated */ - virtual void OnCalculateRelayoutSize( Dimension::Type dimension ) {} + virtual void OnCalculateRelayoutSize(Dimension::Type dimension) + { + } /** * @brief Virtual method to notify deriving classes that the size for a dimension @@ -816,7 +847,9 @@ public: * @param[in] size The new size for the given dimension * @param[in] dimension The dimension that was just negotiated */ - virtual void OnLayoutNegotiated( float size, Dimension::Type dimension ) {} + virtual void OnLayoutNegotiated(float size, Dimension::Type dimension) + { + } /** * @brief Determine if this actor is dependent on it's children for relayout @@ -824,17 +857,7 @@ public: * @param dimension The dimension(s) to check for * @return Return if the actor is dependent on it's children */ - virtual bool RelayoutDependentOnChildren( Dimension::Type dimension = Dimension::ALL_DIMENSIONS ); - - /** - * @brief Determine if this actor is dependent on it's children for relayout. - * - * Called from deriving classes - * - * @param dimension The dimension(s) to check for - * @return Return if the actor is dependent on it's children - */ - virtual bool RelayoutDependentOnChildrenBase( Dimension::Type dimension = Dimension::ALL_DIMENSIONS ); + virtual bool RelayoutDependentOnChildren(Dimension::Type dimension = Dimension::ALL_DIMENSIONS); /** * @brief Calculate the size for a child @@ -843,7 +866,7 @@ public: * @param[in] dimension The dimension to calculate the size for. E.g. width or height. * @return Return the calculated size for the given dimension */ - virtual float CalculateChildSize( const Dali::Actor& child, Dimension::Type dimension ); + virtual float CalculateChildSize(const Dali::Actor& child, Dimension::Type dimension); /** * @brief This method is called during size negotiation when a height is required for a given width. @@ -853,7 +876,7 @@ public: * @param width to use. * @return the height based on the width. */ - virtual float GetHeightForWidth( float width ); + virtual float GetHeightForWidth(float width); /** * @brief This method is called during size negotiation when a width is required for a given height. @@ -863,10 +886,9 @@ public: * @param height to use. * @return the width based on the width. */ - virtual float GetWidthForHeight( float height ); + virtual float GetWidthForHeight(float height); public: - // Size negotiation /** @@ -881,62 +903,24 @@ public: * @param[in,out] container The container that holds actors that are fed back into the * RelayoutController algorithm. */ - void NegotiateSize( const Vector2& size, RelayoutContainer& container ); - - /** - * @brief Set whether size negotiation should use the assigned size of the actor - * during relayout for the given dimension(s) - * - * @param[in] use Whether the assigned size of the actor should be used - * @param[in] dimension The dimension(s) to set. Can be a bitfield of multiple dimensions - */ - void SetUseAssignedSize( bool use, Dimension::Type dimension = Dimension::ALL_DIMENSIONS ); - - /** - * @brief Returns whether size negotiation should use the assigned size of the actor - * during relayout for a single dimension - * - * @param[in] dimension The dimension to get - * @return Return whether the assigned size of the actor should be used. If more than one dimension is requested, just return the first one found - */ - bool GetUseAssignedSize( Dimension::Type dimension ) const; + void NegotiateSize(const Vector2& size, RelayoutContainer& container); /** * @copydoc Dali::Actor::SetResizePolicy() */ - void SetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension = Dimension::ALL_DIMENSIONS ); + void SetResizePolicy(ResizePolicy::Type policy, Dimension::Type dimension = Dimension::ALL_DIMENSIONS); /** * @copydoc Dali::Actor::GetResizePolicy() */ - ResizePolicy::Type GetResizePolicy( Dimension::Type dimension ) const; - - /** - * @copydoc Dali::Actor::SetSizeScalePolicy() - */ - void SetSizeScalePolicy( SizeScalePolicy::Type policy ); - - /** - * @copydoc Dali::Actor::GetSizeScalePolicy() - */ - SizeScalePolicy::Type GetSizeScalePolicy() const; - - /** - * @copydoc Dali::Actor::SetDimensionDependency() - */ - void SetDimensionDependency( Dimension::Type dimension, Dimension::Type dependency ); - - /** - * @copydoc Dali::Actor::GetDimensionDependency() - */ - Dimension::Type GetDimensionDependency( Dimension::Type dimension ) const; + ResizePolicy::Type GetResizePolicy(Dimension::Type dimension) const; /** * @brief Set the size negotiation relayout enabled on this actor * * @param[in] relayoutEnabled Boolean to enable or disable relayout */ - void SetRelayoutEnabled( bool relayoutEnabled ); + void SetRelayoutEnabled(bool relayoutEnabled); /** * @brief Return if relayout is enabled @@ -947,33 +931,37 @@ public: /** * @brief Mark an actor as having it's layout dirty + * @note Only called from RelayoutController * * @param dirty Whether to mark actor as dirty or not * @param dimension The dimension(s) to mark as dirty */ - void SetLayoutDirty( bool dirty, Dimension::Type dimension = Dimension::ALL_DIMENSIONS ); + void SetLayoutDirty(bool dirty, Dimension::Type dimension = Dimension::ALL_DIMENSIONS); /** * @brief Return if any of an actor's dimensions are marked as dirty + * @note Only called from RelayoutController * * @param dimension The dimension(s) to check * @return Return if any of the requested dimensions are dirty */ - bool IsLayoutDirty( Dimension::Type dimension = Dimension::ALL_DIMENSIONS ) const; + bool IsLayoutDirty(Dimension::Type dimension = Dimension::ALL_DIMENSIONS) const; /** * @brief Returns if relayout is enabled and the actor is not dirty + * @note Only called from RelayoutController * * @return Return if it is possible to relayout the actor */ - bool RelayoutPossible( Dimension::Type dimension = Dimension::ALL_DIMENSIONS ) const; + bool RelayoutPossible(Dimension::Type dimension = Dimension::ALL_DIMENSIONS) const; /** * @brief Returns if relayout is enabled and the actor is dirty + * @note Only called from RelayoutController * * @return Return if it is required to relayout the actor */ - bool RelayoutRequired( Dimension::Type dimension = Dimension::ALL_DIMENSIONS ) const; + bool RelayoutRequired(Dimension::Type dimension = Dimension::ALL_DIMENSIONS) const; /** * @brief Request a relayout, which means performing a size negotiation on this actor, its parent and children (and potentially whole scene) @@ -988,103 +976,26 @@ public: * @note RelayoutRequest() can be called multiple times; the size negotiation is still * only performed once, i.e. there is no need to keep track of this in the calling side. */ - void RelayoutRequest( Dimension::Type dimension = Dimension::ALL_DIMENSIONS ); + void RelayoutRequest(Dimension::Type dimension = Dimension::ALL_DIMENSIONS); /** * @brief Determine if this actor is dependent on it's parent for relayout + * @note Only called from RelayoutController * * @param dimension The dimension(s) to check for * @return Return if the actor is dependent on it's parent */ - bool RelayoutDependentOnParent( Dimension::Type dimension = Dimension::ALL_DIMENSIONS ); + bool RelayoutDependentOnParent(Dimension::Type dimension = Dimension::ALL_DIMENSIONS); /** * @brief Determine if this actor has another dimension depedent on the specified one + * @note Only called from RelayoutController * * @param dimension The dimension to check for * @param dependentDimension The dimension to check for dependency with * @return Return if the actor is dependent on this dimension */ - bool RelayoutDependentOnDimension( Dimension::Type dimension, Dimension::Type dependentDimension ); - - /** - * Negotiate sizes for a control in all dimensions - * - * @param[in] allocatedSize The size constraint that the control must respect - */ - void NegotiateDimensions( const Vector2& allocatedSize ); - - /** - * Negotiate size for a specific dimension - * - * The algorithm adopts a recursive dependency checking approach. Meaning, that wherever dependencies - * are found, e.g. an actor dependent on its parent, the dependency will be calculated first with NegotiatedDimension and - * LayoutDimensionNegotiated flags being filled in on the actor. - * - * @post All actors that exist in the dependency chain connected to the given actor will have had their NegotiatedDimensions - * calculated and set as well as the LayoutDimensionNegotiated flags. - * - * @param[in] dimension The dimension to negotiate on - * @param[in] allocatedSize The size constraint that the actor must respect - */ - void NegotiateDimension( Dimension::Type dimension, const Vector2& allocatedSize, ActorDimensionStack& recursionStack ); - - /** - * @brief Calculate the size of a dimension - * - * @param[in] dimension The dimension to calculate the size for - * @param[in] maximumSize The upper bounds on the size - * @return Return the calculated size for the dimension - */ - float CalculateSize( Dimension::Type dimension, const Vector2& maximumSize ); - - /** - * Negotiate a dimension based on the size of the parent - * - * @param[in] dimension The dimension to negotiate on - * @return Return the negotiated size - */ - float NegotiateFromParent( Dimension::Type dimension ); - - /** - * Negotiate a dimension based on the size of the parent. Fitting inside. - * - * @param[in] dimension The dimension to negotiate on - * @return Return the negotiated size - */ - float NegotiateFromParentFit( Dimension::Type dimension ); - - /** - * Negotiate a dimension based on the size of the parent. Flooding the whole space. - * - * @param[in] dimension The dimension to negotiate on - * @return Return the negotiated size - */ - float NegotiateFromParentFlood( Dimension::Type dimension ); - - /** - * @brief Negotiate a dimension based on the size of the children - * - * @param[in] dimension The dimension to negotiate on - * @return Return the negotiated size - */ - float NegotiateFromChildren( Dimension::Type dimension ); - - /** - * Set the negotiated dimension value for the given dimension(s) - * - * @param negotiatedDimension The value to set - * @param dimension The dimension(s) to set the value for - */ - void SetNegotiatedDimension( float negotiatedDimension, Dimension::Type dimension = Dimension::ALL_DIMENSIONS ); - - /** - * Return the value of negotiated dimension for the given dimension - * - * @param dimension The dimension to retrieve - * @return Return the value of the negotiated dimension - */ - float GetNegotiatedDimension( Dimension::Type dimension ) const; + bool RelayoutDependentOnDimension(Dimension::Type dimension, Dimension::Type dependentDimension); /** * @brief Set the padding for a dimension @@ -1092,7 +1003,7 @@ public: * @param[in] padding Padding for the dimension. X = start (e.g. left, bottom), y = end (e.g. right, top) * @param[in] dimension The dimension to set */ - void SetPadding( const Vector2& padding, Dimension::Type dimension ); + void SetPadding(const Vector2& padding, Dimension::Type dimension); /** * Return the value of padding for the given dimension @@ -1100,23 +1011,7 @@ public: * @param dimension The dimension to retrieve * @return Return the value of padding for the dimension */ - Vector2 GetPadding( Dimension::Type dimension ) const; - - /** - * Return the actor size for a given dimension - * - * @param[in] dimension The dimension to retrieve the size for - * @return Return the size for the given dimension - */ - float GetSize( Dimension::Type dimension ) const; - - /** - * Return the natural size of the actor for a given dimension - * - * @param[in] dimension The dimension to retrieve the size for - * @return Return the natural size for the given dimension - */ - float GetNaturalSize( Dimension::Type dimension ) const; + Vector2 GetPadding(Dimension::Type dimension) const; /** * @brief Return the amount of size allocated for relayout @@ -1126,22 +1021,7 @@ public: * @param[in] dimension The dimension to retrieve * @return Return the size */ - float GetRelayoutSize( Dimension::Type dimension ) const; - - /** - * @brief If the size has been negotiated return that else return normal size - * - * @param[in] dimension The dimension to retrieve - * @return Return the size - */ - float GetLatestSize( Dimension::Type dimension ) const; - - /** - * Apply the negotiated size to the actor - * - * @param[in] container The container to fill with actors that require further relayout - */ - void SetNegotiatedSize( RelayoutContainer& container ); + float GetRelayoutSize(Dimension::Type dimension) const; /** * @brief Flag the actor as having it's layout dimension negotiated. @@ -1149,7 +1029,7 @@ public: * @param[in] negotiated The status of the flag to set. * @param[in] dimension The dimension to set the flag for */ - void SetLayoutNegotiated( bool negotiated, Dimension::Type dimension = Dimension::ALL_DIMENSIONS ); + void SetLayoutNegotiated(bool negotiated, Dimension::Type dimension = Dimension::ALL_DIMENSIONS); /** * @brief Test whether the layout dimension for this actor has been negotiated or not. @@ -1157,69 +1037,63 @@ public: * @param[in] dimension The dimension to determine the value of the flag for * @return Return if the layout dimension is negotiated or not. */ - bool IsLayoutNegotiated( Dimension::Type dimension = Dimension::ALL_DIMENSIONS ) const; + bool IsLayoutNegotiated(Dimension::Type dimension = Dimension::ALL_DIMENSIONS) const; /** * @brief provides the Actor implementation of GetHeightForWidth * @param width to use. * @return the height based on the width. */ - float GetHeightForWidthBase( float width ); + float GetHeightForWidthBase(float width); /** * @brief provides the Actor implementation of GetWidthForHeight * @param height to use. * @return the width based on the height. */ - float GetWidthForHeightBase( float height ); + float GetWidthForHeightBase(float height); /** - * @brief Calculate the size for a child + * @brief provides the Actor implementation of CalculateChildSize * * @param[in] child The child actor to calculate the size for * @param[in] dimension The dimension to calculate the size for. E.g. width or height. * @return Return the calculated size for the given dimension */ - float CalculateChildSizeBase( const Dali::Actor& child, Dimension::Type dimension ); + float CalculateChildSizeBase(const Dali::Actor& child, Dimension::Type dimension); /** - * @brief Set the preferred size for size negotiation - * - * @param[in] size The preferred size to set - */ - void SetPreferredSize( const Vector2& size ); - - /** - * @brief Return the preferred size used for size negotiation + * @brief Determine if this actor is dependent on it's children for relayout. * - * @return Return the preferred size + * @param dimension The dimension(s) to check for + * @return Return if the actor is dependent on it's children */ - Vector2 GetPreferredSize() const; + bool RelayoutDependentOnChildrenBase(Dimension::Type dimension = Dimension::ALL_DIMENSIONS); /** * @copydoc Dali::Actor::SetMinimumSize */ - void SetMinimumSize( float size, Dimension::Type dimension = Dimension::ALL_DIMENSIONS ); + void SetMinimumSize(float size, Dimension::Type dimension = Dimension::ALL_DIMENSIONS); /** * @copydoc Dali::Actor::GetMinimumSize */ - float GetMinimumSize( Dimension::Type dimension ) const; + float GetMinimumSize(Dimension::Type dimension) const; /** * @copydoc Dali::Actor::SetMaximumSize */ - void SetMaximumSize( float size, Dimension::Type dimension = Dimension::ALL_DIMENSIONS ); + void SetMaximumSize(float size, Dimension::Type dimension = Dimension::ALL_DIMENSIONS); /** * @copydoc Dali::Actor::GetMaximumSize */ - float GetMaximumSize( Dimension::Type dimension ) const; + float GetMaximumSize(Dimension::Type dimension) const; /** * @copydoc Dali::Actor::AddRenderer() */ - uint32_t AddRenderer( Renderer& renderer ); + uint32_t AddRenderer(Renderer& renderer); /** * @copydoc Dali::Actor::GetRendererCount() @@ -1229,21 +1103,40 @@ public: /** * @copydoc Dali::Actor::GetRendererAt() */ - RendererPtr GetRendererAt( uint32_t index ); + RendererPtr GetRendererAt(uint32_t index); /** * @copydoc Dali::Actor::RemoveRenderer() */ - void RemoveRenderer( Renderer& renderer ); + void RemoveRenderer(Renderer& renderer); /** * @copydoc Dali::Actor::RemoveRenderer() */ - void RemoveRenderer( uint32_t index ); + void RemoveRenderer(uint32_t index); -public: + /** + * @brief Set BlendEquation at each renderer that added on this Actor. + */ + void SetBlendEquation(DevelBlendEquation::Type blendEquation); /** + * @brief Get Blend Equation that applied to this Actor + */ + DevelBlendEquation::Type GetBlendEquation() const; + + /** + * @brief Set this Actor is transparent or not without any affection on the child Actors. + */ + void SetTransparent(bool transparent); + + /** + * @brief Get this Actor is transparent or not. + */ + bool IsTransparent() const; + +public: + /** * Converts screen coordinates into the actor's coordinate system. * @note The actor coordinates are relative to the top-left (0.0, 0.0, 0.5) * @param[out] localX On return, the X-coordinate relative to the actor. @@ -1252,7 +1145,7 @@ public: * @param[in] screenY The screen Y-coordinate. * @return True if the conversion succeeded. */ - bool ScreenToLocal( float& localX, float& localY, float screenX, float screenY ) const; + bool ScreenToLocal(float& localX, float& localY, float screenX, float screenY) const; /** * Converts screen coordinates into the actor's coordinate system. @@ -1264,7 +1157,7 @@ public: * @param[in] screenY The screen Y-coordinate. * @return True if the conversion succeeded. */ - bool ScreenToLocal( const RenderTask& renderTask, float& localX, float& localY, float screenX, float screenY ) const; + bool ScreenToLocal(const RenderTask& renderTask, float& localX, float& localY, float screenX, float screenY) const; /** * Converts from the actor's coordinate system to screen coordinates. @@ -1278,13 +1171,13 @@ public: * @param[in] screenY The screen Y-coordinate. * @return True if the conversion succeeded. */ - bool ScreenToLocal( const Matrix& viewMatrix, - const Matrix& projectionMatrix, - const Viewport& viewport, - float& localX, - float& localY, - float screenX, - float screenY ) const; + bool ScreenToLocal(const Matrix& viewMatrix, + const Matrix& projectionMatrix, + const Viewport& viewport, + float& localX, + float& localY, + float screenX, + float screenY) const; /** * Sets whether the actor should receive a notification when touch or hover motion events leave @@ -1295,7 +1188,7 @@ public: * * @param[in] required Should be set to true if a Leave event is required */ - void SetLeaveRequired( bool required ) + void SetLeaveRequired(bool required) { mLeaveRequired = required; } @@ -1313,7 +1206,7 @@ public: /** * @copydoc Dali::Actor::SetKeyboardFocusable() */ - void SetKeyboardFocusable( bool focusable ) + void SetKeyboardFocusable(bool focusable) { mKeyboardFocusable = focusable; } @@ -1326,6 +1219,48 @@ public: return mKeyboardFocusable; } + /** + * @copydoc Dali::Actor::SetKeyboardFocusableChildren() + */ + void SetKeyboardFocusableChildren(bool focusable) + { + mKeyboardFocusableChildren = focusable; + } + + /** + * @copydoc Dali::Actor::AreChildrenKeyBoardFocusable() + */ + bool AreChildrenKeyBoardFocusable() const + { + return mKeyboardFocusableChildren; + } + + /** + * Set whether this view can focus by touch. + * @param[in] focusable focuable by touch. + */ + void SetTouchFocusable(bool focusable) + { + mTouchFocusable = focusable; + } + + /** + * This returns whether this actor can focus by touch. + * @return true if this actor can focus by touch. + */ + bool IsTouchFocusable() const + { + return mTouchFocusable; + } + + /** + * Query whether the application or derived actor type requires hit-test result events. + * @return True if hit-test result events are required. + */ + bool IsHitTestResultRequired() const + { + return !mHitTestResultSignal.Empty(); + } /** * Query whether the application or derived actor type requires intercept touch events. @@ -1370,7 +1305,7 @@ public: */ bool IsHittable() const { - return IsSensitive() && IsVisible() && ( GetCurrentWorldColor().a > FULLY_TRANSPARENT ) && IsNodeConnected(); + return (IsUserInteractionEnabled()) && IsSensitive() && IsVisible() && (GetCurrentWorldColor().a > FULLY_TRANSPARENT) && IsNodeConnected(); } /** @@ -1383,23 +1318,31 @@ public: } /** - * Sets the touch delegate area of an actor. - * @param [in] area The new area. + * Sets the touch area offset of an actor. + * @param [in] offset The new offset of area (left, right, bottom, top). */ - void SetTouchDelegateArea(Vector2 area) + void SetTouchAreaOffset(Rect offset) { - mTouchDelegateArea = area; + mTouchAreaOffset = offset; } /** - * Retrieve the Actor's touch delegate area. - * @return The Actor's touch delegate area. + * Retrieve the Actor's touch area offset. + * @return The Actor's touch area offset. */ - const Vector2& GetTouchDelegateArea() const + const Rect& GetTouchAreaOffset() const { - return mTouchDelegateArea; + return mTouchAreaOffset; } + /** + * Query whether the actor will only receive own touch. + * @return true, if it only receives touches that started from itself. + */ + bool IsAllowedOnlyOwnTouch() const + { + return mAllowOnlyOwnTouch; + } // Gestures @@ -1418,7 +1361,7 @@ public: * @param[in] type The gesture type. * @return True if the gesture is required, false otherwise. */ - bool IsGestureRequired( GestureType::Value type ) const; + bool IsGestureRequired(GestureType::Value type) const; // Signals @@ -1427,53 +1370,58 @@ public: * @param[in] touch The touch data. * @return True if the event was intercepted. */ - bool EmitInterceptTouchEventSignal( const Dali::TouchEvent& touch ); + bool EmitInterceptTouchEventSignal(const Dali::TouchEvent& touch); /** * Used by the EventProcessor to emit touch event signals. * @param[in] touch The touch data. * @return True if the event was consumed. */ - bool EmitTouchEventSignal( const Dali::TouchEvent& touch ); + bool EmitTouchEventSignal(const Dali::TouchEvent& touch); /** * Used by the EventProcessor to emit hover event signals. * @param[in] event The hover event. * @return True if the event was consumed. */ - bool EmitHoverEventSignal( const Dali::HoverEvent& event ); + bool EmitHoverEventSignal(const Dali::HoverEvent& event); /** * Used by the EventProcessor to emit wheel event signals. * @param[in] event The wheel event. * @return True if the event was consumed. */ - bool EmitWheelEventSignal( const Dali::WheelEvent& event ); + bool EmitWheelEventSignal(const Dali::WheelEvent& event); /** * @brief Emits the visibility change signal for this actor and all its children. * @param[in] visible Whether the actor has become visible or not. * @param[in] type Whether the actor's visible property has changed or a parent's. */ - void EmitVisibilityChangedSignal( bool visible, DevelActor::VisibilityChange::Type type ); + void EmitVisibilityChangedSignal(bool visible, DevelActor::VisibilityChange::Type type); /** * @brief Emits the layout direction change signal for this actor and all its children. * @param[in] type Whether the actor's layout direction property has changed or a parent's. */ - void EmitLayoutDirectionChangedSignal( LayoutDirection::Type type ); + void EmitLayoutDirectionChangedSignal(LayoutDirection::Type type); /** - * @brief Emits the ChildAdded signal for this actor - * @param[in] child The child actor that has been added + * Used by the EventProcessor to emit hit-test result touch event signals. + * @param[in] point The point of event touched. + * @param[in] hitPointLocal The hit point in the Actor's local reference system. + * @param[in] timeStamp The time the event occurred. + * @return True if the event was consumed. */ - void EmitChildAddedSignal( Actor& child ); + bool EmitHitTestResultSignal(Integration::Point point, Vector2 hitPointLocal, uint32_t timeStamp); /** - * @brief Emits the ChildRemoved signal for this actor - * @param[in] child The child actor that has been removed + * @copydoc DevelActor::HitTestResultSignal() */ - void EmitChildRemovedSignal( Actor& child ); + Dali::Actor::TouchEventSignalType& HitTestResultSignal() + { + return mHitTestResultSignal; + } /** * @copydoc DevelActor::InterceptTouchedSignal() @@ -1550,51 +1498,17 @@ public: /** * @copydoc DevelActor::ChildAddedSignal */ - DevelActor::ChildChangedSignalType& ChildAddedSignal() - { - return mChildAddedSignal; - } + DevelActor::ChildChangedSignalType& ChildAddedSignal(); /** * @copydoc DevelActor::ChildRemovedSignal */ - DevelActor::ChildChangedSignalType& ChildRemovedSignal() - { - return mChildRemovedSignal; - } + DevelActor::ChildChangedSignalType& ChildRemovedSignal(); /** * @copydoc DevelActor::ChildOrderChangedSignal */ - DevelActor::ChildOrderChangedSignalType& ChildOrderChangedSignal() - { - return mChildOrderChangedSignal; - } - - /** - * Connects a callback function with the object's signals. - * @param[in] object The object providing the signal. - * @param[in] tracker Used to disconnect the signal. - * @param[in] signalName The signal to connect to. - * @param[in] functor A newly allocated FunctorDelegate. - * @return True if the signal was connected. - * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor. - */ - static bool DoConnectSignal( BaseObject* object, - ConnectionTrackerInterface* tracker, - const std::string& signalName, - FunctorDelegate* functor ); - - /** - * Performs actions as requested using the action name. - * @param[in] object The object on which to perform the action. - * @param[in] actionName The action to perform. - * @param[in] attributes The attributes with which to perfrom this action. - * @return true if the action was done. - */ - static bool DoAction( BaseObject* object, - const std::string& actionName, - const Property::Map& attributes ); + DevelActor::ChildOrderChangedSignalType& ChildOrderChangedSignal(); public: // For Animation @@ -1603,15 +1517,16 @@ public: * For use in derived classes. * This should only be called by Animation, when the actor is resized using Animation::Resize(). */ - virtual void OnSizeAnimation( Animation& animation, const Vector3& targetSize ) + virtual void OnSizeAnimation(Animation& animation, const Vector3& targetSize) { } protected: - enum DerivedType { - BASIC, LAYER, ROOT_LAYER + BASIC, + LAYER, + ROOT_LAYER }; /** @@ -1620,12 +1535,12 @@ protected: * @param[in] derivedType The derived type of actor (if any). * @param[in] reference to the node */ - Actor( DerivedType derivedType, const SceneGraph::Node& node ); + Actor(DerivedType derivedType, const SceneGraph::Node& node); /** * Second-phase constructor. Must be called immediately after creating a new Actor; */ - void Initialize( void ); + void Initialize(void); /** * A reference counted object may only be deleted by calling Unreference() @@ -1635,16 +1550,10 @@ protected: /** * Called on a child during Add() when the parent actor is connected to the Scene. * @param[in] parentDepth The depth of the parent in the hierarchy. + * @param[in] layer3DParentsCount The number of 3d layers in the hierarchy. + * @param[in] notify Emits notification if set to true. */ - void ConnectToScene( uint32_t parentDepth ); - - /** - * Helper for ConnectToScene, to recursively connect a tree of actors. - * This is atomic i.e. not interrupted by user callbacks. - * @param[in] depth The depth in the hierarchy of the actor - * @param[out] connectionList On return, the list of connected actors which require notification. - */ - void RecursiveConnectToScene( ActorContainer& connectionList, uint32_t depth ); + void ConnectToScene(uint32_t parentDepth, uint32_t layer3DParentsCount, bool notify); /** * Connect the Node associated with this Actor to the scene-graph. @@ -1653,20 +1562,15 @@ protected: /** * Helper for ConnectToScene, to notify a connected actor through the public API. + * @param[in] notify Emits notification if set to true. */ - void NotifyStageConnection(); + void NotifyStageConnection(bool notify); /** * Called on a child during Remove() when the actor was previously on the Stage. + * @param[in] notify Emits notification if set to true. */ - void DisconnectFromStage(); - - /** - * Helper for DisconnectFromStage, to recursively disconnect a tree of actors. - * This is atomic i.e. not interrupted by user callbacks. - * @param[out] disconnectionList On return, the list of disconnected actors which require notification. - */ - void RecursiveDisconnectFromStage( ActorContainer& disconnectionList ); + void DisconnectFromStage(bool notify); /** * Disconnect the Node associated with this Actor from the scene-graph. @@ -1675,8 +1579,9 @@ protected: /** * Helper for DisconnectFromStage, to notify a disconnected actor through the public API. + * @param[in] notify Emits notification if set to true. */ - void NotifyStageDisconnection(); + void NotifyStageDisconnection(bool notify); /** * When the Actor is OnScene, checks whether the corresponding Node is connected to the scene graph. @@ -1692,58 +1597,48 @@ public: */ void RebuildDepthTree(); -protected: - - /** - * Traverse the actor tree, inserting actors into the depth tree in sibling order. - * @param[in] sceneGraphNodeDepths A vector capturing the nodes and their depth index - * @param[in,out] depthIndex The current depth index (traversal index) - */ - void DepthTraverseActorTree( OwnerPointer& sceneGraphNodeDepths, int32_t& depthIndex ); - public: - // Default property extensions from Object /** * @copydoc Dali::Internal::Object::SetDefaultProperty() */ - void SetDefaultProperty( Property::Index index, const Property::Value& propertyValue ) override; + void SetDefaultProperty(Property::Index index, const Property::Value& propertyValue) override; /** * @copydoc Dali::Internal::Object::SetSceneGraphProperty() */ - void SetSceneGraphProperty( Property::Index index, const PropertyMetadata& entry, const Property::Value& value ) override; + void SetSceneGraphProperty(Property::Index index, const PropertyMetadata& entry, const Property::Value& value) override; /** * @copydoc Dali::Internal::Object::GetDefaultProperty() */ - Property::Value GetDefaultProperty( Property::Index index ) const override; + Property::Value GetDefaultProperty(Property::Index index) const override; /** * @copydoc Dali::Internal::Object::GetDefaultPropertyCurrentValue() */ - Property::Value GetDefaultPropertyCurrentValue( Property::Index index ) const override; + Property::Value GetDefaultPropertyCurrentValue(Property::Index index) const override; /** * @copydoc Dali::Internal::Object::OnNotifyDefaultPropertyAnimation() */ - void OnNotifyDefaultPropertyAnimation( Animation& animation, Property::Index index, const Property::Value& value, Animation::Type animationType ) override; + void OnNotifyDefaultPropertyAnimation(Animation& animation, Property::Index index, const Property::Value& value, Animation::Type animationType) override; /** * @copydoc Dali::Internal::Object::GetSceneObjectAnimatableProperty() */ - const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty( Property::Index index ) const override; + const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty(Property::Index index) const override; /** * @copydoc Dali::Internal::Object::GetSceneObjectInputProperty() */ - const PropertyInputImpl* GetSceneObjectInputProperty( Property::Index index ) const override; + const PropertyInputImpl* GetSceneObjectInputProperty(Property::Index index) const override; /** * @copydoc Dali::Internal::Object::GetPropertyComponentIndex() */ - int32_t GetPropertyComponentIndex( Property::Index index ) const override; + int32_t GetPropertyComponentIndex(Property::Index index) const override; /** * @copydoc Dali::Internal::Object::IsAnimationPossible() @@ -1757,10 +1652,7 @@ public: * Retrieve the actor's node. * @return The node used by this actor */ - const SceneGraph::Node& GetNode() const - { - return *static_cast( mUpdateObject ); - } + const SceneGraph::Node& GetNode() const; /** * @copydoc Dali::DevelActor::Raise() @@ -1785,20 +1677,19 @@ public: /** * @copydoc Dali::DevelActor::RaiseAbove() */ - void RaiseAbove( Internal::Actor& target ); + void RaiseAbove(Internal::Actor& target); /** * @copydoc Dali::DevelActor::LowerBelow() */ - void LowerBelow( Internal::Actor& target ); + void LowerBelow(Internal::Actor& target); public: - /** * Sets the scene which this actor is added to. * @param[in] scene The scene */ - void SetScene( Scene& scene ) + void SetScene(Scene& scene) { mScene = &scene; } @@ -1812,8 +1703,12 @@ public: return *mScene; } -private: + LayoutDirection::Type GetLayoutDirection() const + { + return mLayoutDirection; + } +private: struct SendMessage { enum Type @@ -1823,29 +1718,17 @@ private: }; }; - struct AnimatedSizeFlag - { - enum Type - { - CLEAR = 0, - WIDTH = 1, - HEIGHT = 2, - DEPTH = 4 - }; - }; - - struct Relayouter; - // Remove default constructor and copy constructor - Actor() = delete; - Actor( const Actor& ) = delete; - Actor& operator=( const Actor& rhs ) = delete; + Actor() = delete; + Actor(const Actor&) = delete; + Actor& operator=(const Actor& rhs) = delete; /** - * Set the actors parent. + * Set the actor's parent. * @param[in] parent The new parent. + * @param[in] notify Emits notification if set to true. Default is true. */ - void SetParent( Actor* parent ); + void SetParent(ActorParent* parent, bool notify = true); /** * For use in derived classes, called after Initialize() @@ -1876,7 +1759,7 @@ private: * For use in external (CustomActor) derived classes. * This is called after the atomic ConnectToScene() traversal has been completed. */ - virtual void OnSceneConnectionExternal( int depth ) + virtual void OnSceneConnectionExternal(int depth) { } @@ -1892,7 +1775,7 @@ private: * For use in derived classes; this is called after Add() has added a child. * @param[in] child The child that was added. */ - virtual void OnChildAdd( Actor& child ) + virtual void OnChildAdd(Actor& child) { } @@ -1900,7 +1783,7 @@ private: * For use in derived classes; this is called after Remove() has attempted to remove a child( regardless of whether it succeeded or not ). * @param[in] child The child that was removed. */ - virtual void OnChildRemove( Actor& child ) + virtual void OnChildRemove(Actor& child) { } @@ -1908,7 +1791,7 @@ private: * For use in derived classes. * This is called after SizeSet() has been called. */ - virtual void OnSizeSet( const Vector3& targetSize ) + virtual void OnSizeSet(const Vector3& targetSize) { } @@ -1918,7 +1801,7 @@ private: * @param[out] value Is set with the cached value of the property if found. * @return True if value set, false otherwise. */ - bool GetCachedPropertyValue( Property::Index index, Property::Value& value ) const; + bool GetCachedPropertyValue(Property::Index index, Property::Value& value) const; /** * @brief Retrieves the current value of a default property from the scene-graph. @@ -1926,67 +1809,76 @@ private: * @param[out] value Is set with the current scene-graph value of the property * @return True if value set, false otherwise. */ - bool GetCurrentPropertyValue( Property::Index index, Property::Value& value ) const; + bool GetCurrentPropertyValue(Property::Index index, Property::Value& value) const; /** - * @brief Ensure the relayouter is allocated + * Retrieve the parent object of an Actor. + * @return The parent object, or NULL if the Actor does not have a parent. */ - Relayouter& EnsureRelayouter(); + Object* GetParentObject() const override + { + return static_cast(mParent); + } /** - * @brief Apply the size set policy to the input size + * @brief Get the current position of the actor in screen coordinates. * - * @param[in] size The size to apply the policy to - * @return Return the adjusted size + * @return Returns the screen position of actor */ - Vector2 ApplySizeSetPolicy( const Vector2& size ); + const Vector2 GetCurrentScreenPosition() const; /** - * Retrieve the parent object of an Actor. - * @return The parent object, or NULL if the Actor does not have a parent. + * Sets the visibility flag of an actor. + * @param[in] visible The new visibility flag. + * @param[in] sendMessage Whether to send a message to the update thread or not. */ - Object* GetParentObject() const override - { - return mParent; - } + void SetVisibleInternal(bool visible, SendMessage::Type sendMessage); /** - * Set Sibling order - * @param[in] order The sibling order this Actor should be. It will place - * the actor at this index in it's parent's child array. + * @copydoc ActorParent::SetSiblingOrderOfChild */ - void SetSiblingOrder( uint32_t order); + void SetSiblingOrderOfChild(Actor& child, uint32_t order) override; /** - * Get Sibling order - * @return the order of this actor amongst it's siblings + * @copydoc ActorParent::GetSiblingOrderOfChild */ - uint32_t GetSiblingOrder() const; + uint32_t GetSiblingOrderOfChild(const Actor& child) const override; /** - * Request that the stage rebuilds the actor depth indices. + * @copydoc ActorParent::RaiseChild */ - void RequestRebuildDepthTree(); + void RaiseChild(Actor& child) override; /** - * @brief Get the current position of the actor in screen coordinates. - * - * @return Returns the screen position of actor + * @copydoc ActorParent::LowerChild */ - const Vector2 GetCurrentScreenPosition() const; + void LowerChild(Actor& child) override; /** - * Sets the visibility flag of an actor. - * @param[in] visible The new visibility flag. - * @param[in] sendMessage Whether to send a message to the update thread or not. + * @copydoc ActorParent::RaiseChildToTop */ - void SetVisibleInternal( bool visible, SendMessage::Type sendMessage ); + void RaiseChildToTop(Actor& child) override; + + /** + * @copydoc ActorParent::LowerChildToBottom + */ + void LowerChildToBottom(Actor& child) override; + + /** + * @copydoc ActorParent::RaiseChildAbove + */ + void RaiseChildAbove(Actor& child, Actor& target) override; + + /** + * @copydoc ActorParent::LowerChildBelow() + */ + void LowerChildBelow(Actor& child, Actor& target) override; /** * Set whether a child actor inherits it's parent's layout direction. Default is to inherit. * @param[in] inherit - true if the actor should inherit layout direction, false otherwise. */ - void SetInheritLayoutDirection( bool inherit ); + void SetInheritLayoutDirection(bool inherit); /** * Returns whether the actor inherits it's parent's layout direction. @@ -1998,107 +1890,101 @@ private: } /** - * @brief Propagates layout direction recursively. - * @param[in] actor The actor for seting layout direction. - * @param[in] direction New layout direction. + * @brief Sets the update area hint of an actor. + * @param [in] updateAreaHint The update area hint. */ - void InheritLayoutDirectionRecursively( ActorPtr actor, Dali::LayoutDirection::Type direction, bool set = false ); - - /** - * @brief Sets the update size hint of an actor. - * @param [in] updateSizeHint The update size hint. - */ - void SetUpdateSizeHint( const Vector2& updateSizeHint ); + void SetUpdateAreaHint(const Vector4& updateAreaHint); protected: - - Scene* mScene; ///< The scene the actor is added to - - Actor* mParent; ///< Each actor (except the root) can have one parent - ActorContainer* mChildren; ///< Container of referenced actors, lazily initialized - RendererContainer* mRenderers; ///< Renderer container - - Vector3* mParentOrigin; ///< NULL means ParentOrigin::DEFAULT. ParentOrigin is non-animatable - Vector3* mAnchorPoint; ///< NULL means AnchorPoint::DEFAULT. AnchorPoint is non-animatable - - Relayouter* mRelayoutData; ///< Struct to hold optional collection of relayout variables - - ActorGestureData* mGestureData; ///< Optional Gesture data. Only created when actor requires gestures + ActorParentImpl mParentImpl; ///< Implementation of ActorParent; + ActorSizer mSizer; ///< Implementation for managing actor size + ActorParent* mParent; ///< Each actor (except the root) can have one parent + Scene* mScene; ///< The scene the actor is added to + RendererContainer* mRenderers; ///< Renderer container + Vector3* mParentOrigin; ///< NULL means ParentOrigin::DEFAULT. ParentOrigin is non-animatable + Vector3* mAnchorPoint; ///< NULL means AnchorPoint::DEFAULT. AnchorPoint is non-animatable + ActorGestureData* mGestureData; ///< Optional Gesture data. Only created when actor requires gestures // Signals - Dali::Actor::TouchEventSignalType mInterceptTouchedSignal; - Dali::Actor::TouchEventSignalType mTouchedSignal; - Dali::Actor::HoverSignalType mHoveredSignal; - Dali::Actor::WheelEventSignalType mWheelEventSignal; - Dali::Actor::OnSceneSignalType mOnSceneSignal; - Dali::Actor::OffSceneSignalType mOffSceneSignal; - Dali::Actor::OnRelayoutSignalType mOnRelayoutSignal; - DevelActor::VisibilityChangedSignalType mVisibilityChangedSignal; - Dali::Actor::LayoutDirectionChangedSignalType mLayoutDirectionChangedSignal; - DevelActor::ChildChangedSignalType mChildAddedSignal; - DevelActor::ChildChangedSignalType mChildRemovedSignal; - DevelActor::ChildOrderChangedSignalType mChildOrderChangedSignal; - - Quaternion mTargetOrientation; ///< Event-side storage for orientation - Vector4 mTargetColor; ///< Event-side storage for color - Vector3 mTargetSize; ///< Event-side storage for size (not a pointer as most actors will have a size) - Vector3 mTargetPosition; ///< Event-side storage for position (not a pointer as most actors will have a position) - Vector3 mTargetScale; ///< Event-side storage for scale - Vector3 mAnimatedSize; ///< Event-side storage for size animation - Vector2 mTouchDelegateArea; ///< touch delegate area - - std::string mName; ///< Name of the actor - uint32_t mSortedDepth; ///< The sorted depth index. A combination of tree traversal and sibling order. - int16_t mDepth; ///< The depth in the hierarchy of the actor. Only 32,767 levels of depth are supported - uint16_t mUseAnimatedSize; ///< Whether the size is animated. - - const bool mIsRoot : 1; ///< Flag to identify the root actor - const bool mIsLayer : 1; ///< Flag to identify that this is a layer - bool mIsOnScene : 1; ///< Flag to identify whether the actor is on-scene - bool mSensitive : 1; ///< Whether the actor emits touch event signals - bool mLeaveRequired : 1; ///< Whether a touch event signal is emitted when the a touch leaves the actor's bounds - bool mKeyboardFocusable : 1; ///< Whether the actor should be focusable by keyboard navigation - bool mOnSceneSignalled : 1; ///< Set to true before OnSceneConnection signal is emitted, and false before OnSceneDisconnection - bool mInsideOnSizeSet : 1; ///< Whether we are inside OnSizeSet - bool mInheritPosition : 1; ///< Cached: Whether the parent's position should be inherited. - bool mInheritOrientation : 1; ///< Cached: Whether the parent's orientation should be inherited. - bool mInheritScale : 1; ///< Cached: Whether the parent's scale should be inherited. - bool mPositionUsesAnchorPoint : 1; ///< Cached: Whether the position uses the anchor point or not. - bool mVisible : 1; ///< Cached: Whether the actor is visible or not. - bool mInheritLayoutDirection : 1; ///< Whether the actor inherits the layout direction from parent. - bool mCaptureAllTouchAfterStart : 1; ///< Whether the actor should capture all touch after touch starts even if the motion moves outside of the actor area. - LayoutDirection::Type mLayoutDirection : 2; ///< Layout direction, Left to Right or Right to Left. - DrawMode::Type mDrawMode : 3; ///< Cached: How the actor and its children should be drawn - ColorMode mColorMode : 3; ///< Cached: Determines whether mWorldColor is inherited - ClippingMode::Type mClippingMode : 3; ///< Cached: Determines which clipping mode (if any) to use. + Dali::Actor::TouchEventSignalType mInterceptTouchedSignal; + Dali::Actor::TouchEventSignalType mTouchedSignal; + Dali::Actor::HoverSignalType mHoveredSignal; + Dali::Actor::WheelEventSignalType mWheelEventSignal; + Dali::Actor::OnSceneSignalType mOnSceneSignal; + Dali::Actor::OffSceneSignalType mOffSceneSignal; + Dali::Actor::OnRelayoutSignalType mOnRelayoutSignal; + DevelActor::VisibilityChangedSignalType mVisibilityChangedSignal; + Dali::Actor::LayoutDirectionChangedSignalType mLayoutDirectionChangedSignal; + Dali::Actor::TouchEventSignalType mHitTestResultSignal; + + Quaternion mTargetOrientation; ///< Event-side storage for orientation + Vector4 mTargetColor; ///< Event-side storage for color + Vector3 mTargetPosition; ///< Event-side storage for position (not a pointer as most actors will have a position) + Vector3 mTargetScale; ///< Event-side storage for scale + Rect mTouchAreaOffset; ///< touch area offset (left, right, bottom, top) + + ConstString mName; ///< Name of the actor + uint32_t mSortedDepth; ///< The sorted depth index. A combination of tree traversal and sibling order. + int16_t mDepth; ///< The depth in the hierarchy of the actor. Only 32,767 levels of depth are supported + + int16_t mLayer3DParentsCount; ///< The number of layer with 3D behaviour in ancestors include this. It will be 0 if actor is not on scene. + + const bool mIsRoot : 1; ///< Flag to identify the root actor + const bool mIsLayer : 1; ///< Flag to identify that this is a layer + bool mIsOnScene : 1; ///< Flag to identify whether the actor is on-scene + bool mSensitive : 1; ///< Whether the actor emits touch event signals + bool mLeaveRequired : 1; ///< Whether a touch event signal is emitted when the a touch leaves the actor's bounds + bool mKeyboardFocusable : 1; ///< Whether the actor should be focusable by keyboard navigation + bool mKeyboardFocusableChildren : 1; ///< Whether the children of this actor can be focusable by keyboard navigation. + bool mTouchFocusable : 1; ///< Whether the actor should be focusable by touch + bool mOnSceneSignalled : 1; ///< Set to true before OnSceneConnection signal is emitted, and false before OnSceneDisconnection + bool mInheritPosition : 1; ///< Cached: Whether the parent's position should be inherited. + bool mInheritOrientation : 1; ///< Cached: Whether the parent's orientation should be inherited. + bool mInheritScale : 1; ///< Cached: Whether the parent's scale should be inherited. + bool mPositionUsesAnchorPoint : 1; ///< Cached: Whether the position uses the anchor point or not. + bool mVisible : 1; ///< Cached: Whether the actor is visible or not. + bool mInheritLayoutDirection : 1; ///< Whether the actor inherits the layout direction from parent. + bool mCaptureAllTouchAfterStart : 1; ///< Whether the actor should capture all touch after touch starts even if the motion moves outside of the actor area. + bool mIsBlendEquationSet : 1; ///< Flag to identify whether the Blend equation is set + bool mNeedGesturePropagation : 1; ///< Whether the parent listens for gesture events or not + bool mUserInteractionEnabled : 1; ///< Whether the actor should be enabled user interaction. + bool mAllowOnlyOwnTouch : 1; ///< whether the actor will only receive own touch. it only receives touches that started from itself. + LayoutDirection::Type mLayoutDirection : 2; ///< Layout direction, Left to Right or Right to Left. + DrawMode::Type mDrawMode : 3; ///< Cached: How the actor and its children should be drawn + ColorMode mColorMode : 3; ///< Cached: Determines whether mWorldColor is inherited + ClippingMode::Type mClippingMode : 3; ///< Cached: Determines which clipping mode (if any) to use. + DevelBlendEquation::Type mBlendEquation : 16; ///< Cached: Determines which blend equation will be used to render renderers. private: - - static ActorContainer mNullChildren; ///< Empty container (shared by all actors, returned by GetChildren() const) + static ActorContainer mNullChildren; ///< Empty container (shared by all actors, returned by GetChildren() const) struct PropertyHandler; + struct SiblingHandler; + + friend class ActorParentImpl; // Allow impl to call private methods on actor + friend class ActorSizer; // Allow sizer to call private methods on actor }; } // namespace Internal // Helpers for public-api forwarding methods -inline Internal::Actor& GetImplementation( Dali::Actor& actor ) +inline Internal::Actor& GetImplementation(Dali::Actor& actor) { - DALI_ASSERT_ALWAYS( actor && "Actor handle is empty" ); + DALI_ASSERT_ALWAYS(actor && "Actor handle is empty"); BaseObject& handle = actor.GetBaseObject(); - return static_cast< Internal::Actor& >( handle ); + return static_cast(handle); } -inline const Internal::Actor& GetImplementation( const Dali::Actor& actor ) +inline const Internal::Actor& GetImplementation(const Dali::Actor& actor) { - DALI_ASSERT_ALWAYS( actor && "Actor handle is empty" ); + DALI_ASSERT_ALWAYS(actor && "Actor handle is empty"); const BaseObject& handle = actor.GetBaseObject(); - return static_cast< const Internal::Actor& >( handle ); + return static_cast(handle); } } // namespace Dali