#include <dali/public-api/animation/active-constraint-declarations.h>
#include <dali/public-api/actors/actor-enumerations.h>
#include <dali/public-api/actors/draw-mode.h>
-#include <dali/public-api/object/constrainable.h>
-#include <dali/public-api/signals/dali-signal-v2.h>
+#include <dali/public-api/object/handle.h>
+#include <dali/public-api/signals/dali-signal.h>
-namespace Dali DALI_IMPORT_API
+namespace Dali
{
namespace Internal DALI_INTERNAL
class Quaternion;
class Layer;
struct Radian;
-class ShaderEffect;
struct KeyEvent;
struct TouchEvent;
+struct HoverEvent;
struct MouseWheelEvent;
struct Vector2;
struct Vector3;
*
* <h3>Multi-Touch Events:</h3>
*
- * Touch events are received via signals; see Actor::TouchedSignal() for more details.
+ * Touch or hover events are received via signals; see Actor::TouchedSignal() and Actor::HoveredSignal() for more details.
*
* <i>Hit Testing Rules Summary:</i>
*
- * - An actor is only hittable if the actor's touch signal has a connection.
+ * - An actor is only hittable if the actor's touch or hover signal has a connection.
* - An actor is only hittable when it is between the camera's near and far planes.
* - If an actor is made insensitive, then the actor and its children are not hittable; see IsSensitive()
* - If an actor's visibility flag is unset, then none of its children are hittable either; see IsVisible()
* // Depth-first traversal within current layer, visiting parent first
*
* // Check whether current actor should be hit-tested
- * IF ( TOUCH-SIGNAL-NOT-EMPTY &&
+ * IF ( ( TOUCH-SIGNAL-NOT-EMPTY || HOVER-SIGNAL-NOT-EMPTY ) &&
* ACTOR-HAS-NON-ZERO-SIZE &&
* ACTOR-WORLD-COLOR-IS-NOT-TRANSPARENT )
* {
* also be considered a Stencil Actor.
* Non-renderable actors can be hit regardless of whether a stencil actor is hit or not.
*
- * <i>Touch Event Delivery:</i>
+ * <i>Touch or hover Event Delivery:</i>
*
* - Delivery
- * - The hit actor's touch signal is emitted first; if it is not consumed by any of the listeners,
- * the parent's touch signal is emitted, and so on.
+ * - The hit actor's touch or hover signal is emitted first; if it is not consumed by any of the listeners,
+ * the parent's touch or hover signal is emitted, and so on.
* - The following pseudocode shows the delivery mechanism:
* @code
* EMIT-TOUCH-SIGNAL( ACTOR )
* }
* }
* }
+ *
+ * EMIT-HOVER-SIGNAL( ACTOR )
+ * {
+ * IF ( HOVER-SIGNAL-NOT-EMPTY )
+ * {
+ * // Only do the emission if hover signal of actor has connections.
+ * CONSUMED = HOVERED-SIGNAL( HOVER-EVENT )
+ * }
+ *
+ * IF ( NOT-CONSUMED )
+ * {
+ * // If event is not consumed then deliver it to the parent unless we reach the root actor
+ * IF ( ACTOR-PARENT )
+ * {
+ * EMIT-HOVER-SIGNAL( ACTOR-PARENT )
+ * }
+ * }
+ * }
* @endcode
* - If there are several touch points, then the delivery is only to the first touch point's hit
- * actor (and its parents). There will be NO touch signal delivery for the hit actors of the
+ * actor (and its parents). There will be NO touch or hover signal delivery for the hit actors of the
* other touch points.
* - The local coordinates are from the top-left (0.0f, 0.0f, 0.5f) of the hit actor.
*
* - Leave State
* - A "Leave" state is set when the first point exits the bounds of the previous first point's
* hit actor (primary hit actor).
- * - When this happens, the last primary hit actor's touch signal is emitted with a "Leave" state
+ * - When this happens, the last primary hit actor's touch or hover signal is emitted with a "Leave" state
* (only if it requires leave signals); see SetLeaveRequired().
*
* - Interrupted State
- * - If a system event occurs which interrupts the touch processing, then the last primary hit
- * actor's touch signals are emitted with an "Interrupted" state.
- * - If the last primary hit actor, or one of its parents, is no longer touchable, then its
- * touch signals are also emitted with an "Interrupted" state.
+ * - If a system event occurs which interrupts the touch or hover processing, then the last primary hit
+ * actor's touch or hover signals are emitted with an "Interrupted" state.
+ * - If the last primary hit actor, or one of its parents, is no longer touchable or hoverable, then its
+ * touch or hover signals are also emitted with an "Interrupted" state.
* - If the consumed actor on touch-down is not the same as the consumed actor on touch-up, then
* touch signals are also emitted from the touch-down actor with an "Interrupted" state.
+ * - If the consumed actor on hover-start is not the same as the consumed actor on hover-finished, then
+ * hover signals are also emitted from the hover-started actor with an "Interrupted" state.
* <h3>Key Events:</h3>
*
* Key events are received by an actor once set to grab key events, only one actor can be set as focused.
*
* @nosubgrouping
+ *
+ * Signals
+ * | %Signal Name | Method |
+ * |-------------------|------------------------------|
+ * | touched | @ref TouchedSignal() |
+ * | hovered | @ref HoveredSignal() |
+ * | mouse-wheel-event | @ref MouseWheelEventSignal() |
+ * | on-stage | @ref OnStageSignal() |
+ * | off-stage | @ref OffStageSignal() |
+ *
+ * Actions
+ * | %Action Name | %Actor method called |
+ * |-------------------|------------------------------|
+ * | show | %SetVisible( true ) |
+ * | hide | %SetVisible( false ) |
*/
-class DALI_IMPORT_API Actor : public Constrainable
+class DALI_IMPORT_API Actor : public Handle
{
public:
// Typedefs
-
- typedef SignalV2< bool (Actor, const TouchEvent&)> TouchSignalV2; ///< Touch signal type
- typedef SignalV2< bool (Actor, const MouseWheelEvent&) > MouseWheelEventSignalV2;///< Mousewheel signal type
- typedef SignalV2< void (Actor, const Vector3&) > SetSizeSignalV2; ///< SetSize signal type
- typedef SignalV2< void (Actor) > OnStageSignalV2; ///< Stage connection signal type
- typedef SignalV2< void (Actor) > OffStageSignalV2; ///< Stage disconnection signal type
+ typedef Signal< bool (Actor, const TouchEvent&)> TouchSignalType; ///< Touch signal type
+ typedef Signal< bool (Actor, const HoverEvent&)> HoverSignalType; ///< Hover signal type
+ typedef Signal< bool (Actor, const MouseWheelEvent&) > MouseWheelEventSignalType;///< Mousewheel signal type
+ typedef Signal< void (Actor) > OnStageSignalType; ///< Stage connection signal type
+ typedef Signal< void (Actor) > OffStageSignalType; ///< Stage disconnection signal type
/// @name Properties
/** @{ */
static const Property::Index COLOR_MODE; ///< name "color-mode", type STRING
static const Property::Index POSITION_INHERITANCE; ///< name "position-inheritance", type STRING
static const Property::Index DRAW_MODE; ///< name "draw-mode", type STRING
- /** @} */
-
- /// @name Signals
- /** @{ */
- static const char* const SIGNAL_TOUCHED; ///< name "touched", @see TouchedSignal()
- static const char* const SIGNAL_MOUSE_WHEEL_EVENT; ///< name "mouse-wheel-event", @see MouseWheelEventSignal()
- static const char* const SIGNAL_SET_SIZE; ///< name "set-size", @see SetSizeSignal()
- static const char* const SIGNAL_ON_STAGE; ///< name "on-stage", @see OnStageSignal()
- static const char* const SIGNAL_OFF_STAGE; ///< name "off-stage", @see OffStageSignal()
- /** @} */
-
- /// @name Actions
- /** @{ */
- static const char* const ACTION_SHOW; ///< name "show", @see SetVisible()
- static const char* const ACTION_HIDE; ///< name "hide", @see SetVisible()
+ static const Property::Index SIZE_MODE; ///< name "size-mode", type STRING
+ static const Property::Index SIZE_MODE_FACTOR; ///< name "size-mode-factor", type VECTOR3
/** @} */
// Creation
Actor& operator=(const Actor& rhs);
/**
- * @brief This method is defined to allow assignment of the NULL value,
- * and will throw an exception if passed any other value.
- *
- * Assigning to NULL is an alias for Reset().
- * @param [in] rhs A NULL pointer
- * @return A reference to this handle
- */
- Actor& operator=(BaseHandle::NullType* rhs);
-
- /**
* @brief Retrieve the Actor's name.
*
* @pre The Actor has been initialized.
void Add(Actor child);
/**
+ * @brief Inserts a child Actor to this actor's list of children at the given index
+ *
+ * NOTE! if the child already has a parent, it will be removed from old parent
+ * and reparented to this actor. This may change childs position, color,
+ * scale etc as it now inherits them from this actor
+ * @pre This Actor (the parent) has been initialized.
+ * @pre The child actor has been initialized.
+ * @pre The child actor is not the same as the parent actor.
+ * @pre The actor is not the Root actor
+ * @param [in] index of actor to insert before
+ * @param [in] child The child.
+ * @post The child will be referenced by its parent. This means that the child will be kept alive,
+ * even if the handle passed into this method is reset or destroyed.
+ * @post If the index is greater than the current child count, it will be ignored and added at the end.
+ * @post This may invalidate ActorContainer iterators.
+ */
+ void Insert(unsigned int index, Actor child);
+
+ /**
* @brief Removes a child Actor from this Actor.
*
* If the actor was not a child of this actor, this is a no-op.
* @brief Retrieve the actor's size.
*
* @pre The actor has been initialized.
+ * @note This return is the value that was set using SetSize or the target size of an animation
+ * @return The actor's current size.
+ */
+ Vector3 GetSize() const;
+
+ /**
+ * @brief Retrieve the actor's size.
+ *
+ * @pre The actor has been initialized.
* @note This property can be animated; the return value may not match the value written with SetSize().
* @return The actor's current size.
*/
Vector3 GetCurrentSize() const;
/**
+ * Return the natural size of the actor.
+ *
+ * Deriving classes stipulate the natural size and by default an actor has a ZERO natural size.
+ *
+ * @return The actor's natural size
+ */
+ Vector3 GetNaturalSize() const;
+
+ /**
* @brief Sets the position of the actor.
*
* The Actor's z position will be set to 0.0f.
bool IsScaleInherited() const;
/**
+ * @brief Defines how a child actor's size is affected by its parent's size.
+ *
+ * The default is to ignore the parent's size and use the size property of this actor.
+ *
+ * If USE_OWN_SIZE is used, this option is bypassed and the actor's size
+ * property is used.
+ *
+ * If SIZE_EQUAL_TO_PARENT is used, this actor's size will be equal to that
+ * of its parent. The actor's size property is ignored.
+ *
+ * If SIZE_RELATIVE_TO_PARENT is used, this actor's size will be based on
+ * its parent's size by multiplying the parent size by
+ * SizeModeFactor.
+ *
+ * If SIZE_FIXED_OFFSET_FROM_PARENT is used, this actor's size will be based on
+ * its parent's size plus SizeModeFactor.
+ *
+ * @pre The Actor has been initialized.
+ * @param[in] mode The size relative to parent mode to use.
+ */
+ void SetSizeMode(const SizeMode mode);
+
+ /**
+ * @brief Returns the actor's mode for modifying its size relative to its parent.
+ *
+ * @pre The Actor has been initialized.
+ * @return The mode used.
+ */
+ SizeMode GetSizeMode() const;
+
+ /**
+ * @brief Sets the relative to parent size factor of the actor.
+ *
+ * This factor is only used when SizeMode is set to either:
+ * SIZE_RELATIVE_TO_PARENT or SIZE_FIXED_OFFSET_FROM_PARENT.
+ * This actor's size is set to the actor's parent size multipled by or added to this factor,
+ * depending on SideMode (See SetSizeMode).
+ *
+ * @pre The Actor has been initialized.
+ * @param [in] factor A Vector3 representing the relative factor to be applied to each axis.
+ */
+ void SetSizeModeFactor(const Vector3& factor);
+
+ /**
+ * @brief Retrieve the relative to parent size factor of the actor.
+ *
+ * @pre The Actor has been initialized.
+ * @return The Actor's current relative size factor.
+ */
+ Vector3 GetSizeModeFactor() const;
+
+ /**
* @brief Retrieves the world-matrix of the actor.
*
* @note The actor will not have a world-matrix, unless it has previously been added to the stage.
*/
Vector4 GetCurrentWorldColor() const;
- // Shader Effects
-
- /**
- * @deprecated call Set/RemoveShaderEffectRecursively if you want to apply the same shader for a tree of actors
- *
- * @param [in] ignored
- */
- void SetInheritShaderEffect(bool ignored);
-
- /**
- * @deprecated functionality no longer supported
- *
- * @return false
- */
- bool GetInheritShaderEffect() const;
-
- /**
- * @deprecated you need to call RenderableActor::SetShaderEffect
- *
- * @param [in] effect The shader effect.
- */
- void SetShaderEffect(ShaderEffect effect);
-
- /**
- * @deprecated you need to call RenderableActor::GetShaderEffect
- *
- * @return The shader effect
- */
- ShaderEffect GetShaderEffect() const;
-
- /**
- * @deprecated you need to call RenderableActor::GetShaderEffect
- */
- void RemoveShaderEffect();
-
/**
* @brief Set how the actor and its children should be drawn.
*
// Input Handling
/**
- * @brief Sets whether an actor should emit touch event signals; @see SignalTouched().
+ * @brief Sets whether an actor should emit touch or hover signals; see SignalTouch() and SignalHover().
*
- * An actor is sensitive by default, which means that as soon as an application connects to the SignalTouched(),
- * the touch event signal will be emitted.
+ * An actor is sensitive by default, which means that as soon as an application connects to the SignalTouch(),
+ * the touch event signal will be emitted, and as soon as an application connects to the SignalHover(), the
+ * hover event signal will be emitted.
*
- * If the application wishes to temporarily disable the touch event signal emission, then they can do so by calling:
+ * If the application wishes to temporarily disable the touch or hover event signal emission, then they can do so by calling:
* @code
* actor.SetSensitive(false);
* @endcode
*
- * Then, to re-enable the touch event signal emission, the application should call:
+ * Then, to re-enable the touch or hover event signal emission, the application should call:
* @code
* actor.SetSensitive(true);
* @endcode
*
- * @see SignalTouched().
+ * @see @see SignalTouch() and SignalHover().
* @note If an actor's sensitivity is set to false, then it's children will not be hittable either.
* This is regardless of the individual sensitivity values of the children i.e. an actor will only be
* hittable if all of its parents have sensitivity set to true.
* @pre The Actor has been initialized.
- * @param[in] sensitive true to enable emission of the touch event signals, false otherwise.
+ * @param[in] sensitive true to enable emission of the touch or hover event signals, false otherwise.
*/
void SetSensitive(bool sensitive);
/**
- * @brief Query whether an actor emits touch event signals.
+ * @brief Query whether an actor emits touch or hover event signals.
*
* @note If an actor is not sensitive, then it's children will not be hittable either.
* This is regardless of the individual sensitivity values of the children i.e. an actor will only be
* hittable if all of its parents have sensitivity set to true.
* @pre The Actor has been initialized.
- * @return true, if emission of touch event signals is enabled, false otherwise.
+ * @return true, if emission of touch or hover event signals is enabled, false otherwise.
*/
bool IsSensitive() const;
bool ScreenToLocal(float& localX, float& localY, float screenX, float screenY) const;
/**
- * @brief Sets whether the actor should receive a notification when touch motion events leave
+ * @brief Sets whether the actor should receive a notification when touch or hover motion events leave
* the boundary of the actor.
*
* @note By default, this is set to false as most actors do not require this.
- * @note Need to connect to the SignalTouch to actually receive this event.
+ * @note Need to connect to the SignalTouch or SignalHover to actually receive this event.
*
* @pre The Actor has been initialized.
* @param[in] required Should be set to true if a Leave event is required
void SetLeaveRequired(bool required);
/**
- * @brief This returns whether the actor requires touch events whenever touch motion events leave
+ * @brief This returns whether the actor requires touch or hover events whenever touch or hover motion events leave
* the boundary of the actor.
*
* @pre The Actor has been initialized.
* @pre The Actor has been initialized.
* @return The signal to connect to.
*/
- TouchSignalV2& TouchedSignal();
+ TouchSignalType& TouchedSignal();
/**
- * @brief This signal is emitted when mouse wheel event is received.
+ * @brief This signal is emitted when hover input is received.
*
* A callback of the following type may be connected:
* @code
- * bool YourCallbackName(Actor actor, const MouseWheelEvent& event);
+ * bool YourCallbackName(Actor actor, const HoverEvent& event);
* @endcode
- * The return value of True, indicates that the mouse wheel event should be consumed.
+ * The return value of True, indicates that the hover event should be consumed.
* Otherwise the signal will be emitted on the next sensitive parent of the actor.
* @pre The Actor has been initialized.
* @return The signal to connect to.
*/
- MouseWheelEventSignalV2& MouseWheelEventSignal();
+ HoverSignalType& HoveredSignal();
/**
- * @brief Signal to indicate when the actor's size is set by application code.
+ * @brief This signal is emitted when mouse wheel event is received.
*
- * This signal is emitted when actors size is being <b>set</b> by application code.
- * This signal is <b>not</b> emitted when size is animated
- * Note! GetCurrentSize might not return this same size as the set size message may still be queued
* A callback of the following type may be connected:
* @code
- * void YourCallback(Actor actor, const Vector3& newSize);
+ * bool YourCallbackName(Actor actor, const MouseWheelEvent& event);
* @endcode
+ * The return value of True, indicates that the mouse wheel event should be consumed.
+ * Otherwise the signal will be emitted on the next sensitive parent of the actor.
* @pre The Actor has been initialized.
* @return The signal to connect to.
*/
- SetSizeSignalV2& SetSizeSignal();
+ MouseWheelEventSignalType& MouseWheelEventSignal();
/**
* @brief This signal is emitted after the actor has been connected to the stage.
*
* @return The signal
*/
- OnStageSignalV2& OnStageSignal();
+ OnStageSignalType& OnStageSignal();
/**
* @brief This signal is emitted after the actor has been disconnected from the stage.
*
* @return The signal
*/
- OffStageSignalV2& OffStageSignal();
+ OffStageSignalType& OffStageSignal();
public: // Dynamics
*
* @return The number of DynamicsJoint objects added to this actor
*/
- const int GetNumberOfJoints() const;
+ int GetNumberOfJoints() const;
/**
* @brief Get a joint by index.
* actor.Unparent() will be called, followed by actor.Reset().
* @param[in,out] actor A handle to an actor, or an empty handle.
*/
-void UnparentAndReset( Actor& actor );
+ DALI_IMPORT_API void UnparentAndReset( Actor& actor );
} // namespace Dali