/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include <sstream>
#include <dali/public-api/object/ref-object.h>
#include <dali/public-api/object/type-registry.h>
-#include <dali/devel-api/object/type-registry-helper.h>
+#include <dali/public-api/object/type-registry-helper.h>
#include <dali/devel-api/scripting/scripting.h>
#include <dali/public-api/size-negotiation/relayout-container.h>
#include <dali/integration-api/debug.h>
void FlexContainer::OnChildAdd( Actor& child )
{
- Control::OnChildAdd( child );
-
// Anchor actor to top left of the container
child.SetAnchorPoint( AnchorPoint::TOP_LEFT );
child.SetParentOrigin( ParentOrigin::TOP_LEFT );
childNode.node->get_child = GetChildNodeAtIndex;
childNode.node->is_dirty = IsNodeDirty;
mChildrenNodes.push_back(childNode);
+
+ Control::OnChildAdd( child );
}
void FlexContainer::OnChildRemove( Actor& child )
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] ) );
RelayoutRequest();
}
-}
-void FlexContainer::OnSizeAnimation( Animation& animation, const Vector3& targetSize )
-{
- // @todo Animate the children to their target size and position
+ Control::OnSizeSet( size );
}
void FlexContainer::ComputeLayout()
// These properties should be dynamically registered to the child which
// would be added to FlexContainer.
- childNode->style.flex = childActor.GetProperty( Toolkit::FlexContainer::ChildProperty::FLEX ).Get<float>();
-
- Toolkit::FlexContainer::Alignment alignSelf( Toolkit::FlexContainer::ALIGN_AUTO );
- Property::Value alignSelfPropertyValue = childActor.GetProperty( Toolkit::FlexContainer::ChildProperty::ALIGN_SELF );
- if( alignSelfPropertyValue.GetType() == Property::INTEGER )
+ if( childActor.GetPropertyType( Toolkit::FlexContainer::ChildProperty::FLEX ) != Property::NONE )
{
- alignSelf = static_cast<Toolkit::FlexContainer::Alignment>( alignSelfPropertyValue.Get< int >() );
+ childNode->style.flex = childActor.GetProperty( Toolkit::FlexContainer::ChildProperty::FLEX ).Get<float>();
}
- else if( alignSelfPropertyValue.GetType() == Property::STRING )
+
+ Toolkit::FlexContainer::Alignment alignSelf( Toolkit::FlexContainer::ALIGN_AUTO );
+ if( childActor.GetPropertyType( Toolkit::FlexContainer::FlexContainer::ChildProperty::ALIGN_SELF ) != Property::NONE )
{
- std::string value = alignSelfPropertyValue.Get<std::string>();
- Scripting::GetEnumeration< Toolkit::FlexContainer::Alignment >( value.c_str(),
- ALIGN_SELF_STRING_TABLE,
- ALIGN_SELF_STRING_TABLE_COUNT,
- alignSelf );
+ Property::Value alignSelfPropertyValue = childActor.GetProperty( Toolkit::FlexContainer::ChildProperty::ALIGN_SELF );
+ if( alignSelfPropertyValue.GetType() == Property::INTEGER )
+ {
+ alignSelf = static_cast<Toolkit::FlexContainer::Alignment>( alignSelfPropertyValue.Get< int >() );
+ }
+ else if( alignSelfPropertyValue.GetType() == Property::STRING )
+ {
+ std::string value = alignSelfPropertyValue.Get<std::string>();
+ Scripting::GetEnumeration< Toolkit::FlexContainer::Alignment >( value.c_str(),
+ ALIGN_SELF_STRING_TABLE,
+ ALIGN_SELF_STRING_TABLE_COUNT,
+ alignSelf );
+ }
}
childNode->style.align_self = static_cast<css_align_t>(alignSelf);
- Vector4 flexMargin = childActor.GetProperty( Toolkit::FlexContainer::ChildProperty::FLEX_MARGIN ).Get<Vector4>();
- childNode->style.margin[CSS_LEFT] = flexMargin.x;
- childNode->style.margin[CSS_TOP] = flexMargin.y;
- childNode->style.margin[CSS_RIGHT] = flexMargin.z;
- childNode->style.margin[CSS_BOTTOM] = flexMargin.w;
+ if( childActor.GetPropertyType( Toolkit::FlexContainer::ChildProperty::FLEX_MARGIN ) != Property::NONE )
+ {
+ Vector4 flexMargin = childActor.GetProperty( Toolkit::FlexContainer::ChildProperty::FLEX_MARGIN ).Get<Vector4>();
+ childNode->style.margin[CSS_LEFT] = flexMargin.x;
+ childNode->style.margin[CSS_TOP] = flexMargin.y;
+ childNode->style.margin[CSS_RIGHT] = flexMargin.z;
+ childNode->style.margin[CSS_BOTTOM] = flexMargin.w;
+ }
}
// Calculate the layout
} while ( !mChildrenNodes[nextFocusedActorIndex].actor.GetHandle().IsKeyboardFocusable() );
break;
}
+ default:
+ {
+ break;
+ }
}
if( nextFocusedActorIndex != currentFocusedActorIndex )
}
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 ),