{
Actor actor = Actor::New();
- actor.SetRelayoutEnabled( true );
-
actor.SetResizePolicy( widthPolicy, Dimension::WIDTH );
actor.SetResizePolicy( heightPolicy, Dimension::HEIGHT );
TestApplication application;
Actor actor = Actor::New();
- actor.SetRelayoutEnabled( true );
Internal::Actor& actorImpl = GetImplementation( actor );
Internal::RelayoutController* controller = Internal::RelayoutController::Get();
controller->RequestRelayout( actor );
- DALI_TEST_CHECK( actorImpl.IsLayoutDirty() );
+ DALI_TEST_CHECK( !actorImpl.IsLayoutDirty() );
END_TEST;
}
TestApplication application;
Actor actor = Actor::New();
- actor.SetRelayoutEnabled( true );
Internal::Actor& actorImpl = GetImplementation( actor );
// Request default enable (false)
controller->RequestRelayoutTree( actor );
- DALI_TEST_CHECK( actorImpl.IsLayoutDirty() );
+ DALI_TEST_CHECK( !actorImpl.IsLayoutDirty() );
END_TEST;
}
{ "position-inheritance", Actor::Property::POSITION_INHERITANCE, Property::STRING },
{ "draw-mode", Actor::Property::DRAW_MODE, Property::STRING },
{ "size-mode-factor", Actor::Property::SIZE_MODE_FACTOR, Property::VECTOR3 },
- { "relayout-enabled", Actor::Property::RELAYOUT_ENABLED, Property::BOOLEAN },
{ "width-resize-policy", Actor::Property::WIDTH_RESIZE_POLICY, Property::STRING },
{ "height-resize-policy", Actor::Property::HEIGHT_RESIZE_POLICY, Property::STRING },
{ "size-scale-policy", Actor::Property::SIZE_SCALE_POLICY, Property::STRING },
END_TEST;
}
-int UtcDaliRelayoutProperties_RelayoutEnabled(void)
-{
- TestApplication app;
-
- Actor actor = Actor::New();
-
- // Defaults
- DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::RELAYOUT_ENABLED ).Get< bool >(), false, TEST_LOCATION );
-
- // Set relayout disabled
- actor.SetProperty( Actor::Property::RELAYOUT_ENABLED, false );
-
- DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::RELAYOUT_ENABLED ).Get< bool >(), false, TEST_LOCATION );
-
- // Set relayout enabled
- actor.SetProperty( Actor::Property::RELAYOUT_ENABLED, true );
-
- DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::RELAYOUT_ENABLED ).Get< bool >(), true, TEST_LOCATION );
-
- END_TEST;
-}
-
int UtcDaliRelayoutProperties_ResizePolicies(void)
{
TestApplication app;
* Constructor
*/
TestCustomActor()
- : CustomActorImpl( true ), // requires touch
+ : CustomActorImpl( ActorFlags( REQUIRES_TOUCH_EVENTS | REQUIRES_MOUSE_WHEEL_EVENTS | REQUIRES_HOVER_EVENTS | DISABLE_SIZE_NEGOTIATION ) ),
mDaliProperty( Property::INVALID_INDEX ),
mSizeSet( Vector3::ZERO ),
mTargetSize( Vector3::ZERO )
{
- SetRequiresMouseWheelEvents(true);
- SetRequiresHoverEvents(true);
}
/**
* Constructor
*/
SimpleTestCustomActor()
- : CustomActorImpl( true ) // requires touch
+ : CustomActorImpl( ActorFlags( REQUIRES_TOUCH_EVENTS | DISABLE_SIZE_NEGOTIATION ) )
{
}
Actor stencil = ImageActor::New(Dali::BufferImage::WHITE() );
stencil.SetAnchorPoint( AnchorPoint::TOP_LEFT );
stencil.SetParentOrigin( ParentOrigin::TOP_LEFT );
- stencil.SetRelayoutEnabled( false );
stencil.SetSize( 50.0f, 50.0f );
stencil.SetDrawMode( DrawMode::STENCIL );
stencil.SetName( "stencil" );
// Create a renderable actor and add that to the layer
Actor layerHitActor = ImageActor::New();
- layerHitActor.SetRelayoutEnabled( false );
layerHitActor.SetSize( 100.0f, 100.0f );
layerHitActor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
layerHitActor.SetParentOrigin( ParentOrigin::TOP_LEFT );
Vector2 stageSize ( stage.GetSize() );
Actor parent = ImageActor::New();
- parent.SetRelayoutEnabled( false );
parent.SetSize( 100.0f, 100.0f );
parent.SetAnchorPoint(AnchorPoint::TOP_LEFT);
stage.Add(parent);
Actor actor = ImageActor::New();
- actor.SetRelayoutEnabled( false );
actor.SetSize( 100.0f, 100.0f );
actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
parent.Add(actor);
BufferImage img = BufferImage::New( 1,1 );
ImageActor actor = ImageActor::New( img );
- actor.SetRelayoutEnabled( false );
ShaderEffect effect = ShaderEffect::New( " ", " ", GEOMETRY_TYPE_IMAGE, ShaderEffect::HINT_GRID );
actor.SetShaderEffect( effect );
Vector2 initialImageSize(100, 50);
BufferImage image = BufferImage::New( initialImageSize.width, initialImageSize.height );
ImageActor actor = ImageActor::New( image );
- actor.SetRelayoutEnabled( false );
Stage::GetCurrent().Add(actor);
application.SendNotification();
// natural size is not used as setsize is called
DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), size, TEST_LOCATION );
- actor.SetToNaturalSize();
- application.SendNotification();
- application.Render(9);
- DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), Vector2( area.width, area.height ), TEST_LOCATION );
-
END_TEST;
}
Image image = ResourceImage::New("image.jpg");
ImageActor actor = ImageActor::New( image );
- actor.SetRelayoutEnabled( false );
Stage::GetCurrent().Add(actor);
application.SendNotification(); // Flush update messages
application.Render();
DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), size, TEST_LOCATION );
- actor.SetToNaturalSize();
- application.SendNotification();
- application.Render();
- DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), initialImageSize, TEST_LOCATION );
END_TEST;
}
attrs.SetSize( requestedSize.width, requestedSize.height );
Image image = ResourceImage::New("image.jpg", attrs);
ImageActor actor = ImageActor::New( image );
- actor.SetRelayoutEnabled( false );
Stage::GetCurrent().Add(actor);
application.SendNotification(); // Flush update messages
DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), requestedSize, TEST_LOCATION );
- // Test that setting a size on the actor can be 'undone' with SetNaturalSize()
- Vector2 size(200.0f, 200.0f);
- actor.SetSize(size);
-
- // flush the queue and render once
- application.SendNotification();
- application.Render();
- DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), size, TEST_LOCATION );
-
- actor.SetToNaturalSize();
- application.SendNotification();
- application.Render();
- DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), requestedSize, TEST_LOCATION );
END_TEST;
}
attrs.SetSize( requestedSize.width, requestedSize.height );
Image image = ResourceImage::New("image.jpg", attrs);
ImageActor actor = ImageActor::New( image );
- actor.SetRelayoutEnabled( false );
Stage::GetCurrent().Add(actor);
application.SendNotification(); // Flush update messages
// Ensure the actor size is kept
DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), size, TEST_LOCATION );
- actor.SetToNaturalSize();
- application.SendNotification();
- application.Render();
- // Ensure the actor size gets the new image's natural size
- DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), request2Size, TEST_LOCATION );
END_TEST;
}
attrs.SetSize( requestedSize.width, requestedSize.height );
Image image = ResourceImage::New("image.jpg", attrs);
ImageActor actor = ImageActor::New( image );
- actor.SetRelayoutEnabled( false );
Stage::GetCurrent().Add(actor);
application.SendNotification(); // Flush update messages
attrs.SetSize( requestedSize.width, requestedSize.height );
Image image = ResourceImage::New("image.jpg", attrs);
ImageActor actor = ImageActor::New( image );
- actor.SetRelayoutEnabled( false );
Stage::GetCurrent().Add(actor);
application.SendNotification(); // Flush update messages
attrs.SetSize( requestedSize.width, requestedSize.height );
Image image = ResourceImage::New("image.jpg", attrs);
ImageActor actor = ImageActor::New( image );
- actor.SetRelayoutEnabled( false );
Stage::GetCurrent().Add(actor);
application.SendNotification(); // Flush update messages
application.Render(); // Process LoadComplete
DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), Vector2(100, 100), TEST_LOCATION );
- // Use natural size - expect actor to change to pixel area
- actor.SetToNaturalSize();
- application.SendNotification(); // Process event messages
- application.Render(); // Process LoadComplete
- DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), Vector2(40, 40), TEST_LOCATION );
-
// Clearing pixel area should change actor size to image size
+ actor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
actor.ClearPixelArea();
application.SendNotification(); // Process event messages
application.Render(); // Process LoadComplete
Vector2 stageSize ( stage.GetSize() );
Actor parent = ImageActor::New();
- parent.SetRelayoutEnabled( false );
parent.SetSize(100.0f, 100.0f);
parent.SetAnchorPoint(AnchorPoint::TOP_LEFT);
stage.Add(parent);
Actor actor = ImageActor::New();
- actor.SetRelayoutEnabled( false );
actor.SetSize(100.0f, 100.0f);
actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
parent.Add(actor);
typedef Signal< void ()> SignalType;
typedef Signal< void (float)> SignalTypeFloat;
- MyTestCustomActor() : CustomActorImpl( true ) // requires touch
+ MyTestCustomActor() : CustomActorImpl( ActorFlags( REQUIRES_TOUCH_EVENTS ) )
{ }
virtual ~MyTestCustomActor()
DALI_PROPERTY( "position-inheritance", STRING, true, false, false, Dali::Actor::Property::POSITION_INHERITANCE )
DALI_PROPERTY( "draw-mode", STRING, true, false, false, Dali::Actor::Property::DRAW_MODE )
DALI_PROPERTY( "size-mode-factor", VECTOR3, true, false, false, Dali::Actor::Property::SIZE_MODE_FACTOR )
-DALI_PROPERTY( "relayout-enabled", BOOLEAN, true, false, false, Dali::Actor::Property::RELAYOUT_ENABLED )
DALI_PROPERTY( "width-resize-policy", STRING, true, false, false, Dali::Actor::Property::WIDTH_RESIZE_POLICY )
DALI_PROPERTY( "height-resize-policy", STRING, true, false, false, Dali::Actor::Property::HEIGHT_RESIZE_POLICY )
DALI_PROPERTY( "size-scale-policy", STRING, true, false, false, Dali::Actor::Property::SIZE_SCALE_POLICY )
}
}
+ // If calling SetResizePolicy, assume we want relayout enabled
+ SetRelayoutEnabled( true );
+
OnSetResizePolicy( policy, dimension );
// Trigger relayout on this control
break;
}
- case Dali::Actor::Property::RELAYOUT_ENABLED:
- {
- SetRelayoutEnabled( property.Get< bool >() );
- break;
- }
-
case Dali::Actor::Property::WIDTH_RESIZE_POLICY:
{
SetResizePolicy( Scripting::GetEnumeration< ResizePolicy::Type >( property.Get< std::string >().c_str(), ResizePolicy::TypeTable, ResizePolicy::TypeTableCount ), Dimension::WIDTH );
break;
}
- case Dali::Actor::Property::RELAYOUT_ENABLED:
- {
- value = IsRelayoutEnabled();
- break;
- }
-
case Dali::Actor::Property::WIDTH_RESIZE_POLICY:
{
value = Scripting::GetLinearEnumerationName< ResizePolicy::Type >( GetResizePolicy( Dimension::WIDTH ), ResizePolicy::TypeTable, ResizePolicy::TypeTableCount );
return 0.0f; // Default
}
-float Actor::ConstrainDimension( float size, Dimension::Type dimension )
+float Actor::ClampDimension( float size, Dimension::Type dimension )
{
const float minSize = GetMinimumSize( dimension );
const float maxSize = GetMaximumSize( dimension );
OnCalculateRelayoutSize( dimension );
// All dependencies checked, calculate the size and set negotiated flag
- const float newSize = ConstrainDimension( CalculateSize( dimension, allocatedSize ), dimension );
+ const float newSize = ClampDimension( CalculateSize( dimension, allocatedSize ), dimension );
SetNegotiatedDimension( newSize, dimension );
SetLayoutNegotiated( true, dimension );
}
}
-void Actor::RelayoutRequestTree()
-{
- Internal::RelayoutController* relayoutController = Internal::RelayoutController::Get();
- if( relayoutController )
- {
- Dali::Actor self( this );
- relayoutController->RequestRelayoutTree( self );
- }
-}
-
void Actor::PropagateRelayoutFlags()
{
Internal::RelayoutController* relayoutController = Internal::RelayoutController::Get();
Dimension::Type GetDimensionDependency( Dimension::Type dimension ) const;
/**
- * @copydoc Dali::Actor::SetRelayoutEnabled()
+ * @brief Set the size negotiation relayout enabled on this actor
+ *
+ * @param[in] relayoutEnabled Boolean to enable or disable relayout
*/
void SetRelayoutEnabled( bool relayoutEnabled );
/**
- * @copydoc Dali::Actor::IsRelayoutEnabled()
+ * @brief Return if relayout is enabled
+ *
+ * @return Return if relayout is enabled or not for this actor
*/
bool IsRelayoutEnabled() const;
*/
void RelayoutRequest( Dimension::Type dimension = Dimension::ALL_DIMENSIONS );
- /**
- * @brief Request to relayout of all actors in the sub-tree below the given actor.
- *
- * This flags the actor and all actors below it for relayout. The actual
- * relayout is performed at the end of the frame. This means that multiple calls to relayout
- * will not cause multiple relayouts to occur.
- */
- void RelayoutRequestTree();
-
/*
* @copydoc Dali::Actor::PropagateRelayoutFlags
*/
float CalculateSize( Dimension::Type dimension, const Vector2& maximumSize );
/**
- * @brief Constain a dimension given the relayout constraints on this actor
+ * @brief Clamp a dimension given the relayout constraints on this actor
*
* @param[in] size The size to constrain
* @param[in] dimension The dimension the size exists in
- * @return Return the constrained size
+ * @return Return the clamped size
*/
- float ConstrainDimension( float size, Dimension::Type dimension );
+ float ClampDimension( float size, Dimension::Type dimension );
/**
* Negotiate a dimension based on the size of the parent
mDerivedRequiresTouch = extension.RequiresTouchEvents();
mDerivedRequiresHover = extension.RequiresHoverEvents();
mDerivedRequiresMouseWheelEvent = extension.RequiresMouseWheelEvents();
+ SetRelayoutEnabled( extension.IsRelayoutEnabled() );
}
CustomActor::~CustomActor()
}
// set the actual image (normal or 9 patch) and natural size based on that
mImageAttachment->SetImage( newImage );
- SetNaturalSize();
+
+ RelayoutRequest();
}
ImagePtr ImageActor::GetImage()
return mImageAttachment->GetImage();
}
-void ImageActor::SetToNaturalSize()
-{
- mUsingNaturalSize = true;
-
- SetNaturalSize();
-}
-
void ImageActor::SetPixelArea( const PixelArea& pixelArea )
{
mImageAttachment->SetPixelArea( pixelArea );
- SetNaturalSize();
+ RelayoutRequest();
}
const ImageActor::PixelArea& ImageActor::GetPixelArea() const
{
mImageAttachment->ClearPixelArea();
- if( mUsingNaturalSize )
- {
- ImagePtr image = mImageAttachment->GetImage();
- if( image )
- {
- mInternalSetSize = true;
- SetSizeInternal( image->GetNaturalSize() );
- mInternalSetSize = false;
- }
- }
+ RelayoutRequest();
}
void ImageActor::SetStyle( Style style )
}
ImageActor::ImageActor()
-: RenderableActor(),
- mUsingNaturalSize(true),
- mInternalSetSize(false)
+: RenderableActor()
{
- // Size negotiate disabled by default, so turn it on for this actor
- SetRelayoutEnabled( true );
}
ImageActor::~ImageActor()
{
}
-void ImageActor::SetNaturalSize()
-{
- if( mUsingNaturalSize )
- {
- mInternalSetSize = true;
- SetSizeInternal( CalculateNaturalSize() );
- mInternalSetSize = false;
- }
-}
-
Vector3 ImageActor::GetNaturalSize() const
{
Vector2 naturalSize( CalculateNaturalSize() );
return size;
}
-void ImageActor::OnSizeSet( const Vector3& targetSize )
-{
- if( !mInternalSetSize )
- {
- mUsingNaturalSize = false;
- }
-}
-
-void ImageActor::OnSizeAnimation(Animation& animation, const Vector3& targetSize)
-{
- mUsingNaturalSize = false;
-}
-
void ImageActor::OnStageConnectionInternal()
{
}
ImagePtr GetImage();
/**
- * @copydoc Dali::ImageActor::SetToNaturalSize()
- */
- void SetToNaturalSize();
-
- /**
* @copydoc Dali::ImageActor::SetPixelArea()
*/
void SetPixelArea( const PixelArea& pixelArea );
private:
/**
- * Helper to set the actor to the image's natural size
- */
- void SetNaturalSize();
-
- /**
* Calculate the natural size of this image actor
*
* @return Return the natural size as a Vector2
Vector2 CalculateNaturalSize() const;
/**
- * From Actor.
- * This is called after SizeSet() has been called.
- */
- virtual void OnSizeSet( const Vector3& targetSize );
-
- /**
- * @copydoc Actor::OnSizeAnimation( Animation& animation, const Vector3& targetSize )
- */
- virtual void OnSizeAnimation(Animation& animation, const Vector3& targetSize);
-
- /**
* From Actor; used to trigger fade-in animations.
*/
virtual void OnStageConnectionInternal();
ImageAttachmentPtr mImageAttachment; ///< Used to display the image (holds a pointer to currently showed Image)
- // flags, compressed to bitfield (uses only 1 byte)
- bool mUsingNaturalSize:1; ///< True only when the actor is using
- bool mInternalSetSize:1; ///< True whilst setting size internally, false at all other times
-
};
} // namespace Internal
mTouchConsumed(false),
mHoverConsumed(false)
{
- // Size negotiate disabled by default, so turn it on for this actor
- SetRelayoutEnabled( true );
}
void Layer::OnInitialize()
// The stage owns the default layer
mRootLayer = Layer::NewRoot( *mLayerList, mUpdateManager, false/*not system-level*/ );
mRootLayer->SetName("RootLayer");
- mRootLayer->SetRelayoutEnabled( false ); // Exclude from size negotiation
// Create the default camera actor first; this is needed by the RenderTaskList
CreateDefaultCameraActor();
{
mRootLayer = Layer::NewRoot( *mLayerList, mEventThreadServices.GetUpdateManager(), true/*system layer*/ );
mRootLayer->SetName("SystemOverlayRoot");
- mRootLayer->SetRelayoutEnabled( false ); // Exclude from size negotiation
mRootLayer->SetSize( mSize.width, mSize.height );
}
}
output << ", Dirty: (" << ( GetImplementation( actor ).IsLayoutDirty( Dimension::WIDTH ) ? "TRUE" : "FALSE" ) << "," << ( GetImplementation( actor ).IsLayoutDirty( Dimension::HEIGHT ) ? "TRUE" : "FALSE" ) << ")";
output << ", Negotiated: (" << ( GetImplementation( actor ).IsLayoutNegotiated( Dimension::WIDTH ) ? "TRUE" : "FALSE" ) << "," << ( GetImplementation( actor ).IsLayoutNegotiated( Dimension::HEIGHT ) ? "TRUE" : "FALSE" ) << ")";
- output << ", Enabled: " << ( actor.IsRelayoutEnabled() ? "TRUE" : "FALSE" );
+ output << ", Enabled: " << ( GetImplementation( actor ).IsRelayoutEnabled() ? "TRUE" : "FALSE" );
output << ", (" << actor.GetObjectPtr() << ")" << std::endl;
{
// If parent is not in relayout we are at the top of a new sub-tree
Dali::Actor parent = actor.GetParent();
- if( !parent || !parent.IsRelayoutEnabled() )
+ if( !parent || !GetImplementation( parent ).IsRelayoutEnabled() )
{
AddRequest( actor );
}
return GetImplementation(*this).IsKeyboardFocusable();
}
-void Actor::SetRelayoutEnabled( bool enabled )
-{
- GetImplementation(*this).SetRelayoutEnabled( enabled );
-}
-
-bool Actor::IsRelayoutEnabled() const
-{
- return GetImplementation(*this).IsRelayoutEnabled();
-}
-
void Actor::SetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension )
{
GetImplementation(*this).SetResizePolicy( policy, dimension );
return GetImplementation(*this).GetRelayoutSize( dimension );
}
-void Actor::RelayoutRequestTree()
-{
- GetImplementation(*this).RelayoutRequestTree();
-}
-
void Actor::PropagateRelayoutFlags()
{
GetImplementation(*this).PropagateRelayoutFlags();
POSITION_INHERITANCE, ///< name "position-inheritance", type std::string
DRAW_MODE, ///< name "draw-mode", type std::string
SIZE_MODE_FACTOR, ///< name "size-mode-factor", type Vector3
- RELAYOUT_ENABLED, ///< name "relayout-enabled", type Boolean
WIDTH_RESIZE_POLICY, ///< name "width-resize-policy", type String
HEIGHT_RESIZE_POLICY, ///< name "height-resize-policy", type String
SIZE_SCALE_POLICY, ///< name "size-scale-policy", type String
// SIZE NEGOTIATION
/**
- * @brief Set if the actor should do relayout in size negotiation or not.
- *
- * @param[in] enabled Flag to specify if actor should do relayout or not.
- */
- void SetRelayoutEnabled( bool enabled );
-
- /**
- * @brief Is the actor included in relayout or not.
- *
- * @return Return if the actor is involved in size negotiation or not.
- */
- bool IsRelayoutEnabled() const;
-
- /**
* Set the resize policy to be used for the given dimension(s)
*
* @param[in] policy The resize policy to use
float GetRelayoutSize( Dimension::Type dimension ) const;
/**
- * @brief Request to relayout of all actors in the sub-tree below the given actor.
- *
- * This flags the actor and all actors below it for relayout. The actual
- * relayout is performed at the end of the frame. This means that multiple calls to relayout
- * will not cause multiple relayouts to occur.
- */
- void RelayoutRequestTree();
-
- /**
* @brief Force propagate relayout flags through the tree. This actor and all actors
* dependent on it will have their relayout flags reset.
*
{
}
-CustomActorImpl::CustomActorImpl(bool requiresTouchEvents)
+CustomActorImpl::CustomActorImpl( ActorFlags flags )
: mOwner(NULL),
- mRequiresTouchEvents(requiresTouchEvents),
- mRequiresHoverEvents(false),
- mRequiresMouseWheelEvents(false)
+ mFlags( flags )
{
}
bool CustomActorImpl::RequiresTouchEvents() const
{
- return mRequiresTouchEvents;
+ return ( mFlags & REQUIRES_TOUCH_EVENTS );
}
bool CustomActorImpl::RequiresHoverEvents() const
{
- return mRequiresHoverEvents;
-}
-
-void CustomActorImpl::SetRequiresHoverEvents(bool requiresHoverEvents)
-{
- mRequiresHoverEvents = requiresHoverEvents;
+ return ( mFlags & REQUIRES_HOVER_EVENTS );
}
bool CustomActorImpl::RequiresMouseWheelEvents() const
{
- return mRequiresMouseWheelEvents;
+ return ( mFlags & REQUIRES_MOUSE_WHEEL_EVENTS );
}
-void CustomActorImpl::SetRequiresMouseWheelEvents(bool requiresMouseWheelEvents)
+bool CustomActorImpl::IsRelayoutEnabled() const
{
- mRequiresMouseWheelEvents = requiresMouseWheelEvents;
+ return ( mFlags & DISABLE_SIZE_NEGOTIATION ) == 0;
}
void CustomActorImpl::RelayoutRequest()
#include <dali/public-api/object/property.h>
#include <dali/public-api/object/ref-object.h>
#include <dali/public-api/actors/actor-enumerations.h>
+#include <dali/public-api/math/compile-time-math.h>
namespace Dali
{
protected: // For derived classes
- /**
- * @brief Create a CustomActorImpl.
- * @param[in] requiresTouchEvents True if the OnTouchEvent() callback is required.
- */
- CustomActorImpl(bool requiresTouchEvents);
+ // Flags for the constructor
+ enum ActorFlags
+ {
+ ACTOR_BEHAVIOUR_NONE = 0,
+ DISABLE_SIZE_NEGOTIATION = 1 << 0, ///< True if control does not need size negotiation, i.e. it can be skipped in the algorithm
+ REQUIRES_TOUCH_EVENTS = 1 << 1, ///< True if the OnTouchEvent() callback is required.
+ REQUIRES_HOVER_EVENTS = 1 << 2, ///< True if the OnHoverEvent() callback is required.
+ REQUIRES_MOUSE_WHEEL_EVENTS = 1 << 3, ///< True if the OnMouseWheelEvent() callback is required.
- /**
- * @brief Set whether the custom actor requires hover events.
- * @param[in] requiresHoverEvents True if the OnHoverEvent() callback is required.
- */
- void SetRequiresHoverEvents(bool requiresHoverEvents);
+ LAST_ACTOR_FLAG ///< Special marker for last actor flag
+ };
+
+ static const int ACTOR_FLAG_COUNT = Log< LAST_ACTOR_FLAG - 1 >::value + 1; ///< Value for deriving classes to continue on the flag enum
/**
- * @brief Set whether the custom actor requires mouse wheel events.
- * @param[in] requiresMouseWheelEvents True if the OnMouseWheelEvent() callback is required.
+ * @brief Create a CustomActorImpl.
+ * @param[in] flags Bitfield of ActorFlags to define behaviour
*/
- void SetRequiresMouseWheelEvents(bool requiresMouseWheelEvents);
+ CustomActorImpl( ActorFlags flags );
/**
* @brief Request a relayout, which means performing a size negotiation on this actor, its parent and children (and potentially whole scene)
*/
bool RequiresMouseWheelEvents() const;
+ /**
+ * @brief Called when ownership of the CustomActorImpl is passed to a CustomActor.
+ * @return Return true if relayout is enabled on the custom actor
+ */
+ bool IsRelayoutEnabled() const;
+
private:
- 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
+ Internal::CustomActor* mOwner; ///< Internal owner of this custom actor implementation
+ ActorFlags mFlags :ACTOR_FLAG_COUNT; ///< ActorFlags flags to determine behaviour
};
} // namespace Dali
return Dali::Image( imagePtr.Get() );
}
-void ImageActor::SetToNaturalSize()
-{
- GetImplementation(*this).SetToNaturalSize();
-}
-
void ImageActor::SetPixelArea(const PixelArea& pixelArea)
{
GetImplementation(*this).SetPixelArea(pixelArea);
* Setting a size on the ImageActor, e.g through the SetSize api or through an animation will
* stop the natural size being used.
*
- * Such a set size can be changed back to the image's size by calling SetToNaturalSize().
- *
* If a pixel area is set on an ImageActor with natural size, the actor size will change
* to match the pixel area. If a pixel area is set on an ImageActor that has had it's size set,
* then the size doesn't change, and the partial image will be stretched to fill the set size.
Image GetImage();
/**
- * @brief Tell the image actor to use the natural size of the current image
- * or future images.
- *
- * Calling SetSize on this actor or animating the size of the actor
- * overrides this behaviour.
- *
- * @post The image actor uses the natural image size after an image
- * has been loaded.
- */
- void SetToNaturalSize();
-
- /**
* @brief Set a region of the image to display, in pixels.
*
* When the image is loaded the actor's size will be reset to the pixelArea,