X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fcontrols%2Fflex-container%2Fflex-container-impl.cpp;h=94a92a7c7e35dcf00b637fbdd5a650fa65171818;hb=e54f982e0aaf23db4c3002a3d9fe47a19737bb71;hp=00e127140468a3be93d8f67ee0a8fabbb456f093;hpb=b936651d1ccf66163c2ed8e381229e8f3618cc7b;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/internal/controls/flex-container/flex-container-impl.cpp b/dali-toolkit/internal/controls/flex-container/flex-container-impl.cpp index 00e1271..94a92a7 100644 --- a/dali-toolkit/internal/controls/flex-container/flex-container-impl.cpp +++ b/dali-toolkit/internal/controls/flex-container/flex-container-impl.cpp @@ -22,7 +22,7 @@ #include #include #include -#include +#include #include #include #include @@ -31,18 +31,6 @@ using namespace Dali; namespace { -/* - * Custom properties for how to lay out the actor. - * - * When an actor is add to the flex container, the following custom properties of the actor - * are checked to decide how to lay out the actor inside the flex container. - * - * These non-animatable properties should be registered to the child which would be added - * to the flex container, and once added their values can not be changed. - */ -const char * const FLEX_PROPERTY_NAME("flex"); -const char * const ALIGN_SELF_PROPERTY_NAME("alignSelf"); -const char * const FLEX_MARGIN_PROPERTY_NAME("flexMargin"); #if defined(DEBUG_ENABLED) // debugging support, very useful when new features are added or bugs are hunted down @@ -93,12 +81,15 @@ BaseHandle Create() // Setup properties, signals and actions using the type-registry. DALI_TYPE_REGISTRATION_BEGIN( Toolkit::FlexContainer, Toolkit::Control, Create ); -DALI_PROPERTY_REGISTRATION( Toolkit, FlexContainer, "contentDirection", INTEGER, CONTENT_DIRECTION ) -DALI_PROPERTY_REGISTRATION( Toolkit, FlexContainer, "flexDirection", INTEGER, FLEX_DIRECTION ) -DALI_PROPERTY_REGISTRATION( Toolkit, FlexContainer, "flexWrap", INTEGER, FLEX_WRAP ) -DALI_PROPERTY_REGISTRATION( Toolkit, FlexContainer, "justifyContent", INTEGER, JUSTIFY_CONTENT ) -DALI_PROPERTY_REGISTRATION( Toolkit, FlexContainer, "alignItems", INTEGER, ALIGN_ITEMS ) -DALI_PROPERTY_REGISTRATION( Toolkit, FlexContainer, "alignContent", INTEGER, ALIGN_CONTENT ) +DALI_PROPERTY_REGISTRATION( Toolkit, FlexContainer, "contentDirection", INTEGER, CONTENT_DIRECTION ) +DALI_PROPERTY_REGISTRATION( Toolkit, FlexContainer, "flexDirection", INTEGER, FLEX_DIRECTION ) +DALI_PROPERTY_REGISTRATION( Toolkit, FlexContainer, "flexWrap", INTEGER, FLEX_WRAP ) +DALI_PROPERTY_REGISTRATION( Toolkit, FlexContainer, "justifyContent", INTEGER, JUSTIFY_CONTENT ) +DALI_PROPERTY_REGISTRATION( Toolkit, FlexContainer, "alignItems", INTEGER, ALIGN_ITEMS ) +DALI_PROPERTY_REGISTRATION( Toolkit, FlexContainer, "alignContent", INTEGER, ALIGN_CONTENT ) +DALI_CHILD_PROPERTY_REGISTRATION( Toolkit, FlexContainer, "flex", FLOAT, FLEX ) +DALI_CHILD_PROPERTY_REGISTRATION( Toolkit, FlexContainer, "alignSelf", INTEGER, ALIGN_SELF ) +DALI_CHILD_PROPERTY_REGISTRATION( Toolkit, FlexContainer, "flexMargin", VECTOR4, FLEX_MARGIN ) DALI_TYPE_REGISTRATION_END() @@ -536,13 +527,18 @@ void FlexContainer::OnRelayout( const Vector2& size, RelayoutContainer& containe Actor child = mChildrenNodes[i].actor.GetHandle(); if( child ) { - if( child.GetResizePolicy( Dimension::WIDTH ) != ResizePolicy::USE_ASSIGNED_SIZE ) + if( child.GetPropertyType( Toolkit::FlexContainer::ChildProperty::FLEX ) != Property::NONE ) { - child.SetResizePolicy( ResizePolicy::USE_ASSIGNED_SIZE, Dimension::WIDTH ); - } - if( child.GetResizePolicy( Dimension::HEIGHT ) != ResizePolicy::USE_ASSIGNED_SIZE ) - { - child.SetResizePolicy( ResizePolicy::USE_ASSIGNED_SIZE, Dimension::HEIGHT ); + // Only Set to USE_ASSIGNED_SIZE if the child actor is flexible. + + if( child.GetResizePolicy( Dimension::WIDTH ) != ResizePolicy::USE_ASSIGNED_SIZE ) + { + child.SetResizePolicy( ResizePolicy::USE_ASSIGNED_SIZE, Dimension::WIDTH ); + } + if( child.GetResizePolicy( Dimension::HEIGHT ) != ResizePolicy::USE_ASSIGNED_SIZE ) + { + child.SetResizePolicy( ResizePolicy::USE_ASSIGNED_SIZE, Dimension::HEIGHT ); + } } container.Add( child, Vector2(mChildrenNodes[i].node->layout.dimensions[CSS_WIDTH], mChildrenNodes[i].node->layout.dimensions[CSS_HEIGHT] ) ); @@ -605,18 +601,19 @@ void FlexContainer::ComputeLayout() childNode->style.maxDimensions[CSS_WIDTH] = childActor.GetMaximumSize().x; childNode->style.maxDimensions[CSS_HEIGHT] = childActor.GetMaximumSize().y; - // Test custom properties on the child - if( childActor.GetPropertyIndex( FLEX_PROPERTY_NAME ) != Property::INVALID_INDEX ) + // Check child properties on the child for how to layout it. + // These properties should be dynamically registered to the child which + // would be added to FlexContainer. + + if( childActor.GetPropertyType( Toolkit::FlexContainer::ChildProperty::FLEX ) != Property::NONE ) { - childNode->style.flex = childActor.GetProperty( childActor.GetPropertyIndex(FLEX_PROPERTY_NAME) ).Get(); + childNode->style.flex = childActor.GetProperty( Toolkit::FlexContainer::ChildProperty::FLEX ).Get(); } - Property::Index alignSelfPropertyIndex = childActor.GetPropertyIndex( ALIGN_SELF_PROPERTY_NAME ); - if( alignSelfPropertyIndex != Property::INVALID_INDEX ) + Toolkit::FlexContainer::Alignment alignSelf( Toolkit::FlexContainer::ALIGN_AUTO ); + if( childActor.GetPropertyType( Toolkit::FlexContainer::FlexContainer::ChildProperty::ALIGN_SELF ) != Property::NONE ) { - Property::Value alignSelfPropertyValue = childActor.GetProperty( alignSelfPropertyIndex ); - - Toolkit::FlexContainer::Alignment alignSelf( Toolkit::FlexContainer::ALIGN_AUTO ); + Property::Value alignSelfPropertyValue = childActor.GetProperty( Toolkit::FlexContainer::ChildProperty::ALIGN_SELF ); if( alignSelfPropertyValue.GetType() == Property::INTEGER ) { alignSelf = static_cast( alignSelfPropertyValue.Get< int >() ); @@ -629,12 +626,12 @@ void FlexContainer::ComputeLayout() ALIGN_SELF_STRING_TABLE_COUNT, alignSelf ); } - childNode->style.align_self = static_cast(alignSelf); } + childNode->style.align_self = static_cast(alignSelf); - if( childActor.GetPropertyIndex( FLEX_MARGIN_PROPERTY_NAME ) != Property::INVALID_INDEX ) + if( childActor.GetPropertyType( Toolkit::FlexContainer::ChildProperty::FLEX_MARGIN ) != Property::NONE ) { - Vector4 flexMargin = childActor.GetProperty( childActor.GetPropertyIndex(FLEX_MARGIN_PROPERTY_NAME) ).Get(); + Vector4 flexMargin = childActor.GetProperty( Toolkit::FlexContainer::ChildProperty::FLEX_MARGIN ).Get(); childNode->style.margin[CSS_LEFT] = flexMargin.x; childNode->style.margin[CSS_TOP] = flexMargin.y; childNode->style.margin[CSS_RIGHT] = flexMargin.z; @@ -738,6 +735,10 @@ Actor FlexContainer::GetNextKeyboardFocusableActor(Actor currentFocusedActor, To } while ( !mChildrenNodes[nextFocusedActorIndex].actor.GetHandle().IsKeyboardFocusable() ); break; } + default: + { + break; + } } if( nextFocusedActorIndex != currentFocusedActorIndex ) @@ -762,7 +763,7 @@ Actor FlexContainer::GetNextKeyboardFocusableActor(Actor currentFocusedActor, To } FlexContainer::FlexContainer() -: Control( ControlBehaviour( ACTOR_BEHAVIOUR_NONE ) ), +: Control( ControlBehaviour( CONTROL_BEHAVIOUR_DEFAULT ) ), mContentDirection( Toolkit::FlexContainer::INHERIT ), mFlexDirection( Toolkit::FlexContainer::COLUMN ), mFlexWrap( Toolkit::FlexContainer::NO_WRAP ),