From: Kingsley Stephens Date: Tue, 31 Mar 2015 16:35:45 +0000 (+0100) Subject: Size negotiation patch 1: Remove actor SetPreferredSize X-Git-Tag: accepted/tizen/common/20150407.101656~1^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F76%2F37676%2F6;p=platform%2Fcore%2Fuifw%2Fdali-core.git Size negotiation patch 1: Remove actor SetPreferredSize Also merge SizeMode enum into ResizePolicies, fixed control backing, made actor SetSize override size policy to FIXED, removed SetDimensionDependency from Actor public API Change-Id: I90b98248a089d2a83064f6bed6e25254e5edd6eb --- diff --git a/automated-tests/src/dali-internal/utc-Dali-Internal-RelayoutController.cpp b/automated-tests/src/dali-internal/utc-Dali-Internal-RelayoutController.cpp index 46ac182..077d836 100644 --- a/automated-tests/src/dali-internal/utc-Dali-Internal-RelayoutController.cpp +++ b/automated-tests/src/dali-internal/utc-Dali-Internal-RelayoutController.cpp @@ -456,7 +456,7 @@ int UtcDaliRelayoutController_Relayout_Dependency(void) // Add a child Actor child = NewRelayoutActor( true, true, FILL_TO_PARENT, FIXED ); - child.SetDimensionDependency( HEIGHT, WIDTH ); + child.SetResizePolicy( DIMENSION_DEPENDENCY, HEIGHT ); parent.Add( child ); // Run the test diff --git a/automated-tests/src/dali/utc-Dali-Actor.cpp b/automated-tests/src/dali/utc-Dali-Actor.cpp index b5824b5..e4408f4 100644 --- a/automated-tests/src/dali/utc-Dali-Actor.cpp +++ b/automated-tests/src/dali/utc-Dali-Actor.cpp @@ -40,15 +40,6 @@ void utc_dali_actor_cleanup(void) namespace { -// Enumeration properties to test: -const Scripting::StringEnum< int > SIZE_MODE_VALUES[] = -{ - { "USE_OWN_SIZE", USE_OWN_SIZE }, - { "SIZE_RELATIVE_TO_PARENT", SIZE_RELATIVE_TO_PARENT }, - { "SIZE_FIXED_OFFSET_FROM_PARENT", SIZE_FIXED_OFFSET_FROM_PARENT }, -}; -const unsigned int SIZE_MODE_VALUES_COUNT = sizeof( SIZE_MODE_VALUES ) / sizeof( SIZE_MODE_VALUES[0] ); - bool gTouchCallBackCalled=false; bool gTouchCallBack2Called=false; bool gHoverCallBackCalled=false; @@ -2633,10 +2624,8 @@ int UtcDaliActorSetDrawModeOverlayHitTest(void) Stage::GetCurrent().Add(a); Stage::GetCurrent().Add(b); - a.SetResizePolicy( FIXED, ALL_DIMENSIONS ); - a.SetPreferredSize(Vector2(100.0f, 100.0f)); - b.SetResizePolicy( FIXED, ALL_DIMENSIONS ); - b.SetPreferredSize(Vector2(100.0f, 100.0f)); + a.SetSize( 100.0f, 100.0f ); + b.SetSize( 100.0f, 100.0f ); // position b overlapping a. (regular non-overlays) // hit test at point 'x' @@ -2951,7 +2940,6 @@ const PropertyStringIndex PROPERTY_TABLE[] = { "color-mode", Actor::Property::COLOR_MODE, Property::STRING }, { "position-inheritance", Actor::Property::POSITION_INHERITANCE, Property::STRING }, { "draw-mode", Actor::Property::DRAW_MODE, Property::STRING }, - { "size-mode", Actor::Property::SIZE_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 }, @@ -2962,7 +2950,6 @@ const PropertyStringIndex PROPERTY_TABLE[] = { "padding", Actor::Property::PADDING, Property::VECTOR4 }, { "minimum-size", Actor::Property::MINIMUM_SIZE, Property::VECTOR2 }, { "maximum-size", Actor::Property::MAXIMUM_SIZE, Property::VECTOR2 }, - { "preferred-size", Actor::Property::PREFERRED_SIZE, Property::VECTOR2 }, }; const unsigned int PROPERTY_TABLE_COUNT = sizeof( PROPERTY_TABLE ) / sizeof( PROPERTY_TABLE[0] ); } // unnamed namespace diff --git a/automated-tests/src/dali/utc-Dali-Handle.cpp b/automated-tests/src/dali/utc-Dali-Handle.cpp index e25dd4b..72df1a7 100644 --- a/automated-tests/src/dali/utc-Dali-Handle.cpp +++ b/automated-tests/src/dali/utc-Dali-Handle.cpp @@ -331,7 +331,6 @@ int UtcDaliHandleIsPropertyAConstraintInput(void) DALI_TEST_CHECK( false == actor.IsPropertyAConstraintInput( Actor::Property::COLOR_MODE ) ); DALI_TEST_CHECK( false == actor.IsPropertyAConstraintInput( Actor::Property::POSITION_INHERITANCE ) ); DALI_TEST_CHECK( false == actor.IsPropertyAConstraintInput( Actor::Property::DRAW_MODE ) ); - DALI_TEST_CHECK( false == actor.IsPropertyAConstraintInput( Actor::Property::SIZE_MODE ) ); DALI_TEST_CHECK( false == actor.IsPropertyAConstraintInput( Actor::Property::SIZE_MODE_FACTOR ) ); END_TEST; diff --git a/automated-tests/src/dali/utc-Dali-RenderTask.cpp b/automated-tests/src/dali/utc-Dali-RenderTask.cpp index 81845ec..0bfc035 100644 --- a/automated-tests/src/dali/utc-Dali-RenderTask.cpp +++ b/automated-tests/src/dali/utc-Dali-RenderTask.cpp @@ -138,8 +138,7 @@ ImageActor CreateLoadingImage(TestApplication& application, std::string filename application.Render(16); DALI_TEST_CHECK( application.GetPlatform().WasCalled(TestPlatformAbstraction::LoadResourceFunc) ); ImageActor actor = ImageActor::New(image); - actor.SetPreferredSize( Vector2( 80, 80 ) ); - actor.SetResizePolicy( FIXED, ALL_DIMENSIONS ); + actor.SetSize( 80, 80 ); application.SendNotification(); application.Render(16); return actor; diff --git a/automated-tests/src/dali/utc-Dali-Scripting.cpp b/automated-tests/src/dali/utc-Dali-Scripting.cpp index 72749df..e50db24 100644 --- a/automated-tests/src/dali/utc-Dali-Scripting.cpp +++ b/automated-tests/src/dali/utc-Dali-Scripting.cpp @@ -790,7 +790,6 @@ int UtcDaliScriptingCreatePropertyMapActor(void) actor.SetLeaveRequired( true ); actor.SetInheritOrientation( false ); actor.SetInheritScale( false ); - actor.SetSizeMode( USE_OWN_SIZE ); actor.SetSizeModeFactor( Vector3::ONE ); Stage::GetCurrent().Add( actor ); diff --git a/dali/internal/event/actors/actor-impl.cpp b/dali/internal/event/actors/actor-impl.cpp index 6a1efd9..fdef852 100644 --- a/dali/internal/event/actors/actor-impl.cpp +++ b/dali/internal/event/actors/actor-impl.cpp @@ -78,7 +78,7 @@ ActorContainer Actor::mNullChildren; struct Actor::RelayoutData { RelayoutData() - : sizeModeFactor( Vector3::ONE ), preferredSize( Vector2::ZERO ), sizeSetPolicy( USE_SIZE_SET ), sizeMode( USE_OWN_SIZE ), relayoutEnabled( false ), insideRelayout( false ) + : sizeModeFactor( Vector3::ONE ), preferredSize( Vector2::ZERO ), sizeSetPolicy( USE_SIZE_SET ), relayoutEnabled( false ), insideRelayout( false ) { // Set size negotiation defaults for( unsigned int i = 0; i < DIMENSION_COUNT; ++i ) @@ -113,7 +113,6 @@ struct Actor::RelayoutData Vector2 preferredSize; ///< The preferred size of the actor SizeScalePolicy sizeSetPolicy :3; ///< Policy to apply when setting size. Enough room for the enum - SizeMode sizeMode :2; ///< Determines how the actors parent affects the actors size bool relayoutEnabled :1; ///< Flag to specify if this actor should be included in size negotiation or not (defaults to true) bool insideRelayout :1; ///< Locking flag to prevent recursive relayouts on size set @@ -195,7 +194,6 @@ DALI_PROPERTY( "inherit-scale", BOOLEAN, true, false, false, Dali::Actor::Proper DALI_PROPERTY( "color-mode", STRING, true, false, false, Dali::Actor::Property::COLOR_MODE ) 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", STRING, true, false, false, Dali::Actor::Property::SIZE_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 ) @@ -206,7 +204,6 @@ DALI_PROPERTY( "height-for-width", BOOLEAN, true, false, false, Dali::Actor::Pro DALI_PROPERTY( "padding", VECTOR4, true, false, false, Dali::Actor::Property::PADDING ) DALI_PROPERTY( "minimum-size", VECTOR2, true, false, false, Dali::Actor::Property::MINIMUM_SIZE ) DALI_PROPERTY( "maximum-size", VECTOR2, true, false, false, Dali::Actor::Property::MAXIMUM_SIZE ) -DALI_PROPERTY( "preferred-size", VECTOR2, true, false, false, Dali::Actor::Property::PREFERRED_SIZE ) DALI_PROPERTY_TABLE_END( DEFAULT_ACTOR_PROPERTY_START_INDEX ) // Signals @@ -224,17 +221,14 @@ const char* const ACTION_HIDE = "hide"; // Enumeration to / from string conversion tables -DALI_ENUM_TO_STRING_TABLE_BEGIN( SizeMode )DALI_ENUM_TO_STRING( USE_OWN_SIZE ) -DALI_ENUM_TO_STRING( SIZE_RELATIVE_TO_PARENT ) -DALI_ENUM_TO_STRING( SIZE_FIXED_OFFSET_FROM_PARENT ) -DALI_ENUM_TO_STRING_TABLE_END( SizeMode ) - DALI_ENUM_TO_STRING_TABLE_BEGIN( ResizePolicy )DALI_ENUM_TO_STRING( FIXED ) DALI_ENUM_TO_STRING( USE_NATURAL_SIZE ) -DALI_ENUM_TO_STRING( USE_ASSIGNED_SIZE ) DALI_ENUM_TO_STRING( FILL_TO_PARENT ) +DALI_ENUM_TO_STRING( SIZE_RELATIVE_TO_PARENT ) +DALI_ENUM_TO_STRING( SIZE_FIXED_OFFSET_FROM_PARENT ) DALI_ENUM_TO_STRING( FIT_TO_CHILDREN ) DALI_ENUM_TO_STRING( DIMENSION_DEPENDENCY ) +DALI_ENUM_TO_STRING( USE_ASSIGNED_SIZE ) DALI_ENUM_TO_STRING_TABLE_END( ResizePolicy ) DALI_ENUM_TO_STRING_TABLE_BEGIN( SizeScalePolicy )DALI_ENUM_TO_STRING( USE_SIZE_SET ) @@ -1130,13 +1124,6 @@ bool Actor::IsOrientationInherited() const return mInheritOrientation; } -void Actor::SetSizeMode( SizeMode mode ) -{ - EnsureRelayoutData(); - - mRelayoutData->sizeMode = mode; -} - void Actor::SetSizeModeFactor( const Vector3& factor ) { EnsureRelayoutData(); @@ -1144,13 +1131,6 @@ void Actor::SetSizeModeFactor( const Vector3& factor ) mRelayoutData->sizeModeFactor = factor; } -SizeMode Actor::GetSizeMode() const -{ - EnsureRelayoutData(); - - return mRelayoutData->sizeMode; -} - const Vector3& Actor::GetSizeModeFactor() const { EnsureRelayoutData(); @@ -1284,6 +1264,19 @@ void Actor::SetResizePolicy( ResizePolicy policy, Dimension dimension ) } } + if( policy == DIMENSION_DEPENDENCY ) + { + if( dimension & WIDTH ) + { + SetDimensionDependency( WIDTH, HEIGHT ); + } + + if( dimension & HEIGHT ) + { + SetDimensionDependency( HEIGHT, WIDTH ); + } + } + OnSetResizePolicy( policy, dimension ); // Trigger relayout on this control @@ -1329,7 +1322,6 @@ void Actor::SetDimensionDependency( Dimension dimension, Dimension dependency ) if( dimension & ( 1 << i ) ) { mRelayoutData->dimensionDependencies[ i ] = dependency; - mRelayoutData->resizePolicies[ i ] = DIMENSION_DEPENDENCY; } } } @@ -2815,12 +2807,6 @@ void Actor::SetDefaultProperty( Property::Index index, const Property::Value& pr break; } - case Dali::Actor::Property::SIZE_MODE: - { - SetSizeMode( Scripting::GetEnumeration< SizeMode >( property.Get< std::string >().c_str(), SizeModeTable, SizeModeTableCount ) ); - break; - } - case Dali::Actor::Property::SIZE_MODE_FACTOR: { SetSizeModeFactor( property.Get< Vector3 >() ); @@ -2855,7 +2841,7 @@ void Actor::SetDefaultProperty( Property::Index index, const Property::Value& pr { if( property.Get< bool >() ) { - SetDimensionDependency( WIDTH, HEIGHT ); + SetResizePolicy( DIMENSION_DEPENDENCY, WIDTH ); } break; } @@ -2864,7 +2850,7 @@ void Actor::SetDefaultProperty( Property::Index index, const Property::Value& pr { if( property.Get< bool >() ) { - SetDimensionDependency( HEIGHT, WIDTH ); + SetResizePolicy( DIMENSION_DEPENDENCY, HEIGHT ); } break; } @@ -2893,13 +2879,6 @@ void Actor::SetDefaultProperty( Property::Index index, const Property::Value& pr break; } - case Dali::Actor::Property::PREFERRED_SIZE: - { - Vector2 size = property.Get< Vector2 >(); - SetPreferredSize( size ); - break; - } - default: { // this can happen in the case of a non-animatable default property so just do nothing @@ -3286,12 +3265,6 @@ Property::Value Actor::GetDefaultProperty( Property::Index index ) const break; } - case Dali::Actor::Property::SIZE_MODE: - { - value = Scripting::GetLinearEnumerationName< SizeMode >( GetSizeMode(), SizeModeTable, SizeModeTableCount ); - break; - } - case Dali::Actor::Property::SIZE_MODE_FACTOR: { value = GetSizeModeFactor(); @@ -3354,12 +3327,6 @@ Property::Value Actor::GetDefaultProperty( Property::Index index ) const break; } - case Dali::Actor::Property::PREFERRED_SIZE: - { - value = GetPreferredSize(); - break; - } - default: { DALI_ASSERT_ALWAYS( false && "Actor Property index invalid" ); // should not come here @@ -3808,7 +3775,7 @@ bool Actor::RelayoutDependentOnParent( Dimension dimension ) if( ( dimension & ( 1 << i ) ) ) { const ResizePolicy resizePolicy = GetResizePolicy( static_cast< Dimension >( 1 << i ) ); - if( resizePolicy == FILL_TO_PARENT ) + if( resizePolicy == FILL_TO_PARENT || resizePolicy == SIZE_RELATIVE_TO_PARENT || resizePolicy == SIZE_FIXED_OFFSET_FROM_PARENT ) { return true; } @@ -3951,9 +3918,9 @@ float Actor::CalculateChildSize( const Dali::Actor& child, Dimension dimension ) float Actor::CalculateChildSizeBase( const Dali::Actor& child, Dimension dimension ) { // Fill to parent, taking size mode factor into account - switch( child.GetSizeMode() ) + switch( child.GetResizePolicy( dimension ) ) { - case USE_OWN_SIZE: + case FILL_TO_PARENT: { return GetLatestSize( dimension ); } @@ -4081,6 +4048,8 @@ float Actor::CalculateSize( Dimension dimension, const Vector2& maximumSize ) } case FILL_TO_PARENT: + case SIZE_RELATIVE_TO_PARENT: + case SIZE_FIXED_OFFSET_FROM_PARENT: { return NegotiateFromParent( dimension ); } @@ -4377,6 +4346,16 @@ void Actor::SetPreferredSize( const Vector2& size ) { EnsureRelayoutData(); + if( size.width > 0.0f ) + { + SetResizePolicy( FIXED, WIDTH ); + } + + if( size.height > 0.0f ) + { + SetResizePolicy( FIXED, HEIGHT ); + } + mRelayoutData->preferredSize = size; RelayoutRequest(); diff --git a/dali/internal/event/actors/actor-impl.h b/dali/internal/event/actors/actor-impl.h index 73105e6..fa84c86 100644 --- a/dali/internal/event/actors/actor-impl.h +++ b/dali/internal/event/actors/actor-impl.h @@ -533,27 +533,15 @@ public: bool IsOrientationInherited() const; /** - * @brief Defines how a child actors size is affected by its parents size. - * @param[in] mode The size relative to parent mode to use. - */ - void SetSizeMode( SizeMode mode ); - - /** - * Query how the child actors size is affected by its parents size. - * @return The size relative to parent mode in use. - */ - SizeMode GetSizeMode() const; - - /** * Sets the factor of the parents size used for the child actor. - * Note: Only used if SizeMode is SIZE_RELATIVE_TO_PARENT or SIZE_FIXED_OFFSET_FROM_PARENT. + * Note: Only used if ResizePolicy is SIZE_RELATIVE_TO_PARENT or SIZE_FIXED_OFFSET_FROM_PARENT. * @param[in] factor The vector to multiply the parents size by to get the childs size. */ void SetSizeModeFactor( const Vector3& factor ); /** * Gets the factor of the parents size used for the child actor. - * Note: Only used if SizeMode is SIZE_RELATIVE_TO_PARENT or SIZE_FIXED_OFFSET_FROM_PARENT. + * Note: Only used if ResizePolicy is SIZE_RELATIVE_TO_PARENT or SIZE_FIXED_OFFSET_FROM_PARENT. * @return The vector being used to multiply the parents size by to get the childs size. */ const Vector3& GetSizeModeFactor() const; @@ -1186,12 +1174,16 @@ public: float CalculateChildSizeBase( const Dali::Actor& child, Dimension dimension ); /** - * @copydoc Dali::Actor::SetPreferredSize + * @brief Set the preferred size for size negotiation + * + * @param[in] size The preferred size to set */ void SetPreferredSize( const Vector2& size ); /** - * @copydoc Dali::Actor::GetPreferredSize + * @brief Return the preferred size used for size negotiation + * + * @return Return the preferred size */ Vector2 GetPreferredSize() const; diff --git a/dali/internal/event/actors/image-actor-impl.cpp b/dali/internal/event/actors/image-actor-impl.cpp index a31e532..b7ef27f 100644 --- a/dali/internal/event/actors/image-actor-impl.cpp +++ b/dali/internal/event/actors/image-actor-impl.cpp @@ -171,7 +171,6 @@ void ImageActor::ClearPixelArea() { mInternalSetSize = true; SetSize( image->GetNaturalSize() ); - SetPreferredSize( GetTargetSize().GetVectorXY() ); mInternalSetSize = false; } } @@ -227,7 +226,6 @@ void ImageActor::SetNaturalSize() { mInternalSetSize = true; SetSize( CalculateNaturalSize() ); - SetPreferredSize( GetTargetSize().GetVectorXY() ); mInternalSetSize = false; } } diff --git a/dali/internal/event/size-negotiation/relayout-controller-impl.cpp b/dali/internal/event/size-negotiation/relayout-controller-impl.cpp index 3deb9e1..f987e6e 100644 --- a/dali/internal/event/size-negotiation/relayout-controller-impl.cpp +++ b/dali/internal/event/size-negotiation/relayout-controller-impl.cpp @@ -117,7 +117,8 @@ RelayoutController::RelayoutController() mRelayoutStack( new MemoryPoolRelayoutContainer( mRelayoutInfoAllocator ) ), mRelayoutConnection( false ), mRelayoutFlag( false ), - mEnabled( false ) + mEnabled( false ), + mPerformingRelayout( false ) { // Make space for 32 controls to avoid having to copy construct a lot in the beginning mRelayoutStack->Reserve( 32 ); @@ -413,6 +414,8 @@ void RelayoutController::Relayout() // Only do something when requested if( mRelayoutFlag ) { + mPerformingRelayout = true; + // Clear the flag as we're now doing the relayout mRelayoutFlag = false; @@ -469,6 +472,8 @@ void RelayoutController::Relayout() PRINT_HIERARCHY; } + + mPerformingRelayout = false; } // should not disconnect the signal as that causes some control size negotiations to not work correctly // this algorithm needs more optimization as well @@ -479,6 +484,11 @@ void RelayoutController::SetEnabled( bool enabled ) mEnabled = enabled; } +bool RelayoutController::IsPerformingRelayout() const +{ + return mPerformingRelayout; +} + void RelayoutController::FindAndZero( const RawActorList& list, const Dali::RefObject* object ) { // Object has been destroyed so clear it from this list diff --git a/dali/internal/event/size-negotiation/relayout-controller-impl.h b/dali/internal/event/size-negotiation/relayout-controller-impl.h index 81b8dd2..a0aa6c6 100644 --- a/dali/internal/event/size-negotiation/relayout-controller-impl.h +++ b/dali/internal/event/size-negotiation/relayout-controller-impl.h @@ -105,6 +105,13 @@ public: */ void SetEnabled( bool enabled ); + /** + * @brief Return true if the relayout controller is currently performing a relayout + * + * @return Return true if the relayout controller is currently performing a relayout + */ + bool IsPerformingRelayout() const; + public: // CALLBACKS /** @@ -190,6 +197,7 @@ private: bool mRelayoutConnection : 1; ///< Whether EventProcessingFinishedSignal signal is connected. bool mRelayoutFlag : 1; ///< Relayout flag to avoid unnecessary calls bool mEnabled : 1; ///< Initially disabled. Must be enabled at some point. + bool mPerformingRelayout : 1; ///< The relayout controller is currently performing a relayout }; diff --git a/dali/internal/update/manager/update-algorithms.cpp b/dali/internal/update/manager/update-algorithms.cpp index bd0295f..7d35f54 100644 --- a/dali/internal/update/manager/update-algorithms.cpp +++ b/dali/internal/update/manager/update-algorithms.cpp @@ -174,8 +174,7 @@ inline void UpdateRootNodeTransformValues( Layer& rootNode, int nodeDirtyFlags, /** * Updates transform values for the given node if the transform flag is dirty. - * This includes applying a new size should the SizeMode require it. - * Note that this will cause the size dirty flag to be set. This is why we pass + * Note that this will cause the size dirty flag to be set. This is why we pass * the dirty flags in by reference. * @param[in] node The node to update * @param[in,out] nodeDirtyFlags A reference to the dirty flags, these may be modified by this function diff --git a/dali/internal/update/nodes/node.h b/dali/internal/update/nodes/node.h index 2b5bcf6..e342708 100644 --- a/dali/internal/update/nodes/node.h +++ b/dali/internal/update/nodes/node.h @@ -45,7 +45,6 @@ namespace Internal // value types used by messages template <> struct ParameterType< ColorMode > : public BasicType< ColorMode > {}; template <> struct ParameterType< PositionInheritanceMode > : public BasicType< PositionInheritanceMode > {}; -template <> struct ParameterType< SizeMode > : public BasicType< SizeMode > {}; namespace SceneGraph { diff --git a/dali/public-api/actors/actor-enumerations.h b/dali/public-api/actors/actor-enumerations.h index 77fd3a1..444eb07 100644 --- a/dali/public-api/actors/actor-enumerations.h +++ b/dali/public-api/actors/actor-enumerations.h @@ -47,16 +47,6 @@ enum PositionInheritanceMode }; /** - * @brief Actor size relative to parent mode. - */ -enum SizeMode -{ - USE_OWN_SIZE, ///< The mode is bypassed. The size Vector3 will be used as normal. - SIZE_RELATIVE_TO_PARENT, ///< The actors size will be ( ParentSize * SizeRelativeToParentFactor ). - SIZE_FIXED_OFFSET_FROM_PARENT ///< The actors size will be ( ParentSize + SizeRelativeToParentFactor ). -}; - -/** * @brief Dimensions for layout */ enum Dimension @@ -75,10 +65,12 @@ enum ResizePolicy { FIXED, ///< Size is fixed as set by SetSize USE_NATURAL_SIZE, ///< Size is to use the actor's natural size - USE_ASSIGNED_SIZE, ///< The size will be assigned to the actor FILL_TO_PARENT, ///< Size is to fill up to the actor's parent's bounds. Aspect ratio not maintained. + SIZE_RELATIVE_TO_PARENT, ///< The actors size will be ( ParentSize * SizeRelativeToParentFactor ). + SIZE_FIXED_OFFSET_FROM_PARENT, ///< The actors size will be ( ParentSize + SizeRelativeToParentFactor ). FIT_TO_CHILDREN, ///< Size will adjust to wrap around all children - DIMENSION_DEPENDENCY ///< One dimension is dependent on the other + DIMENSION_DEPENDENCY, ///< One dimension is dependent on the other + USE_ASSIGNED_SIZE ///< The size will be assigned to the actor }; /** diff --git a/dali/public-api/actors/actor.cpp b/dali/public-api/actors/actor.cpp index 51e84ae..1f9435d 100644 --- a/dali/public-api/actors/actor.cpp +++ b/dali/public-api/actors/actor.cpp @@ -30,6 +30,7 @@ #include #include #include +#include namespace Dali { @@ -171,22 +172,50 @@ Vector3 Actor::GetCurrentAnchorPoint() const void Actor::SetSize(float width, float height) { - GetImplementation(*this).SetSize(width, height); + if( IsRelayoutEnabled() ) + { + GetImplementation(*this).SetPreferredSize( Vector2( width, height ) ); + } + else + { + GetImplementation(*this).SetSize(width, height); + } } void Actor::SetSize(float width, float height, float depth) { - GetImplementation(*this).SetSize(width, height, depth); + if( IsRelayoutEnabled() ) + { + GetImplementation(*this).SetPreferredSize( Vector2( width, height ) ); + } + else + { + GetImplementation(*this).SetSize(width, height, depth); + } } void Actor::SetSize(const Vector2& size) { - GetImplementation(*this).SetSize(size); + if( IsRelayoutEnabled() ) + { + GetImplementation(*this).SetPreferredSize( size ); + } + else + { + GetImplementation(*this).SetSize( size ); + } } void Actor::SetSize(const Vector3& size) { - GetImplementation(*this).SetSize(size); + if( IsRelayoutEnabled() ) + { + GetImplementation(*this).SetPreferredSize( size.GetVectorXY() ); + } + else + { + GetImplementation(*this).SetSize( size ); + } } Vector3 Actor::GetTargetSize() const @@ -349,16 +378,6 @@ bool Actor::IsScaleInherited() const return GetImplementation(*this).IsScaleInherited(); } -void Actor::SetSizeMode(SizeMode mode) -{ - GetImplementation(*this).SetSizeMode(mode); -} - -SizeMode Actor::GetSizeMode() const -{ - return GetImplementation(*this).GetSizeMode(); -} - void Actor::SetSizeModeFactor(const Vector3& factor) { GetImplementation(*this).SetSizeModeFactor(factor); @@ -494,16 +513,6 @@ SizeScalePolicy Actor::GetSizeScalePolicy() const return GetImplementation(*this).GetSizeScalePolicy(); } -void Actor::SetDimensionDependency( Dimension dimension, Dimension dependency ) -{ - GetImplementation(*this).SetDimensionDependency( dimension, dependency ); -} - -Dimension Actor::GetDimensionDependency( Dimension dimension ) -{ - return GetImplementation(*this).GetDimensionDependency( dimension ); -} - float Actor::GetHeightForWidth( float width ) { return GetImplementation(*this).GetHeightForWidth( width ); @@ -553,16 +562,6 @@ void Actor::GetPadding( Padding& paddingOut ) const paddingOut.top = heightPadding.y; } -void Actor::SetPreferredSize( const Vector2& size ) -{ - GetImplementation(*this).SetPreferredSize( size ); -} - -Vector2 Actor::GetPreferredSize() const -{ - return GetImplementation(*this).GetPreferredSize(); -} - void Actor::SetMinimumSize( const Vector2& size ) { Internal::Actor& impl = GetImplementation(*this); diff --git a/dali/public-api/actors/actor.h b/dali/public-api/actors/actor.h index 4cc752d..019014e 100644 --- a/dali/public-api/actors/actor.h +++ b/dali/public-api/actors/actor.h @@ -294,7 +294,6 @@ public: COLOR_MODE, ///< name "color-mode", type std::string POSITION_INHERITANCE, ///< name "position-inheritance", type std::string DRAW_MODE, ///< name "draw-mode", type std::string - SIZE_MODE, ///< name "size-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 @@ -305,7 +304,6 @@ public: PADDING, ///< name "padding", type Vector4 MINIMUM_SIZE, ///< name "minimum-size", type Vector2 MAXIMUM_SIZE, ///< name "maximum-size", type Vector2 - PREFERRED_SIZE ///< name "preferred-size", type Vector2 }; }; @@ -1190,40 +1188,12 @@ public: SizeScalePolicy GetSizeScalePolicy() 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_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 or SIZE_FIXED_OFFSET. + * This factor is only used when ResizePolicy is set to either: + * SIZE_RELATIVE_TO_PARENT or SIZE_FIXED_OFFSET_FROM_PARENT. * This actor's size is set to the actor's size multipled by or added to this factor, - * depending on SideMode (See SetSizeMode). + * depending on ResizePolicy (See SetResizePolicy). * * @pre The Actor has been initialized. * @param [in] factor A Vector3 representing the relative factor to be applied to each axis. @@ -1239,23 +1209,6 @@ public: Vector3 GetSizeModeFactor() const; /** - * @brief This method specifies a dependency between dimensions. Will set resize policy on the actor for - * the given dimension to be DIMENSION_DEPENDENCY. - * - * @param[in] dimension The dimension to set the dependency on - * @param[in] dependency The dependency to set on the dimension - */ - void SetDimensionDependency( Dimension dimension, Dimension dependency ); - - /** - * @brief Return the dependecy for a dimension - * - * @param[in] dimension The dimension to return the dependency for - * @return Return the dependency - */ - Dimension GetDimensionDependency( Dimension dimension ); - - /** * @brief Calculate the height of the actor given a width * * @param width Width to use @@ -1311,20 +1264,6 @@ public: void GetPadding( Padding& paddingOut ) const; /** - * @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 - * - * @return Return the preferred size - */ - Vector2 GetPreferredSize() const; - - /** * @brief Set the minimum size an actor can be assigned in size negotiation * * @param[in] size The minimum size