#include <dali/public-api/common/vector-wrapper.h>
#include <dali/public-api/object/property.h>
#include <dali/public-api/object/ref-object.h>
+#include <dali/public-api/actors/actor-enumerations.h>
-namespace Dali DALI_IMPORT_API
+namespace Dali
{
namespace Internal DALI_INTERNAL
class Animation;
class CustomActor;
class CustomActorImpl;
+class RelayoutContainer;
struct KeyEvent;
struct TouchEvent;
+struct HoverEvent;
struct MouseWheelEvent;
+struct Vector2;
struct Vector3;
+
/**
* @brief Pointer to Dali::CustomActorImpl object.
*/
virtual void OnSizeSet(const Vector3& targetSize) = 0;
/**
- * @brief Called when the owning actor's size is animated e.g. using Animation::Resize().
+ * @brief Called when the owning actor's size is animated e.g. using Animation::AnimateTo( Property( actor, Actor::Property::SIZE ), ... ).
*
* @param[in] animation The object which is animating the owning actor.
* @param[in] targetSize The target size. Note that this target size may not match the size returned via Actor::GetSize().
virtual bool OnTouchEvent(const TouchEvent& event) = 0;
/**
+ * @brief Called after a hover-event is received by the owning actor.
+ *
+ * @note This must be enabled during construction; see CustomActorImpl::SetRequiresHoverEvents(bool)
+ * @param[in] event The hover event.
+ * @return True if the event should be consumed.
+ */
+ virtual bool OnHoverEvent(const HoverEvent& event) = 0;
+
+ /**
* @brief Called after a key-event is received by the actor that has had its focus set.
*
* @param[in] event the Key Event
virtual bool OnMouseWheelEvent(const MouseWheelEvent& event) = 0;
/**
- * @brief Called when this actor gains keyboard focus.
+ * @brief Called after the size negotiation has been finished for this control.
+ *
+ * The control is expected to assign this given size to itself/its children.
+ *
+ * Should be overridden by derived classes if they need to layout
+ * actors differently after certain operations like add or remove
+ * actors, resize or after changing specific properties.
+ *
+ * Note! As this function is called from inside the size negotiation algorithm, you cannot
+ * call RequestRelayout (the call would just be ignored)
+ *
+ * @param[in] size The allocated size.
+ * @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 ) = 0;
+
+ /**
+ * @brief Notification for deriving classes
+ *
+ * @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 ) = 0;
+
+ /**
+ * Return the natural size of the actor
+ *
+ * @return The actor's natural size
+ */
+ virtual Vector3 GetNaturalSize() = 0;
+
+ /**
+ * @brief Calculate the size for a child
+ *
+ * @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
+ */
+ virtual float CalculateChildSize( const Dali::Actor& child, Dimension::Type dimension ) = 0;
+
+ /**
+ * @brief This method is called during size negotiation when a height is required for a given width.
+ *
+ * Derived classes should override this if they wish to customize the height returned.
+ *
+ * @param width to use.
+ * @return the height based on the width.
+ */
+ virtual float GetHeightForWidth( float width ) = 0;
+
+ /**
+ * @brief This method is called during size negotiation when a width is required for a given height.
+ *
+ * Derived classes should override this if they wish to customize the width returned.
+ *
+ * @param height to use.
+ * @return the width based on the width.
+ */
+ virtual float GetWidthForHeight( float height ) = 0;
+
+ /**
+ * @brief Determine if this actor is dependent on it's children for relayout
*
+ * @param dimension The dimension(s) to check for
+ * @return Return if the actor is dependent on it's children
*/
- virtual void OnKeyInputFocusGained() = 0;
+ virtual bool RelayoutDependentOnChildren( Dimension::Type dimension = Dimension::ALL_DIMENSIONS ) = 0;
/**
- * @brief Called when this actor loses keyboard focus.
+ * @brief Virtual method to notify deriving classes that relayout dependencies have been
+ * met and the size for this object is about to be calculated for the given dimension
+ *
+ * @param dimension The dimension that is about to be calculated
*/
- virtual void OnKeyInputFocusLost() = 0;
+ virtual void OnCalculateRelayoutSize( Dimension::Type dimension ) = 0;
/**
- * @brief Called to find a child by an alias.
+ * @brief Virtual method to notify deriving classes that the size for a dimension
+ * has just been negotiated
*
- * If an alias for a child exists, return the child otherwise return an empty handle.
- * For example 'previous' could return the last selected child.
- * @pre The Actor has been initialized.
- * @param[in] actorAlias the name of the actor to find
- * @return A handle to the actor if found, or an empty handle if not.
+ * @param[in] size The new size for the given dimension
+ * @param[in] dimension The dimension that was just negotiated
*/
- virtual Dali::Actor GetChildByAlias(const std::string& actorAlias) = 0;
+ virtual void OnLayoutNegotiated( float size, Dimension::Type dimension ) = 0;
protected: // For derived classes
CustomActorImpl(bool requiresTouchEvents);
/**
+ * @brief Set whether the custom actor requires hover events.
+ * @param[in] requiresHoverEvents True if the OnHoverEvent() callback is required.
+ */
+ void SetRequiresHoverEvents(bool requiresHoverEvents);
+
+ /**
* @brief Set whether the custom actor requires mouse wheel events.
* @param[in] requiresMouseWheelEvents True if the OnMouseWheelEvent() callback is required.
*/
void SetRequiresMouseWheelEvents(bool requiresMouseWheelEvents);
+ /**
+ * @brief Request a relayout, which means performing a size negotiation on this actor, its parent and children (and potentially whole scene)
+ *
+ * This method can also be called from a derived class every time it needs a different size.
+ * At the end of event processing, the relayout process starts and
+ * all controls which requested Relayout will have their sizes (re)negotiated.
+ *
+ * @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();
+
+ /**
+ * @brief Calculate the size for a child using the base actor object
+ *
+ * @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 );
+
+ /**
+ * @brief Determine if this actor is dependent on it's children for relayout from the base class
+ *
+ * @param dimension The dimension(s) to check for
+ * @return Return if the actor is dependent on it's children
+ */
+ bool RelayoutDependentOnChildrenBase( Dimension::Type dimension = Dimension::ALL_DIMENSIONS );
+
public: // Not intended for application developers
/**
/**
* @brief Called when ownership of the CustomActorImpl is passed to a CustomActor.
+ * @return True if the OnHoverEvent() callback is required.
+ */
+ bool RequiresHoverEvents() const;
+
+ /**
+ * @brief Called when ownership of the CustomActorImpl is passed to a CustomActor.
* @return True if the OnMouseWheelEvent() callback is required.
*/
bool RequiresMouseWheelEvents() const;
Internal::CustomActor* mOwner; ///< Internal owner of this custom actor implementation
bool mRequiresTouchEvents; ///< Whether the OnTouchEvent() callback is required
+ bool mRequiresHoverEvents; ///< Whether the OnHoverEvent() callback is required
bool mRequiresMouseWheelEvents; ///< Whether the OnMouseWheelEvent() callback is required
};