/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 <dali-toolkit/internal/controls/flex-container/flex-container-impl.h>
// EXTERNAL INCLUDES
-#include <sstream>
+#include <dali/devel-api/actors/actor-devel.h>
+#include <dali/devel-api/scripting/scripting.h>
+#include <dali/integration-api/debug.h>
#include <dali/public-api/object/ref-object.h>
+#include <dali/public-api/object/type-registry-helper.h>
#include <dali/public-api/object/type-registry.h>
-#include <dali/devel-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>
+#include <sstream>
+
+#include <dali-toolkit/devel-api/controls/control-devel.h>
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_PADDING_PROPERTY_NAME("flexPadding");
-const char * const FLEX_BORDER_PROPERTY_NAME("flexBorder");
-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
// currently not called from code so compiler will optimize these away, kept here for future debugging
#define FLEX_CONTAINER_TAG "DALI Toolkit::FlexContainer "
-#define FC_LOG(fmt, args...) Debug::LogMessage(Debug::DebugInfo, FLEX_CONTAINER_TAG fmt, ## args)
-//#define FLEX_CONTAINER_DEBUG 1
+#define FC_LOG(fmt, args, ...) Debug::LogMessage(Debug::DebugInfo, FLEX_CONTAINER_TAG fmt, ##args)
+// #define FLEX_CONTAINER_DEBUG 1
#if defined(FLEX_CONTAINER_DEBUG)
-void PrintNode( Toolkit::Internal::FlexContainer::FlexItemNodeContainer itemNodes )
+void PrintNodes(Toolkit::Internal::FlexContainer::FlexItemNodeContainer itemNodes)
{
// Print the style property and layout of all the children
- for( unsigned int i = 0; i < itemNodes.size(); ++i )
+ for(unsigned int i = 0; i < itemNodes.size(); ++i)
{
- FC_LOG( "Item %d style: \n", i );
- print_css_node( itemNodes[i].node, (css_print_options_t)( CSS_PRINT_STYLE | CSS_PRINT_CHILDREN ) );
- FC_LOG( "Item %d layout: \n", i );
- print_css_node( itemNodes[i].node, (css_print_options_t)( CSS_PRINT_LAYOUT | CSS_PRINT_CHILDREN ) );
- FC_LOG( "\n" );
+ FC_LOG("Item %d style: \n", i);
+ YGNodePrint(itemNodes[i].node, (YGPrintOptions)(YGPrintOptionsStyle | YGPrintOptionsChildren));
+ FC_LOG("\n");
+ FC_LOG("Item %d layout: \n", i);
+ YGNodePrint(itemNodes[i].node, (YGPrintOptions)(YGPrintOptionsLayout | YGPrintOptionsChildren));
+ FC_LOG("\n");
}
}
#endif // defined(FLEX_CONTAINER_DEBUG)
#endif // defined(DEBUG_ENABLED)
-
} // namespace
namespace Dali
{
-
namespace Toolkit
{
-
namespace Internal
{
-
namespace
{
-
// Type registration
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_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_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()
const Scripting::StringEnum ALIGN_SELF_STRING_TABLE[] =
-{
- { "auto", Toolkit::FlexContainer::ALIGN_AUTO },
- { "flexStart", Toolkit::FlexContainer::ALIGN_FLEX_START },
- { "center", Toolkit::FlexContainer::ALIGN_CENTER },
- { "flexEnd", Toolkit::FlexContainer::ALIGN_FLEX_END },
- { "stretch", Toolkit::FlexContainer::ALIGN_STRETCH }
-};
-const unsigned int ALIGN_SELF_STRING_TABLE_COUNT = sizeof( ALIGN_SELF_STRING_TABLE ) / sizeof( ALIGN_SELF_STRING_TABLE[0] );
+ {
+ {"auto", Toolkit::FlexContainer::ALIGN_AUTO},
+ {"flexStart", Toolkit::FlexContainer::ALIGN_FLEX_START},
+ {"center", Toolkit::FlexContainer::ALIGN_CENTER},
+ {"flexEnd", Toolkit::FlexContainer::ALIGN_FLEX_END},
+ {"stretch", Toolkit::FlexContainer::ALIGN_STRETCH}};
+const unsigned int ALIGN_SELF_STRING_TABLE_COUNT = sizeof(ALIGN_SELF_STRING_TABLE) / sizeof(ALIGN_SELF_STRING_TABLE[0]);
const Scripting::StringEnum CONTENT_DIRECTION_STRING_TABLE[] =
-{
- { "inherit", Toolkit::FlexContainer::INHERIT },
- { "LTR", Toolkit::FlexContainer::LTR },
- { "RTL", Toolkit::FlexContainer::RTL }
-};
-const unsigned int CONTENT_DIRECTION_STRING_TABLE_COUNT = sizeof( CONTENT_DIRECTION_STRING_TABLE ) / sizeof( CONTENT_DIRECTION_STRING_TABLE[0] );
+ {
+ {"inherit", Toolkit::FlexContainer::INHERIT},
+ {"LTR", Toolkit::FlexContainer::LTR},
+ {"RTL", Toolkit::FlexContainer::RTL}};
+const unsigned int CONTENT_DIRECTION_STRING_TABLE_COUNT = sizeof(CONTENT_DIRECTION_STRING_TABLE) / sizeof(CONTENT_DIRECTION_STRING_TABLE[0]);
const Scripting::StringEnum FLEX_DIRECTION_STRING_TABLE[] =
-{
- { "column", Toolkit::FlexContainer::COLUMN },
- { "columnReverse", Toolkit::FlexContainer::COLUMN_REVERSE },
- { "row", Toolkit::FlexContainer::ROW },
- { "rowReverse", Toolkit::FlexContainer::ROW_REVERSE }
-};
-const unsigned int FLEX_DIRECTION_STRING_TABLE_COUNT = sizeof( FLEX_DIRECTION_STRING_TABLE ) / sizeof( FLEX_DIRECTION_STRING_TABLE[0] );
+ {
+ {"column", Toolkit::FlexContainer::COLUMN},
+ {"columnReverse", Toolkit::FlexContainer::COLUMN_REVERSE},
+ {"row", Toolkit::FlexContainer::ROW},
+ {"rowReverse", Toolkit::FlexContainer::ROW_REVERSE}};
+const unsigned int FLEX_DIRECTION_STRING_TABLE_COUNT = sizeof(FLEX_DIRECTION_STRING_TABLE) / sizeof(FLEX_DIRECTION_STRING_TABLE[0]);
const Scripting::StringEnum FLEX_WRAP_STRING_TABLE[] =
-{
- { "noWrap", Toolkit::FlexContainer::NO_WRAP },
- { "wrap", Toolkit::FlexContainer::WRAP }
-};
-const unsigned int FLEX_WRAP_STRING_TABLE_COUNT = sizeof( FLEX_WRAP_STRING_TABLE ) / sizeof( FLEX_WRAP_STRING_TABLE[0] );
+ {
+ {"noWrap", Toolkit::FlexContainer::NO_WRAP},
+ {"wrap", Toolkit::FlexContainer::WRAP}};
+const unsigned int FLEX_WRAP_STRING_TABLE_COUNT = sizeof(FLEX_WRAP_STRING_TABLE) / sizeof(FLEX_WRAP_STRING_TABLE[0]);
const Scripting::StringEnum JUSTIFY_CONTENT_STRING_TABLE[] =
-{
- { "flexStart", Toolkit::FlexContainer::JUSTIFY_FLEX_START },
- { "center", Toolkit::FlexContainer::JUSTIFY_CENTER },
- { "flexEnd", Toolkit::FlexContainer::JUSTIFY_FLEX_END },
- { "spaceBetween", Toolkit::FlexContainer::JUSTIFY_SPACE_BETWEEN },
- { "spaceAround", Toolkit::FlexContainer::JUSTIFY_SPACE_AROUND }
-};
-const unsigned int JUSTIFY_CONTENT_STRING_TABLE_COUNT = sizeof( JUSTIFY_CONTENT_STRING_TABLE ) / sizeof( JUSTIFY_CONTENT_STRING_TABLE[0] );
+ {
+ {"flexStart", Toolkit::FlexContainer::JUSTIFY_FLEX_START},
+ {"center", Toolkit::FlexContainer::JUSTIFY_CENTER},
+ {"flexEnd", Toolkit::FlexContainer::JUSTIFY_FLEX_END},
+ {"spaceBetween", Toolkit::FlexContainer::JUSTIFY_SPACE_BETWEEN},
+ {"spaceAround", Toolkit::FlexContainer::JUSTIFY_SPACE_AROUND},
+ {"spaceEvenly", Toolkit::FlexContainer::JUSTIFY_SPACE_EVENLY}};
+const unsigned int JUSTIFY_CONTENT_STRING_TABLE_COUNT = sizeof(JUSTIFY_CONTENT_STRING_TABLE) / sizeof(JUSTIFY_CONTENT_STRING_TABLE[0]);
const Scripting::StringEnum ALIGN_ITEMS_STRING_TABLE[] =
-{
- { "flexStart", Toolkit::FlexContainer::ALIGN_FLEX_START },
- { "center", Toolkit::FlexContainer::ALIGN_CENTER },
- { "flexEnd", Toolkit::FlexContainer::ALIGN_FLEX_END },
- { "stretch", Toolkit::FlexContainer::ALIGN_STRETCH }
-};
-const unsigned int ALIGN_ITEMS_STRING_TABLE_COUNT = sizeof( ALIGN_ITEMS_STRING_TABLE ) / sizeof( ALIGN_ITEMS_STRING_TABLE[0] );
+ {
+ {"flexStart", Toolkit::FlexContainer::ALIGN_FLEX_START},
+ {"center", Toolkit::FlexContainer::ALIGN_CENTER},
+ {"flexEnd", Toolkit::FlexContainer::ALIGN_FLEX_END},
+ {"stretch", Toolkit::FlexContainer::ALIGN_STRETCH}};
+const unsigned int ALIGN_ITEMS_STRING_TABLE_COUNT = sizeof(ALIGN_ITEMS_STRING_TABLE) / sizeof(ALIGN_ITEMS_STRING_TABLE[0]);
const Scripting::StringEnum ALIGN_CONTENT_STRING_TABLE[] =
-{
- { "flexStart", Toolkit::FlexContainer::ALIGN_FLEX_START },
- { "center", Toolkit::FlexContainer::ALIGN_CENTER },
- { "flexEnd", Toolkit::FlexContainer::ALIGN_FLEX_END },
- { "stretch", Toolkit::FlexContainer::ALIGN_STRETCH }
-};
-const unsigned int ALIGN_CONTENT_STRING_TABLE_COUNT = sizeof( ALIGN_CONTENT_STRING_TABLE ) / sizeof( ALIGN_CONTENT_STRING_TABLE[0] );
-
-/**
- * The function used by the layout algorithm to be get the style properties
- * and layout information of the child at the given index.
- */
-css_node_t* GetChildNodeAtIndex( void *childrenNodes, int i )
-{
- FlexContainer::FlexItemNodeContainer childrenNodeContainer = *( static_cast<FlexContainer::FlexItemNodeContainer*>( childrenNodes ) );
- return childrenNodeContainer[i].node;
-}
-
-/**
- * The function used by the layout algorithm to check whether the node is dirty
- * for relayout.
- */
-bool IsNodeDirty( void *itemNodes )
-{
- // We only calculate the layout when the child is added or removed, or when
- // style properties are changed. So should always return true here.
- return true;
-}
+ {
+ {"flexStart", Toolkit::FlexContainer::ALIGN_FLEX_START},
+ {"center", Toolkit::FlexContainer::ALIGN_CENTER},
+ {"flexEnd", Toolkit::FlexContainer::ALIGN_FLEX_END},
+ {"stretch", Toolkit::FlexContainer::ALIGN_STRETCH}};
+const unsigned int ALIGN_CONTENT_STRING_TABLE_COUNT = sizeof(ALIGN_CONTENT_STRING_TABLE) / sizeof(ALIGN_CONTENT_STRING_TABLE[0]);
} // Unnamed namespace
Toolkit::FlexContainer FlexContainer::New()
{
// Create the implementation, temporarily owned by this handle on stack
- IntrusivePtr< FlexContainer > impl = new FlexContainer();
+ IntrusivePtr<FlexContainer> impl = new FlexContainer();
// Pass ownership to CustomActor handle
- Toolkit::FlexContainer handle( *impl );
+ Toolkit::FlexContainer handle(*impl);
// Second-phase init of the implementation
// This can only be done after the CustomActor connection has been made...
FlexContainer::~FlexContainer()
{
- free_css_node( mRootNode.node );
+ YGNodeFree(mRootNode.node);
- for( unsigned int i = 0; i < mChildrenNodes.size(); i++ )
+ for(unsigned int i = 0; i < mChildrenNodes.size(); i++)
{
- free_css_node( mChildrenNodes[i].node );
+ YGNodeFree(mChildrenNodes[i].node);
}
mChildrenNodes.clear();
}
-void FlexContainer::SetContentDirection( Toolkit::FlexContainer::ContentDirection contentDirection )
+void FlexContainer::SetContentDirection(Toolkit::FlexContainer::ContentDirection contentDirection)
{
- if( mContentDirection != contentDirection )
+ if(mContentDirection != contentDirection)
{
- mContentDirection = contentDirection;
- mRootNode.node->style.direction = static_cast<css_direction_t>( mContentDirection );
+ Dali::CustomActor ownerActor(GetOwner());
+
+ if(Toolkit::FlexContainer::INHERIT != contentDirection)
+ {
+ mContentDirection = contentDirection;
+
+ ownerActor.SetProperty(Dali::Actor::Property::INHERIT_LAYOUT_DIRECTION, false);
+
+ if(Toolkit::FlexContainer::LTR == contentDirection)
+ {
+ ownerActor.SetProperty(Dali::Actor::Property::LAYOUT_DIRECTION, Dali::LayoutDirection::LEFT_TO_RIGHT);
+ }
+ else
+ {
+ ownerActor.SetProperty(Dali::Actor::Property::LAYOUT_DIRECTION, Dali::LayoutDirection::RIGHT_TO_LEFT);
+ }
+ }
+ else
+ {
+ ownerActor.SetProperty(Dali::Actor::Property::INHERIT_LAYOUT_DIRECTION, true);
+
+ Dali::LayoutDirection::Type layoutDirection = static_cast<Dali::LayoutDirection::Type>(ownerActor.GetParent().GetProperty(Dali::Actor::Property::LAYOUT_DIRECTION).Get<int>());
+
+ if(Dali::LayoutDirection::RIGHT_TO_LEFT == layoutDirection)
+ {
+ mContentDirection = Toolkit::FlexContainer::RTL;
+ }
+ else
+ {
+ mContentDirection = Toolkit::FlexContainer::LTR;
+ }
+ }
RelayoutRequest();
}
return mContentDirection;
}
-void FlexContainer::SetFlexDirection( Toolkit::FlexContainer::FlexDirection flexDirection )
+void FlexContainer::SetFlexDirection(Toolkit::FlexContainer::FlexDirection flexDirection)
{
- if( mFlexDirection != flexDirection )
+ if(mFlexDirection != flexDirection)
{
mFlexDirection = flexDirection;
- mRootNode.node->style.flex_direction = static_cast<css_flex_direction_t>( mFlexDirection );
+ YGNodeStyleSetFlexDirection(mRootNode.node, static_cast<YGFlexDirection>(flexDirection));
RelayoutRequest();
}
return mFlexDirection;
}
-void FlexContainer::SetFlexWrap( Toolkit::FlexContainer::WrapType flexWrap )
+void FlexContainer::SetFlexWrap(Toolkit::FlexContainer::WrapType flexWrap)
{
- if( mFlexWrap != flexWrap )
+ if(mFlexWrap != flexWrap)
{
mFlexWrap = flexWrap;
- mRootNode.node->style.flex_wrap = static_cast<css_wrap_type_t>( mFlexWrap );
+ YGNodeStyleSetFlexWrap(mRootNode.node, static_cast<YGWrap>(flexWrap));
RelayoutRequest();
}
return mFlexWrap;
}
-void FlexContainer::SetJustifyContent( Toolkit::FlexContainer::Justification justifyContent )
+void FlexContainer::SetJustifyContent(Toolkit::FlexContainer::Justification justifyContent)
{
- if( mJustifyContent != justifyContent )
+ if(mJustifyContent != justifyContent)
{
mJustifyContent = justifyContent;
- mRootNode.node->style.justify_content = static_cast<css_justify_t>( mJustifyContent );
+ YGNodeStyleSetJustifyContent(mRootNode.node, static_cast<YGJustify>(justifyContent));
RelayoutRequest();
}
return mJustifyContent;
}
-void FlexContainer::SetAlignItems( Toolkit::FlexContainer::Alignment alignItems )
+void FlexContainer::SetAlignItems(Toolkit::FlexContainer::Alignment alignItems)
{
- if( mAlignItems != alignItems )
+ if(mAlignItems != alignItems)
{
mAlignItems = alignItems;
- mRootNode.node->style.align_items = static_cast<css_align_t>( mAlignItems );
+ YGNodeStyleSetAlignItems(mRootNode.node, static_cast<YGAlign>(alignItems));
RelayoutRequest();
}
return mAlignItems;
}
-void FlexContainer::SetAlignContent( Toolkit::FlexContainer::Alignment alignContent )
+void FlexContainer::SetAlignContent(Toolkit::FlexContainer::Alignment alignContent)
{
- if( mAlignContent != alignContent )
+ if(mAlignContent != alignContent)
{
mAlignContent = alignContent;
- mRootNode.node->style.align_content = static_cast<css_align_t>( mAlignContent );
+ YGNodeStyleSetAlignContent(mRootNode.node, static_cast<YGAlign>(alignContent));
RelayoutRequest();
}
return mAlignContent;
}
-void FlexContainer::SetProperty( BaseObject* object, Property::Index index, const Property::Value& value )
+void FlexContainer::SetProperty(BaseObject* object, Property::Index index, const Property::Value& value)
{
- Toolkit::FlexContainer flexContainer = Toolkit::FlexContainer::DownCast( Dali::BaseHandle( object ) );
+ Toolkit::FlexContainer flexContainer = Toolkit::FlexContainer::DownCast(Dali::BaseHandle(object));
- if( flexContainer )
+ if(flexContainer)
{
- FlexContainer& flexContainerImpl( GetImpl( flexContainer ) );
- switch( index )
+ FlexContainer& flexContainerImpl(GetImpl(flexContainer));
+ switch(index)
{
case Toolkit::FlexContainer::Property::CONTENT_DIRECTION:
{
- Toolkit::FlexContainer::ContentDirection contentDirection( Toolkit::FlexContainer::INHERIT );
+ Toolkit::FlexContainer::ContentDirection contentDirection(Toolkit::FlexContainer::INHERIT);
- if( value.GetType() == Property::INTEGER )
+ if(value.GetType() == Property::INTEGER)
{
- flexContainerImpl.SetContentDirection( static_cast<Toolkit::FlexContainer::ContentDirection>( value.Get< int >() ) );
+ flexContainerImpl.SetContentDirection(static_cast<Toolkit::FlexContainer::ContentDirection>(value.Get<int>()));
}
- else if( Scripting::GetEnumeration< Toolkit::FlexContainer::ContentDirection >( value.Get< std::string >().c_str(),
- CONTENT_DIRECTION_STRING_TABLE,
- CONTENT_DIRECTION_STRING_TABLE_COUNT,
- contentDirection ) )
+ else if(Scripting::GetEnumeration<Toolkit::FlexContainer::ContentDirection>(value.Get<std::string>().c_str(),
+ CONTENT_DIRECTION_STRING_TABLE,
+ CONTENT_DIRECTION_STRING_TABLE_COUNT,
+ contentDirection))
{
flexContainerImpl.SetContentDirection(contentDirection);
}
}
case Toolkit::FlexContainer::Property::FLEX_DIRECTION:
{
- Toolkit::FlexContainer::FlexDirection flexDirection( Toolkit::FlexContainer::COLUMN );
+ Toolkit::FlexContainer::FlexDirection flexDirection(Toolkit::FlexContainer::COLUMN);
- if( value.GetType() == Property::INTEGER )
+ if(value.GetType() == Property::INTEGER)
{
- flexContainerImpl.SetFlexDirection( static_cast<Toolkit::FlexContainer::FlexDirection>( value.Get< int >() ) );
+ flexContainerImpl.SetFlexDirection(static_cast<Toolkit::FlexContainer::FlexDirection>(value.Get<int>()));
}
- else if( Scripting::GetEnumeration< Toolkit::FlexContainer::FlexDirection >( value.Get< std::string >().c_str(),
- FLEX_DIRECTION_STRING_TABLE,
- FLEX_DIRECTION_STRING_TABLE_COUNT,
- flexDirection ) )
+ else if(Scripting::GetEnumeration<Toolkit::FlexContainer::FlexDirection>(value.Get<std::string>().c_str(),
+ FLEX_DIRECTION_STRING_TABLE,
+ FLEX_DIRECTION_STRING_TABLE_COUNT,
+ flexDirection))
{
flexContainerImpl.SetFlexDirection(flexDirection);
}
}
case Toolkit::FlexContainer::Property::FLEX_WRAP:
{
- Toolkit::FlexContainer::WrapType flexWrap( Toolkit::FlexContainer::NO_WRAP );
+ Toolkit::FlexContainer::WrapType flexWrap(Toolkit::FlexContainer::NO_WRAP);
- if( value.GetType() == Property::INTEGER )
+ if(value.GetType() == Property::INTEGER)
{
- flexContainerImpl.SetFlexWrap( static_cast<Toolkit::FlexContainer::WrapType>( value.Get< int >() ) );
+ flexContainerImpl.SetFlexWrap(static_cast<Toolkit::FlexContainer::WrapType>(value.Get<int>()));
}
- else if( Scripting::GetEnumeration< Toolkit::FlexContainer::WrapType >( value.Get< std::string >().c_str(),
- FLEX_WRAP_STRING_TABLE,
- FLEX_WRAP_STRING_TABLE_COUNT,
- flexWrap ) )
+ else if(Scripting::GetEnumeration<Toolkit::FlexContainer::WrapType>(value.Get<std::string>().c_str(),
+ FLEX_WRAP_STRING_TABLE,
+ FLEX_WRAP_STRING_TABLE_COUNT,
+ flexWrap))
{
flexContainerImpl.SetFlexWrap(flexWrap);
}
}
case Toolkit::FlexContainer::Property::JUSTIFY_CONTENT:
{
- Toolkit::FlexContainer::Justification justifyContent( Toolkit::FlexContainer::JUSTIFY_FLEX_START );
+ Toolkit::FlexContainer::Justification justifyContent(Toolkit::FlexContainer::JUSTIFY_FLEX_START);
- if( value.GetType() == Property::INTEGER )
+ if(value.GetType() == Property::INTEGER)
{
- flexContainerImpl.SetJustifyContent( static_cast<Toolkit::FlexContainer::Justification>( value.Get< int >() ) );
+ flexContainerImpl.SetJustifyContent(static_cast<Toolkit::FlexContainer::Justification>(value.Get<int>()));
}
- else if( Scripting::GetEnumeration< Toolkit::FlexContainer::Justification >( value.Get< std::string >().c_str(),
- JUSTIFY_CONTENT_STRING_TABLE,
- JUSTIFY_CONTENT_STRING_TABLE_COUNT,
- justifyContent ) )
+ else if(Scripting::GetEnumeration<Toolkit::FlexContainer::Justification>(value.Get<std::string>().c_str(),
+ JUSTIFY_CONTENT_STRING_TABLE,
+ JUSTIFY_CONTENT_STRING_TABLE_COUNT,
+ justifyContent))
{
flexContainerImpl.SetJustifyContent(justifyContent);
}
}
case Toolkit::FlexContainer::Property::ALIGN_ITEMS:
{
- Toolkit::FlexContainer::Alignment alignItems( Toolkit::FlexContainer::ALIGN_STRETCH );
+ Toolkit::FlexContainer::Alignment alignItems(Toolkit::FlexContainer::ALIGN_STRETCH);
- if( value.GetType() == Property::INTEGER )
+ if(value.GetType() == Property::INTEGER)
{
- flexContainerImpl.SetAlignItems( static_cast<Toolkit::FlexContainer::Alignment>( value.Get< int >() ) );
+ flexContainerImpl.SetAlignItems(static_cast<Toolkit::FlexContainer::Alignment>(value.Get<int>()));
}
- else if( Scripting::GetEnumeration< Toolkit::FlexContainer::Alignment >( value.Get< std::string >().c_str(),
- ALIGN_ITEMS_STRING_TABLE,
- ALIGN_ITEMS_STRING_TABLE_COUNT,
- alignItems ) )
+ else if(Scripting::GetEnumeration<Toolkit::FlexContainer::Alignment>(value.Get<std::string>().c_str(),
+ ALIGN_ITEMS_STRING_TABLE,
+ ALIGN_ITEMS_STRING_TABLE_COUNT,
+ alignItems))
{
flexContainerImpl.SetAlignItems(alignItems);
}
}
case Toolkit::FlexContainer::Property::ALIGN_CONTENT:
{
- Toolkit::FlexContainer::Alignment alignContent( Toolkit::FlexContainer::ALIGN_FLEX_START );
+ Toolkit::FlexContainer::Alignment alignContent(Toolkit::FlexContainer::ALIGN_FLEX_START);
- if( value.GetType() == Property::INTEGER )
+ if(value.GetType() == Property::INTEGER)
{
- flexContainerImpl.SetAlignContent( static_cast<Toolkit::FlexContainer::Alignment>( value.Get< int >() ) );
+ flexContainerImpl.SetAlignContent(static_cast<Toolkit::FlexContainer::Alignment>(value.Get<int>()));
}
- else if( Scripting::GetEnumeration< Toolkit::FlexContainer::Alignment >( value.Get< std::string >().c_str(),
- ALIGN_CONTENT_STRING_TABLE,
- ALIGN_CONTENT_STRING_TABLE_COUNT,
- alignContent ) )
+ else if(Scripting::GetEnumeration<Toolkit::FlexContainer::Alignment>(value.Get<std::string>().c_str(),
+ ALIGN_CONTENT_STRING_TABLE,
+ ALIGN_CONTENT_STRING_TABLE_COUNT,
+ alignContent))
{
flexContainerImpl.SetAlignContent(alignContent);
}
}
}
-Property::Value FlexContainer::GetProperty( BaseObject* object, Property::Index index )
+Property::Value FlexContainer::GetProperty(BaseObject* object, Property::Index index)
{
Property::Value value;
- Toolkit::FlexContainer flexContainer = Toolkit::FlexContainer::DownCast( Dali::BaseHandle( object ) );
+ Toolkit::FlexContainer flexContainer = Toolkit::FlexContainer::DownCast(Dali::BaseHandle(object));
- if( flexContainer )
+ if(flexContainer)
{
- FlexContainer& flexContainerImpl( GetImpl( flexContainer ) );
- switch( index )
+ FlexContainer& flexContainerImpl(GetImpl(flexContainer));
+ switch(index)
{
case Toolkit::FlexContainer::Property::CONTENT_DIRECTION:
{
return value;
}
-void FlexContainer::OnChildAdd( Actor& child )
+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 );
-
// Create a new node for the child.
FlexItemNode childNode;
childNode.actor = child;
- childNode.node = new_css_node();
- childNode.node->get_child = GetChildNodeAtIndex;
- childNode.node->is_dirty = IsNodeDirty;
+ childNode.node = YGNodeNew();
+
mChildrenNodes.push_back(childNode);
+ YGNodeInsertChild(mRootNode.node, childNode.node, mChildrenNodes.size() - 1);
+
+ Control::OnChildAdd(child);
}
-void FlexContainer::OnChildRemove( Actor& child )
+void FlexContainer::OnChildRemove(Actor& child)
{
- for( unsigned int i = 0; i < mChildrenNodes.size(); i++ )
+ for(unsigned int i = 0; i < mChildrenNodes.size(); i++)
{
- if( mChildrenNodes[i].actor.GetHandle() == child )
+ if(mChildrenNodes[i].actor.GetHandle() == child)
{
- free_css_node( mChildrenNodes[i].node );
- mChildrenNodes.erase( mChildrenNodes.begin() + i );
+ YGNodeRemoveChild(mRootNode.node, mChildrenNodes[i].node);
+ YGNodeFree(mChildrenNodes[i].node);
+
+ mChildrenNodes.erase(mChildrenNodes.begin() + i);
// Relayout the container only if instances were found
RelayoutRequest();
}
}
- Control::OnChildRemove( child );
+ Control::OnChildRemove(child);
}
-void FlexContainer::OnRelayout( const Vector2& size, RelayoutContainer& container )
+void FlexContainer::OnRelayout(const Vector2& size, RelayoutContainer& container)
{
- for( unsigned int i = 0; i < mChildrenNodes.size(); i++ )
+ for(unsigned int i = 0; i < mChildrenNodes.size(); i++)
{
Actor child = mChildrenNodes[i].actor.GetHandle();
- if( child )
+ if(child)
{
- float negotiatedWidth = child.GetRelayoutSize(Dimension::WIDTH);
+ // Anchor actor to top left of the container
+ if(child.GetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT).Get<bool>())
+ {
+ child.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
+ }
+ child.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
+
+ float negotiatedWidth = child.GetRelayoutSize(Dimension::WIDTH);
float negotiatedHeight = child.GetRelayoutSize(Dimension::HEIGHT);
- if( negotiatedWidth > 0 )
+ if(negotiatedWidth > 0)
{
- mChildrenNodes[i].node->style.dimensions[CSS_WIDTH] = negotiatedWidth;
+ YGNodeStyleSetWidth(mChildrenNodes[i].node, negotiatedWidth);
}
- if( negotiatedHeight > 0 )
+ if(negotiatedHeight > 0)
{
- mChildrenNodes[i].node->style.dimensions[CSS_HEIGHT] = negotiatedHeight;
+ YGNodeStyleSetHeight(mChildrenNodes[i].node, negotiatedHeight);
}
}
}
// Relayout the container
RelayoutChildren();
+#if defined(FLEX_CONTAINER_DEBUG)
+ PrintNodes(mChildrenNodes);
+#endif
- for( unsigned int i = 0; i < mChildrenNodes.size(); i++ )
+ for(unsigned int i = 0; i < mChildrenNodes.size(); i++)
{
Actor child = mChildrenNodes[i].actor.GetHandle();
- if( child )
+ if(child)
{
- 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 )
+ if(child.GetPropertyType(Toolkit::FlexContainer::ChildProperty::FLEX) != Property::NONE)
{
- child.SetResizePolicy( ResizePolicy::USE_ASSIGNED_SIZE, Dimension::HEIGHT );
- }
+ // Only Set to USE_ASSIGNED_SIZE if the child actor is flexible.
- container.Add( child, Vector2(mChildrenNodes[i].node->layout.dimensions[CSS_WIDTH], mChildrenNodes[i].node->layout.dimensions[CSS_HEIGHT] ) );
+ 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(YGNodeLayoutGetWidth(mChildrenNodes[i].node), YGNodeLayoutGetHeight(mChildrenNodes[i].node)));
}
}
}
-bool FlexContainer::RelayoutDependentOnChildren( Dimension::Type dimension )
+bool FlexContainer::RelayoutDependentOnChildren(Dimension::Type dimension)
{
return true;
}
-void FlexContainer::OnSizeSet( const Vector3& size )
+void FlexContainer::OnSizeSet(const Vector3& size)
{
- if( mRootNode.node )
+ if(mRootNode.node)
{
Actor self = Self();
-
- mRootNode.node->style.dimensions[CSS_WIDTH] = size.x;
- mRootNode.node->style.dimensions[CSS_HEIGHT] = size.y;
+ YGNodeStyleSetWidth(mRootNode.node, size.x);
+ YGNodeStyleSetHeight(mRootNode.node, size.y);
RelayoutRequest();
}
+
+ Control::OnSizeSet(size);
}
-void FlexContainer::OnSizeAnimation( Animation& animation, const Vector3& targetSize )
+void FlexContainer::OnLayoutDirectionChanged(Dali::Actor actor, Dali::LayoutDirection::Type type)
{
- // @todo Animate the children to their target size and position
+ Toolkit::FlexContainer flexContainer = Toolkit::FlexContainer::DownCast(actor);
+ Toolkit::FlexContainer::ContentDirection direction;
+
+ if(type == Dali::LayoutDirection::RIGHT_TO_LEFT)
+ {
+ direction = Toolkit::FlexContainer::RTL;
+ }
+ else
+ {
+ direction = Toolkit::FlexContainer::LTR;
+ }
+
+ Toolkit::Internal::FlexContainer& flexContainerImpl = GetImpl(flexContainer);
+
+ if(flexContainerImpl.mContentDirection != direction)
+ {
+ Dali::CustomActor ownerActor(flexContainerImpl.GetOwner());
+ flexContainerImpl.mContentDirection = direction;
+
+ flexContainerImpl.RelayoutRequest();
+ }
}
void FlexContainer::ComputeLayout()
{
- if( mRootNode.node )
+ if(mRootNode.node)
{
- mRootNode.node->children_count = mChildrenNodes.size();
-
- // Intialize the layout.
- mRootNode.node->layout.position[CSS_LEFT] = 0;
- mRootNode.node->layout.position[CSS_TOP] = 0;
- mRootNode.node->layout.position[CSS_BOTTOM] = 0;
- mRootNode.node->layout.position[CSS_RIGHT] = 0;
- mRootNode.node->layout.dimensions[CSS_WIDTH] = CSS_UNDEFINED;
- mRootNode.node->layout.dimensions[CSS_HEIGHT] = CSS_UNDEFINED;
-
- for( unsigned int i = 0; i < mChildrenNodes.size(); i++ )
+ for(unsigned int i = 0; i < mChildrenNodes.size(); i++)
{
- css_node_t* childNode = mChildrenNodes[i].node;
- Actor childActor = mChildrenNodes[i].actor.GetHandle();
-
- childNode->layout.position[CSS_LEFT] = 0;
- childNode->layout.position[CSS_TOP] = 0;
- childNode->layout.position[CSS_BOTTOM] = 0;
- childNode->layout.position[CSS_RIGHT] = 0;
- childNode->layout.dimensions[CSS_WIDTH] = CSS_UNDEFINED;
- childNode->layout.dimensions[CSS_HEIGHT] = CSS_UNDEFINED;
+ YGNodeRef childNode = mChildrenNodes[i].node;
+ Actor childActor = mChildrenNodes[i].actor.GetHandle();
// Intialize the style of the child.
- childNode->style.minDimensions[CSS_WIDTH] = childActor.GetMinimumSize().x;
- childNode->style.minDimensions[CSS_HEIGHT] = childActor.GetMinimumSize().y;
- childNode->style.maxDimensions[CSS_WIDTH] = childActor.GetMaximumSize().x;
- childNode->style.maxDimensions[CSS_HEIGHT] = childActor.GetMaximumSize().y;
+ YGNodeStyleSetMinWidth(childNode, childActor.GetProperty<Vector2>(Actor::Property::MINIMUM_SIZE).x);
+ YGNodeStyleSetMinHeight(childNode, childActor.GetProperty<Vector2>(Actor::Property::MINIMUM_SIZE).y);
+ YGNodeStyleSetMaxWidth(childNode, childActor.GetProperty<Vector2>(Actor::Property::MAXIMUM_SIZE).x);
+ YGNodeStyleSetMaxHeight(childNode, childActor.GetProperty<Vector2>(Actor::Property::MAXIMUM_SIZE).y);
+
+ // 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.
- // Test custom properties on the child
- if( childActor.GetPropertyIndex( FLEX_PROPERTY_NAME ) != Property::INVALID_INDEX )
+ if(childActor.GetPropertyType(Toolkit::FlexContainer::ChildProperty::FLEX) != Property::NONE)
{
- childNode->style.flex = childActor.GetProperty( childActor.GetPropertyIndex(FLEX_PROPERTY_NAME) ).Get<float>();
+ YGNodeStyleSetFlex(childNode, childActor.GetProperty(Toolkit::FlexContainer::ChildProperty::FLEX).Get<float>());
}
- 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::ChildProperty::ALIGN_SELF) != Property::NONE)
{
- Property::Value alignSelfPropertyValue = childActor.GetProperty( alignSelfPropertyIndex );
-
- Toolkit::FlexContainer::Alignment alignSelf( Toolkit::FlexContainer::ALIGN_AUTO );
- if( alignSelfPropertyValue.GetType() == Property::INTEGER )
+ Property::Value alignSelfPropertyValue = childActor.GetProperty(Toolkit::FlexContainer::ChildProperty::ALIGN_SELF);
+ if(alignSelfPropertyValue.GetType() == Property::INTEGER)
{
- alignSelf = static_cast<Toolkit::FlexContainer::Alignment>( alignSelfPropertyValue.Get< int >() );
+ alignSelf = static_cast<Toolkit::FlexContainer::Alignment>(alignSelfPropertyValue.Get<int>());
}
- else if( alignSelfPropertyValue.GetType() == Property::STRING )
+ 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 );
+ 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);
+ YGNodeStyleSetAlignSelf(childNode, static_cast<YGAlign>(alignSelf));
}
- if( childActor.GetPropertyIndex( FLEX_PADDING_PROPERTY_NAME ) != Property::INVALID_INDEX )
+ if(childActor.GetPropertyType(Toolkit::FlexContainer::ChildProperty::FLEX_MARGIN) != Property::NONE)
+ {
+ Vector4 flexMargin = childActor.GetProperty(Toolkit::FlexContainer::ChildProperty::FLEX_MARGIN).Get<Vector4>();
+ YGNodeStyleSetMargin(childNode, YGEdgeLeft, flexMargin.x);
+ YGNodeStyleSetMargin(childNode, YGEdgeTop, flexMargin.y);
+ YGNodeStyleSetMargin(childNode, YGEdgeRight, flexMargin.z);
+ YGNodeStyleSetMargin(childNode, YGEdgeBottom, flexMargin.w);
+ }
+ }
+
+ // Calculate the layout
+ YGDirection nodeLayoutDirection = YGDirectionInherit;
+ switch(mContentDirection)
+ {
+ case Dali::Toolkit::FlexContainer::LTR:
{
- Vector4 flexPadding = childActor.GetProperty( childActor.GetPropertyIndex(FLEX_PADDING_PROPERTY_NAME) ).Get<Vector4>();
- childNode->style.padding[CSS_LEFT] = flexPadding.x;
- childNode->style.padding[CSS_TOP] = flexPadding.y;
- childNode->style.padding[CSS_RIGHT] = flexPadding.z;
- childNode->style.padding[CSS_BOTTOM] = flexPadding.w;
+ nodeLayoutDirection = YGDirectionLTR;
+ break;
}
- if( childActor.GetPropertyIndex( FLEX_BORDER_PROPERTY_NAME ) != Property::INVALID_INDEX )
+ case Dali::Toolkit::FlexContainer::RTL:
{
- Vector4 flexBorder = childActor.GetProperty( childActor.GetPropertyIndex(FLEX_BORDER_PROPERTY_NAME) ).Get<Vector4>();
- childNode->style.border[CSS_LEFT] = flexBorder.x;
- childNode->style.border[CSS_TOP] = flexBorder.y;
- childNode->style.border[CSS_RIGHT] = flexBorder.z;
- childNode->style.border[CSS_BOTTOM] = flexBorder.w;
+ nodeLayoutDirection = YGDirectionRTL;
+ break;
}
- if( childActor.GetPropertyIndex( FLEX_MARGIN_PROPERTY_NAME ) != Property::INVALID_INDEX )
+ case Dali::Toolkit::FlexContainer::INHERIT:
{
- Vector4 flexMargin = childActor.GetProperty( childActor.GetPropertyIndex(FLEX_MARGIN_PROPERTY_NAME) ).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;
+ nodeLayoutDirection = YGDirectionInherit;
+ break;
}
}
- // Calculate the layout
- layoutNode( mRootNode.node, Self().GetMaximumSize().x, Self().GetMaximumSize().y, mRootNode.node->style.direction );
+#if defined(FLEX_CONTAINER_DEBUG)
+ YGNodePrint(mRootNode.node, (YGPrintOptions)(YGPrintOptionsLayout | YGPrintOptionsStyle | YGPrintOptionsChildren));
+#endif
+ YGNodeCalculateLayout(mRootNode.node, Self().GetProperty<Vector2>(Actor::Property::MAXIMUM_SIZE).x, Self().GetProperty<Vector2>(Actor::Property::MAXIMUM_SIZE).y, nodeLayoutDirection);
+#if defined(FLEX_CONTAINER_DEBUG)
+ YGNodePrint(mRootNode.node, (YGPrintOptions)(YGPrintOptionsLayout | YGPrintOptionsStyle | YGPrintOptionsChildren));
+#endif
}
}
ComputeLayout();
// Set size and position of children according to the layout calculation
- for( unsigned int i = 0; i < mChildrenNodes.size(); i++ )
+ for(unsigned int i = 0; i < mChildrenNodes.size(); i++)
{
Dali::Actor child = mChildrenNodes[i].actor.GetHandle();
- if( child )
+ if(child)
{
- child.SetX( mChildrenNodes[i].node->layout.position[CSS_LEFT] );
- child.SetY( mChildrenNodes[i].node->layout.position[CSS_TOP] );
+ child.SetProperty(Actor::Property::POSITION_X, YGNodeLayoutGetLeft(mChildrenNodes[i].node));
+ child.SetProperty(Actor::Property::POSITION_Y, YGNodeLayoutGetTop(mChildrenNodes[i].node));
}
}
}
Actor nextFocusableActor;
// First check whether there is any items in the container
- if( mChildrenNodes.size() > 0 )
+ if(mChildrenNodes.size() > 0)
{
- if ( !currentFocusedActor || currentFocusedActor == Self() )
+ if(!currentFocusedActor || currentFocusedActor == Self())
{
// Nothing is currently focused, so the first child in the container should be focused.
nextFocusableActor = mChildrenNodes[0].actor.GetHandle();
{
// Check whether the current focused actor is within flex container
int currentFocusedActorIndex = -1;
- for( unsigned int index = 0; index < mChildrenNodes.size(); index++ )
+ for(unsigned int index = 0; index < mChildrenNodes.size(); index++)
{
- if( currentFocusedActor == mChildrenNodes[index].actor.GetHandle() )
+ if(currentFocusedActor == mChildrenNodes[index].actor.GetHandle())
{
currentFocusedActorIndex = index;
break;
}
}
- if( currentFocusedActorIndex > -1 )
+ if(currentFocusedActorIndex > -1)
{
int previousCheckedActorIndex = -1;
- int nextFocusedActorIndex = currentFocusedActorIndex;
- switch ( direction )
+ int nextFocusedActorIndex = currentFocusedActorIndex;
+ switch(direction)
{
case Toolkit::Control::KeyboardFocus::LEFT:
case Toolkit::Control::KeyboardFocus::UP:
do
{
nextFocusedActorIndex--;
- if( nextFocusedActorIndex < 0 )
+ if(nextFocusedActorIndex < 0)
{
nextFocusedActorIndex = loopEnabled ? mChildrenNodes.size() - 1 : 0;
}
- if( nextFocusedActorIndex != previousCheckedActorIndex && nextFocusedActorIndex != currentFocusedActorIndex )
+ if(nextFocusedActorIndex != previousCheckedActorIndex && nextFocusedActorIndex != currentFocusedActorIndex)
{
previousCheckedActorIndex = nextFocusedActorIndex;
}
{
break;
}
- } while ( !mChildrenNodes[nextFocusedActorIndex].actor.GetHandle().IsKeyboardFocusable() );
+ } while(!mChildrenNodes[nextFocusedActorIndex].actor.GetHandle().GetProperty<bool>(Actor::Property::KEYBOARD_FOCUSABLE));
break;
}
case Toolkit::Control::KeyboardFocus::RIGHT:
do
{
nextFocusedActorIndex++;
- if( nextFocusedActorIndex > static_cast<int>(mChildrenNodes.size() - 1) )
+ if(nextFocusedActorIndex > static_cast<int>(mChildrenNodes.size() - 1))
{
nextFocusedActorIndex = loopEnabled ? 0 : mChildrenNodes.size() - 1;
}
- if( nextFocusedActorIndex != previousCheckedActorIndex && nextFocusedActorIndex != currentFocusedActorIndex )
+ if(nextFocusedActorIndex != previousCheckedActorIndex && nextFocusedActorIndex != currentFocusedActorIndex)
{
previousCheckedActorIndex = nextFocusedActorIndex;
}
{
break;
}
- } while ( !mChildrenNodes[nextFocusedActorIndex].actor.GetHandle().IsKeyboardFocusable() );
+ } while(!mChildrenNodes[nextFocusedActorIndex].actor.GetHandle().GetProperty<bool>(Actor::Property::KEYBOARD_FOCUSABLE));
+ break;
+ }
+ default:
+ {
break;
}
}
- if( nextFocusedActorIndex != currentFocusedActorIndex )
+ if(nextFocusedActorIndex != currentFocusedActorIndex)
{
nextFocusableActor = mChildrenNodes[nextFocusedActorIndex].actor.GetHandle();
}
}
FlexContainer::FlexContainer()
-: Control( ControlBehaviour( ACTOR_BEHAVIOUR_NONE ) ),
- mContentDirection( Toolkit::FlexContainer::INHERIT ),
- mFlexDirection( Toolkit::FlexContainer::COLUMN ),
- mFlexWrap( Toolkit::FlexContainer::NO_WRAP ),
- mJustifyContent( Toolkit::FlexContainer::JUSTIFY_FLEX_START ),
- mAlignItems( Toolkit::FlexContainer::ALIGN_STRETCH ),
- mAlignContent( Toolkit::FlexContainer::ALIGN_FLEX_START )
-{
- SetKeyboardNavigationSupport( true );
+: Control(ControlBehaviour(CONTROL_BEHAVIOUR_DEFAULT)),
+ mContentDirection(Toolkit::FlexContainer::INHERIT),
+ mFlexDirection(Toolkit::FlexContainer::COLUMN),
+ mFlexWrap(Toolkit::FlexContainer::NO_WRAP),
+ mJustifyContent(Toolkit::FlexContainer::JUSTIFY_FLEX_START),
+ mAlignItems(Toolkit::FlexContainer::ALIGN_STRETCH),
+ mAlignContent(Toolkit::FlexContainer::ALIGN_FLEX_START)
+{
+ SetKeyboardNavigationSupport(true);
}
void FlexContainer::OnInitialize()
{
// Initialize the node for the flex container itself
Dali::Actor self = Self();
+ self.LayoutDirectionChangedSignal().Connect(this, &FlexContainer::OnLayoutDirectionChanged);
+
mRootNode.actor = self;
- mRootNode.node = new_css_node();
- mRootNode.node->context = &mChildrenNodes;
+ mRootNode.node = YGNodeNew();
+ YGNodeSetContext(mRootNode.node, &mChildrenNodes);
// Set default style
- mRootNode.node->style.direction = static_cast<css_direction_t>( mContentDirection );
- mRootNode.node->style.flex_direction = static_cast<css_flex_direction_t>( mFlexDirection );
- mRootNode.node->style.flex_wrap = static_cast<css_wrap_type_t>( mFlexWrap );
- mRootNode.node->style.justify_content = static_cast<css_justify_t>( mJustifyContent );
- mRootNode.node->style.align_items = static_cast<css_align_t>( mAlignItems );
- mRootNode.node->style.align_content = static_cast<css_align_t>( mAlignContent );
-
- // Set callbacks.
- mRootNode.node->get_child = GetChildNodeAtIndex;
- mRootNode.node->is_dirty = IsNodeDirty;
+ YGNodeStyleSetFlexDirection(mRootNode.node, static_cast<YGFlexDirection>(mFlexDirection));
+ YGNodeStyleSetFlexWrap(mRootNode.node, static_cast<YGWrap>(mFlexWrap));
+ YGNodeStyleSetJustifyContent(mRootNode.node, static_cast<YGJustify>(mJustifyContent));
+ YGNodeStyleSetAlignItems(mRootNode.node, static_cast<YGAlign>(mAlignItems));
+ YGNodeStyleSetAlignContent(mRootNode.node, static_cast<YGAlign>(mAlignContent));
// Make self as keyboard focusable and focus group
- self.SetKeyboardFocusable( true );
- SetAsKeyboardFocusGroup( true );
+ self.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, true);
+ SetAsKeyboardFocusGroup(true);
+
+ DevelControl::SetAccessibilityConstructor(self, [](Dali::Actor actor) {
+ return std::unique_ptr<Dali::Accessibility::Accessible>(
+ new DevelControl::AccessibleImpl(actor, Dali::Accessibility::Role::FILLER));
+ });
}
} // namespace Internal