{
TestCustomActor::TestCustomActor()
-: CustomActorImpl( ActorFlags( REQUIRES_TOUCH_EVENTS | REQUIRES_WHEEL_EVENTS | REQUIRES_HOVER_EVENTS | DISABLE_SIZE_NEGOTIATION ) ),
+: CustomActorImpl( ActorFlags( DISABLE_SIZE_NEGOTIATION ) ),
mDaliProperty( Property::INVALID_INDEX ),
mSizeSet( Vector3::ZERO ),
mTargetSize( Vector3::ZERO ),
}
TestCustomActor::TestCustomActor(bool nego)
-: CustomActorImpl( ActorFlags( REQUIRES_TOUCH_EVENTS | REQUIRES_WHEEL_EVENTS | REQUIRES_HOVER_EVENTS ) ),
+: CustomActorImpl( ActorFlags() ),
mDaliProperty( Property::INVALID_INDEX ),
mSizeSet( Vector3::ZERO ),
mTargetSize( Vector3::ZERO ),
mTargetSize = targetSize;
AddToCallStacks("OnSizeAnimation");
}
-bool TestCustomActor::OnHoverEvent(const HoverEvent& event)
-{
- AddToCallStacks("OnHoverEvent");
- return true;
-}
-bool TestCustomActor::OnWheelEvent(const WheelEvent& event)
-{
- AddToCallStacks("OnWheelEvent");
- return true;
-}
-bool TestCustomActor::OnKeyEvent(const KeyEvent& event)
-{
- AddToCallStacks("OnKeyEvent");
- return true;
-}
void TestCustomActor::OnKeyInputFocusGained()
{
AddToCallStacks("OnKeyInputFocusGained");
void OnPropertySet( Dali::Property::Index index, Dali::Property::Value propertyValue ) override;
void OnSizeSet(const Dali::Vector3& targetSize) override;
void OnSizeAnimation(Dali::Animation& animation, const Dali::Vector3& targetSize) override;
- bool OnHoverEvent(const Dali::HoverEvent& event) override;
- bool OnWheelEvent(const Dali::WheelEvent& event) override;
- bool OnKeyEvent(const Dali::KeyEvent& event) override;
virtual void OnKeyInputFocusGained();
virtual void OnKeyInputFocusLost();
Dali::Vector3 GetNaturalSize() override;
* Constructor
*/
SimpleTestCustomActor()
- : CustomActorImpl( ActorFlags( REQUIRES_TOUCH_EVENTS | DISABLE_SIZE_NEGOTIATION ) )
+ : CustomActorImpl( ActorFlags( DISABLE_SIZE_NEGOTIATION ) )
{
}
void OnSizeAnimation(Dali::Animation& animation, const Dali::Vector3& targetSize) override
{
}
- bool OnHoverEvent(const Dali::HoverEvent& event) override
- {
- return true;
- }
- bool OnWheelEvent(const Dali::WheelEvent& event) override
- {
- return true;
- }
- bool OnKeyEvent(const Dali::KeyEvent& event) override
- {
- return true;
- }
virtual void OnKeyInputFocusGained()
{
}
virtual void OnKeyInputFocusLost()
{
}
-
Dali::Vector3 GetNaturalSize() override
{
return Dali::Vector3( 0.0f, 0.0f, 0.0f );
END_TEST;
}
-int UtcDaliCustomActorOnHoverEvent(void)
-{
- TestApplication application;
- tet_infoline("Testing Dali::CustomActor::OnHoverEvent()");
-
- Test::TestCustomActor custom = Test::TestCustomActor::New();
- DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
-
- // set size for custom actor
- custom.SetProperty( Actor::Property::SIZE, Vector2( 100, 100 ) );
- // add the custom actor to stage
- application.GetScene().Add( custom );
- custom.ResetCallStack();
-
- // Render and notify a couple of times
- application.SendNotification();
- application.Render();
- application.SendNotification();
- application.Render();
-
- // simulate a hover event
- Dali::Integration::Point point;
- point.SetState( PointState::MOTION );
- point.SetScreenPosition( Vector2( 1, 1 ) );
- Dali::Integration::HoverEvent event;
- event.AddPoint( point );
- application.ProcessEvent( event );
-
- DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
- DALI_TEST_EQUALS( "OnHoverEvent", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliCustomActorOnWheelEvent(void)
-{
- TestApplication application;
- tet_infoline("Testing Dali::CustomActor::OnWheelEvent()");
-
- Test::TestCustomActor custom = Test::TestCustomActor::New();
- DALI_TEST_EQUALS( 0, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
-
- // set size for custom actor
- custom.SetProperty( Actor::Property::SIZE, Vector2( 100, 100 ) );
- // add the custom actor to stage
- application.GetScene().Add( custom );
- custom.ResetCallStack();
-
- // Render and notify a couple of times
- application.SendNotification();
- application.Render();
- application.SendNotification();
- application.Render();
-
- // simulate a wheel event
- Vector2 screenCoordinates( 10.0f, 10.0f );
- Integration::WheelEvent event( Integration::WheelEvent::MOUSE_WHEEL, 0, 0u, screenCoordinates, 1, 1000u );
- application.ProcessEvent( event );
-
- DALI_TEST_EQUALS( 1, (int)(custom.GetMethodsCalled().size()), TEST_LOCATION );
- DALI_TEST_EQUALS( "OnWheelEvent", custom.GetMethodsCalled()[ 0 ], TEST_LOCATION );
- END_TEST;
-}
-
int UtcDaliCustomActorImplOnPropertySet(void)
{
TestApplication application;
{ }
virtual bool OnHoverEvent(const HoverEvent& event)
{ return false; }
- virtual bool OnKeyEvent(const KeyEvent& event)
- { return false; }
virtual bool OnWheelEvent(const WheelEvent& event)
{ return false; }
virtual void OnRelayout( const Vector2& size, RelayoutContainer& container )
typedef Signal< void ()> SignalType;
typedef Signal< void (float)> SignalTypeFloat;
- MyTestCustomActor() : CustomActorImpl( ActorFlags( REQUIRES_TOUCH_EVENTS ) )
+ MyTestCustomActor() : CustomActorImpl( ActorFlags() )
{ }
virtual ~MyTestCustomActor()
virtual void OnSizeAnimation(Animation& animation, const Vector3& targetSize)
{
}
- virtual bool OnHoverEvent(const HoverEvent& event)
- {
- return true;
- }
- virtual bool OnWheelEvent(const WheelEvent& event)
- {
- return true;
- }
- virtual bool OnKeyEvent(const KeyEvent& event)
- {
- return true;
- }
virtual void OnKeyInputFocusGained()
{
}
typedef Signal< void ()> SignalType;
typedef Signal< void (float)> SignalTypeFloat;
- MyTestCustomActor() : CustomActorImpl( ActorFlags( REQUIRES_TOUCH_EVENTS ) )
+ MyTestCustomActor() : CustomActorImpl( ActorFlags() )
{ }
virtual ~MyTestCustomActor()
virtual void OnSizeAnimation(Animation& animation, const Vector3& targetSize)
{
}
- virtual bool OnHoverEvent(const HoverEvent& event)
- {
- return true;
- }
- virtual bool OnWheelEvent(const WheelEvent& event)
- {
- return true;
- }
- virtual bool OnKeyEvent(const KeyEvent& event)
- {
- return true;
- }
virtual void OnKeyInputFocusGained()
{
}
bool Actor::GetTouchRequired() const
{
- return !mTouchedSignal.Empty() || mDerivedRequiresTouch;
+ return !mTouchedSignal.Empty();
}
bool Actor::GetHoverRequired() const
{
- return !mHoveredSignal.Empty() || mDerivedRequiresHover;
+ return !mHoveredSignal.Empty();
}
bool Actor::GetWheelEventRequired() const
{
- return !mWheelEventSignal.Empty() || mDerivedRequiresWheelEvent;
+ return !mWheelEventSignal.Empty();
}
bool Actor::IsHittable() const
consumed = mHoveredSignal.Emit( handle, event );
}
- if( !consumed )
- {
- // Notification for derived classes
- consumed = OnHoverEvent( event );
- }
-
return consumed;
}
consumed = mWheelEventSignal.Emit( handle, event );
}
- if( !consumed )
- {
- // Notification for derived classes
- consumed = OnWheelEvent( event );
- }
-
return consumed;
}
mSensitive( true ),
mLeaveRequired( false ),
mKeyboardFocusable( false ),
- mDerivedRequiresTouch( false ),
- mDerivedRequiresHover( false ),
- mDerivedRequiresWheelEvent( false ),
mOnSceneSignalled( false ),
mInsideOnSizeSet( false ),
mInheritPosition( true ),
{
}
- /**
- * For use in derived classes.
- * This is only called if mDerivedRequiresHover is true, and the hover-signal was not consumed.
- * @param[in] event The hover event.
- * @return True if the event should be consumed.
- */
- virtual bool OnHoverEvent( const HoverEvent& event )
- {
- return false;
- }
-
- /**
- * For use in derived classes.
- * This is only called if the wheel signal was not consumed.
- * @param[in] event The wheel event.
- * @return True if the event should be consumed.
- */
- virtual bool OnWheelEvent( const WheelEvent& event )
- {
- return false;
- }
-
/**
* @brief Retrieves the cached event side value of a default property.
* @param[in] index The index of the property
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 mDerivedRequiresTouch : 1; ///< Whether the derived actor type requires touch event signals
- bool mDerivedRequiresHover : 1; ///< Whether the derived actor type requires hover event signals
- bool mDerivedRequiresWheelEvent : 1; ///< Whether the derived actor type requires wheel event signals
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.
: Actor( Actor::BASIC, node ),
mImpl( &extension )
{
- mDerivedRequiresTouch = extension.RequiresTouchEvents();
- mDerivedRequiresHover = extension.RequiresHoverEvents();
- mDerivedRequiresWheelEvent = extension.RequiresWheelEvents();
SetRelayoutEnabled( extension.IsRelayoutEnabled() );
}
mImpl->OnSizeAnimation(animationHandle, targetSize);
}
- /**
- * @copydoc Internal::Actor::OnHoverEvent
- */
- virtual bool OnHoverEvent(const HoverEvent& event)
- {
- return mImpl->OnHoverEvent(event);
- }
-
- /**
- * @copydoc Internal::Actor::OnKeyEvent
- */
- virtual bool OnKeyEvent(const KeyEvent& event)
- {
- return mImpl->OnKeyEvent(event);
- }
-
- /**
- * @copydoc Internal::Actor::OnWheelEvent
- */
- virtual bool OnWheelEvent(const WheelEvent& event)
- {
- return mImpl->OnWheelEvent(event);
- }
-
/**
* @copydoc Internal::Actor::OnRelayout
*/
return mOwner;
}
-bool CustomActorImpl::RequiresTouchEvents() const
-{
- return ( mFlags & REQUIRES_TOUCH_EVENTS );
-}
-
-bool CustomActorImpl::RequiresHoverEvents() const
-{
- return ( mFlags & REQUIRES_HOVER_EVENTS );
-}
-
-bool CustomActorImpl::RequiresWheelEvents() const
-{
- return ( mFlags & REQUIRES_WHEEL_EVENTS );
-}
-
bool CustomActorImpl::IsRelayoutEnabled() const
{
return ( mFlags & DISABLE_SIZE_NEGOTIATION ) == 0;
*/
virtual void OnSizeAnimation(Animation& animation, const Vector3& targetSize) = 0;
- /**
- * @brief Called after a hover-event is received by the owning actor.
- *
- * @SINCE_1_0.0
- * @param[in] event The hover event
- * @return True if the event should be consumed
- * @note CustomActorImpl::REQUIRES_HOVER_EVENTS must be enabled during construction. See CustomActorImpl::CustomActorImpl( ActorFlags flags ).
- */
- virtual bool OnHoverEvent(const HoverEvent& event) = 0;
-
- /**
- * @brief Called after a key-event is received by the actor that has had its focus set.
- *
- * @SINCE_1_0.0
- * @param[in] event The Key Event
- * @return True if the event should be consumed
- */
- virtual bool OnKeyEvent(const KeyEvent& event) = 0;
-
- /**
- * @brief Called after a wheel-event is received by the owning actor.
- *
- * @SINCE_1_0.0
- * @param[in] event The wheel event
- * @return True if the event should be consumed
- * @note CustomActorImpl::REQUIRES_WHEEL_EVENTS must be enabled during construction. See CustomActorImpl::CustomActorImpl( ActorFlags flags ).
- */
- virtual bool OnWheelEvent(const WheelEvent& event) = 0;
-
/**
* @brief Called after the size negotiation has been finished for this control.
*
{
ACTOR_BEHAVIOUR_DEFAULT = 0, ///< Use to provide default behaviour (size negotiation is on, event callbacks are not called). @SINCE_1_2_10
DISABLE_SIZE_NEGOTIATION = 1 << 0, ///< True if control does not need size negotiation, i.e. it can be skipped in the algorithm @SINCE_1_0.0
- REQUIRES_TOUCH_EVENTS = 1 << 1, ///< True if the OnTouchEvent() callback is required. @SINCE_1_0.0
- REQUIRES_HOVER_EVENTS = 1 << 2, ///< True if the OnHoverEvent() callback is required. @SINCE_1_0.0
- REQUIRES_WHEEL_EVENTS = 1 << 3, ///< True if the OnWheelEvent() callback is required. @SINCE_1_0.0
LAST_ACTOR_FLAG ///< Special marker for last actor flag @SINCE_1_0.0
};
*/
Internal::CustomActor* GetOwner() const;
- /**
- * @brief Returns whether the OnTouchEvent() callback is required.
- * @SINCE_1_0.0
- * @return True if the OnTouchEvent() callback is required
- * @note Called when ownership of the CustomActorImpl is passed to a CustomActor.
- */
- bool RequiresTouchEvents() const;
-
- /**
- * @brief Returns whether the OnHoverEvent() callback is required.
- * @SINCE_1_0.0
- * @return True if the OnHoverEvent() callback is required
- * @note Called when ownership of the CustomActorImpl is passed to a CustomActor.
- */
- bool RequiresHoverEvents() const;
-
- /**
- * @brief Returns whether the OnWheelEvent() callback is required.
- * @SINCE_1_0.0
- * @return True if the OnWheelEvent() callback is required
- * @note Called when ownership of the CustomActorImpl is passed to a CustomActor.
- */
- bool RequiresWheelEvents() const;
-
/**
* @brief Returns whether relayout is enabled.
* @SINCE_1_0.0
private:
Internal::CustomActor* mOwner; ///< Internal owner of this custom actor implementation
- ActorFlags mFlags :ACTOR_FLAG_COUNT; ///< ActorFlags flags to determine behaviour
+ ActorFlags mFlags; ///< ActorFlags flags to determine behaviour
};
/**