#define DALI_INTERNAL_ACTOR_H
/*
- * Copyright (c) 2021 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.
#include <string>
// INTERNAL INCLUDES
+#include <dali/public-api/actors/actor.h>
+#include <dali/public-api/common/dali-common.h>
+#include <dali/public-api/common/vector-wrapper.h>
+#include <dali/public-api/events/gesture.h>
+#include <dali/public-api/math/viewport.h>
+#include <dali/public-api/object/ref-object.h>
+#include <dali/public-api/size-negotiation/relayout-container.h>
+
#include <dali/devel-api/actors/actor-devel.h>
#include <dali/devel-api/rendering/renderer-devel.h>
+
+#include <dali/integration-api/events/touch-event-integ.h>
+
#include <dali/internal/common/const-string.h>
#include <dali/internal/common/internal-constants.h>
#include <dali/internal/common/memory-pool-object-allocator.h>
#include <dali/internal/event/actors/actor-parent-impl.h>
#include <dali/internal/event/actors/actor-parent.h>
#include <dali/internal/event/actors/actor-renderer-container.h>
+#include <dali/internal/event/actors/actor-sizer.h>
#include <dali/internal/event/common/object-impl.h>
#include <dali/internal/event/common/stage-def.h>
#include <dali/internal/update/nodes/node-declarations.h>
-#include <dali/public-api/actors/actor.h>
-#include <dali/public-api/common/dali-common.h>
-#include <dali/public-api/common/vector-wrapper.h>
-#include <dali/public-api/events/gesture.h>
-#include <dali/public-api/math/viewport.h>
-#include <dali/public-api/object/ref-object.h>
-#include <dali/public-api/size-negotiation/relayout-container.h>
namespace Dali
{
{
public:
/**
- * @brief Struct to hold an actor and a dimension
- */
- struct ActorDimensionPair
- {
- /**
- * @brief Constructor
- *
- * @param[in] newActor The actor to assign
- * @param[in] newDimension The dimension to assign
- */
- ActorDimensionPair(Actor* newActor, Dimension::Type newDimension)
- : actor(newActor),
- dimension(newDimension)
- {
- }
-
- /**
- * @brief Equality operator
- *
- * @param[in] lhs The left hand side argument
- * @param[in] rhs The right hand side argument
- */
- bool operator==(const ActorDimensionPair& rhs)
- {
- return (actor == rhs.actor) && (dimension == rhs.dimension);
- }
-
- Actor* actor; ///< The actor to hold
- Dimension::Type dimension; ///< The dimension to hold
- };
-
- using ActorDimensionStack = std::vector<ActorDimensionPair>;
-
-public:
- /**
* Create a new actor.
* @return A smart-pointer to the newly allocated Actor.
*/
void SetSize(const Vector2& size);
/**
- * Sets the update size for an actor.
- *
- * @param[in] size The size to set.
- */
- void SetSizeInternal(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);
-
- /**
* Set the width component of the Actor's size.
* @param [in] width The new width component.
*/
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.
}
/**
+ * 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);
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);
-
- /**
* @brief Calculate the size for a child
*
* @param[in] child The child actor to calculate the size for
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;
-
- /**
* @copydoc Dali::Actor::SetResizePolicy()
*/
void SetResizePolicy(ResizePolicy::Type policy, Dimension::Type dimension = Dimension::ALL_DIMENSIONS);
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;
-
- /**
* @brief Set the size negotiation relayout enabled on this actor
*
* @param[in] relayoutEnabled Boolean to enable or disable relayout
/**
* @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
/**
* @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
/**
* @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
*/
/**
* @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
*/
/**
* @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
/**
* @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
bool RelayoutDependentOnDimension(Dimension::Type dimension, Dimension::Type dependentDimension);
/**
- * @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;
-
- /**
* @brief Set the padding for a dimension
*
* @param[in] padding Padding for the dimension. X = start (e.g. left, bottom), y = end (e.g. right, top)
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;
-
- /**
* @brief Return the amount of size allocated for relayout
*
* May include padding
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);
-
- /**
* @brief Flag the actor as having it's layout dimension negotiated.
*
* @param[in] negotiated The status of the flag to set.
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.
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
}
/**
+ * 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.
* @return True if intercept touch events are required.
*/
*/
bool IsHittable() const
{
- return IsSensitive() && IsVisible() && (GetCurrentWorldColor().a > FULLY_TRANSPARENT) && IsNodeConnected();
+ return (IsUserInteractionEnabled()) && IsSensitive() && IsVisible() && (GetCurrentWorldColor().a > FULLY_TRANSPARENT) && IsNodeConnected();
}
/**
void EmitLayoutDirectionChangedSignal(LayoutDirection::Type type);
/**
+ * 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.
+ */
+ bool EmitHitTestResultSignal(Integration::Point point, Vector2 hitPointLocal, uint32_t timeStamp);
+
+ /**
+ * @copydoc DevelActor::HitTestResultSignal()
+ */
+ Dali::Actor::TouchEventSignalType& HitTestResultSignal()
+ {
+ return mHitTestResultSignal;
+ }
+
+ /**
* @copydoc DevelActor::InterceptTouchedSignal()
*/
Dali::Actor::TouchEventSignalType& InterceptTouchedSignal()
};
};
- 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;
bool GetCurrentPropertyValue(Property::Index index, Property::Value& value) const;
/**
- * @brief Ensure the relayouter is allocated
- */
- Relayouter& EnsureRelayouter();
-
- /**
- * @brief Apply the size set policy to the input size
- *
- * @param[in] size The size to apply the policy to
- * @return Return the adjusted size
- */
- Vector2 ApplySizeSetPolicy(const Vector2& size);
-
- /**
* Retrieve the parent object of an Actor.
* @return The parent object, or NULL if the Actor does not have a parent.
*/
protected:
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
- Relayouter* mRelayoutData; ///< Struct to hold optional collection of relayout variables
ActorGestureData* mGestureData; ///< Optional Gesture data. Only created when actor requires gestures
// Signals
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 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
Rect<int> 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
- uint16_t mUseAnimatedSize; ///< Whether the size is animated.
+ 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
const bool mIsRoot : 1; ///< Flag to identify the root actor
const bool mIsLayer : 1; ///< Flag to identify that this is a layer
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 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 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.
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
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