#include <sstream>
#include <dali/public-api/object/ref-object.h>
#include <dali/public-api/object/type-registry.h>
-#include <dali/public-api/object/type-registry-helper.h>
-#include <dali/public-api/scripting/scripting.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>
* @param[in] actor The child actor to test against
* @param[dimension] The dimnesion to test against
*/
-bool FitToChild( Actor actor, Dimension dimension )
+bool FitToChild( Actor actor, Dimension::Type dimension )
{
- return actor.GetResizePolicy( dimension ) != FILL_TO_PARENT && actor.GetRelayoutSize( dimension ) > 0.0f;
+ return actor.GetResizePolicy( dimension ) != ResizePolicy::FILL_TO_PARENT && actor.GetRelayoutSize( dimension ) > 0.0f;
}
#if defined(DEBUG_ENABLED)
#define TABLEVIEW_TAG "DALI Toolkit::TableView "
#define TV_LOG(fmt, args...) Debug::LogMessage(Debug::DebugInfo, TABLEVIEW_TAG fmt, ## args)
+//#define TABLEVIEW_DEBUG 1
+#if defined(TABLEVIEW_DEBUG)
void PrintArray( Array2d<Dali::Toolkit::Internal::TableView::CellData>& array )
{
TV_LOG( "Array2d<CellData> size [%d,%d] \n", array.GetRows(), array.GetColumns() );
}
TV_LOG( "\n" );
}
+#endif // defined(TABLEVIEW_DEBUG)
#endif // defined(DEBUG_ENABLED)
} // namespace
// Setup properties, signals and actions using the type-registry.
DALI_TYPE_REGISTRATION_BEGIN( Toolkit::TableView, Toolkit::Control, Create );
-DALI_PROPERTY_REGISTRATION( TableView, "rows", UNSIGNED_INTEGER, ROWS )
-DALI_PROPERTY_REGISTRATION( TableView, "columns", UNSIGNED_INTEGER, COLUMNS )
-DALI_PROPERTY_REGISTRATION( TableView, "cell-padding", VECTOR2, CELL_PADDING )
-DALI_PROPERTY_REGISTRATION( TableView, "layout-rows", MAP, LAYOUT_ROWS )
-DALI_PROPERTY_REGISTRATION( TableView, "layout-columns", MAP, LAYOUT_COLUMNS )
+DALI_PROPERTY_REGISTRATION( Toolkit, TableView, "rows", UNSIGNED_INTEGER, ROWS )
+DALI_PROPERTY_REGISTRATION( Toolkit, TableView, "columns", UNSIGNED_INTEGER, COLUMNS )
+DALI_PROPERTY_REGISTRATION( Toolkit, TableView, "cell-padding", VECTOR2, CELL_PADDING )
+DALI_PROPERTY_REGISTRATION( Toolkit, TableView, "layout-rows", MAP, LAYOUT_ROWS )
+DALI_PROPERTY_REGISTRATION( Toolkit, TableView, "layout-columns", MAP, LAYOUT_COLUMNS )
DALI_TYPE_REGISTRATION_END()
-const Scripting::StringEnum< Toolkit::TableView::LayoutPolicy > LAYOUT_POLICY_STRING_TABLE[] =
+const Scripting::StringEnum LAYOUT_POLICY_STRING_TABLE[] =
{
{ "fixed", Toolkit::TableView::FIXED },
{ "relative", Toolkit::TableView::RELATIVE },
}
}
-void TableView::OnCalculateRelayoutSize( Dimension dimension )
+void TableView::OnCalculateRelayoutSize( Dimension::Type dimension )
{
CalculateRowColumnData();
- if( dimension & WIDTH )
+ if( dimension & Dimension::WIDTH )
{
- CalculateFixedSizes( mColumnData, WIDTH );
+ CalculateFixedSizes( mColumnData, Dimension::WIDTH );
mFixedTotals.width = CalculateTotalFixedSize( mColumnData );
}
- if( dimension & HEIGHT )
+ if( dimension & Dimension::HEIGHT )
{
- CalculateFixedSizes( mRowData, HEIGHT );
+ CalculateFixedSizes( mRowData, Dimension::HEIGHT );
mFixedTotals.height = CalculateTotalFixedSize( mRowData );
}
}
-void TableView::OnLayoutNegotiated( float size, Dimension dimension )
+void TableView::OnLayoutNegotiated( float size, Dimension::Type dimension )
{
CalculateRowColumnData();
// Calculate the value of all relative sized rows and columns
- if( dimension & WIDTH )
+ if( dimension & Dimension::WIDTH )
{
float remainingSize = size - mFixedTotals.width;
if( remainingSize < 0.0f )
CalculateRelativeSizes( mColumnData, remainingSize );
}
- if( dimension & HEIGHT )
+ if( dimension & Dimension::HEIGHT )
{
float remainingSize = size - mFixedTotals.height;
if( remainingSize < 0.0f )
void(TableView::*funcRelative)(unsigned int, float),
const Property::Value& value )
{
- if( Property::MAP == value.GetType() )
+ Property::Map* map = value.GetMap();
+ if( map )
{
- Property::Map map = value.Get<Property::Map>();
unsigned int rowIndex(0);
- for ( unsigned int i = 0, count = map.Count(); i < count; ++i )
+ for ( unsigned int i = 0, count = map->Count(); i < count; ++i )
{
- Property::Value& item = map.GetValue(i);
+ Property::Value& item = map->GetValue(i);
+ Property::Map* childMap = item.GetMap();
- if( std::istringstream(map.GetKey(i)) >> rowIndex // the key is a number
- && Property::MAP == item.GetType())
+ std::istringstream( map->GetKey(i) ) >> rowIndex;
+ if( childMap )
{
- if( item.HasKey( "policy" ) && item.HasKey( "value" ) )
+ Property::Value* policy = childMap->Find( "policy" );
+ Property::Value* value = childMap->Find( "value" );
+ if( policy && value )
{
- Toolkit::TableView::LayoutPolicy policy = Scripting::GetEnumeration< Toolkit::TableView::LayoutPolicy >( item.GetValue("policy").Get<std::string>().c_str(), LAYOUT_POLICY_STRING_TABLE, LAYOUT_POLICY_STRING_TABLE_COUNT );
- if( policy == Toolkit::TableView::FIXED )
+ std::string policyValue;
+ policy->Get( policyValue );
+ Toolkit::TableView::LayoutPolicy policy;
+ if( Scripting::GetEnumeration< Toolkit::TableView::LayoutPolicy >( policyValue.c_str(),
+ LAYOUT_POLICY_STRING_TABLE,
+ LAYOUT_POLICY_STRING_TABLE_COUNT,
+ policy ) )
{
- (tableViewImpl.*funcFixed)( rowIndex, item.GetValue("value").Get<float>() );
- }
- else if( policy == Toolkit::TableView::RELATIVE )
- {
- (tableViewImpl.*funcRelative)( rowIndex, item.GetValue("value").Get<float>() );
+ if( policy == Toolkit::TableView::FIXED )
+ {
+ (tableViewImpl.*funcFixed)( rowIndex, value->Get<float>() );
+ }
+ else if( policy == Toolkit::TableView::RELATIVE )
+ {
+ (tableViewImpl.*funcRelative)( rowIndex, value->Get<float>() );
+ }
}
}
}
void TableView::GetMapPropertyValue( const RowColumnArray& data, Property::Map& map )
{
- std::string fixedPolicy( Scripting::GetEnumerationName< Toolkit::TableView::LayoutPolicy >( Toolkit::TableView::FIXED, LAYOUT_POLICY_STRING_TABLE, LAYOUT_POLICY_STRING_TABLE_COUNT ) );
- std::string relativePolicy( Scripting::GetEnumerationName< Toolkit::TableView::LayoutPolicy >( Toolkit::TableView::RELATIVE, LAYOUT_POLICY_STRING_TABLE, LAYOUT_POLICY_STRING_TABLE_COUNT ) );
+ const char* name = Scripting::GetEnumerationName< Toolkit::TableView::LayoutPolicy >( Toolkit::TableView::FIXED,
+ LAYOUT_POLICY_STRING_TABLE,
+ LAYOUT_POLICY_STRING_TABLE_COUNT );
+ std::string fixedPolicy;
+ if( name )
+ {
+ fixedPolicy = name;
+ }
+ name = Scripting::GetEnumerationName< Toolkit::TableView::LayoutPolicy >( Toolkit::TableView::RELATIVE,
+ LAYOUT_POLICY_STRING_TABLE,
+ LAYOUT_POLICY_STRING_TABLE_COUNT );
+ std::string relativePolicy;
+ if( name )
+ {
+ relativePolicy = name;
+ }
const RowColumnArray::SizeType count = data.Size();
for( RowColumnArray::SizeType i = 0; i < count; i++ )
// nothing to do
}
-Actor TableView::GetNextKeyboardFocusableActor(Actor currentFocusedActor, Toolkit::Control::KeyboardFocusNavigationDirection direction, bool loopEnabled)
+Actor TableView::GetNextKeyboardFocusableActor(Actor currentFocusedActor, Toolkit::Control::KeyboardFocus::Direction direction, bool loopEnabled)
{
Actor nextFocusableActor;
switch ( direction )
{
- case Toolkit::Control::Left:
+ case Toolkit::Control::KeyboardFocus::LEFT:
{
if(--currentColumn < 0)
{
}
break;
}
- case Toolkit::Control::Right:
+ case Toolkit::Control::KeyboardFocus::RIGHT:
{
if(++currentColumn > numberOfColumns - 1)
{
}
break;
}
- case Toolkit::Control::Up:
+ case Toolkit::Control::KeyboardFocus::UP:
{
if(--currentRow < 0)
{
}
break;
}
- case Toolkit::Control::Down:
+ case Toolkit::Control::KeyboardFocus::DOWN:
{
if(++currentRow > numberOfRows - 1)
return Vector3( mFixedTotals.width, mFixedTotals.height, 1.0f );
}
-float TableView::CalculateChildSize( const Actor& child, Dimension dimension )
+float TableView::CalculateChildSize( const Actor& child, Dimension::Type dimension )
{
CalculateRowColumnData();
{
switch( dimension )
{
- case WIDTH:
+ case Dimension::WIDTH:
{
float cellSize = 0.0f;
return cellSize;
}
- case HEIGHT:
+ case Dimension::HEIGHT:
{
float cellSize = 0.0f;
return 0.0f; // Child not found
}
-bool TableView::RelayoutDependentOnChildren( Dimension dimension )
+bool TableView::RelayoutDependentOnChildren( Dimension::Type dimension )
{
if ( Control::RelayoutDependentOnChildren( dimension ) )
{
return totalSize;
}
-void TableView::CalculateFixedSizes( RowColumnArray& data, Dimension dimension )
+Vector2 TableView::GetCellPadding( Dimension::Type dimension )
{
+ switch( dimension )
+ {
+ case Dimension::WIDTH:
+ {
+ return Vector2( mPadding.x, mPadding.x );
+ }
+ case Dimension::HEIGHT:
+ {
+ return Vector2( mPadding.y, mPadding.y );
+ }
+ default:
+ {
+ break;
+ }
+ }
+
+ return Vector2();
+}
+
+void TableView::CalculateFixedSizes( RowColumnArray& data, Dimension::Type dimension )
+{
+ Vector2 cellPadding = GetCellPadding( dimension );
+
const unsigned int dataCount = data.Size();
for( unsigned int i = 0; i < dataCount; ++i )
// Find the size of the biggest actor in the row or column
float maxActorHeight = 0.0f;
- unsigned int fitCount = ( dimension == WIDTH ) ? mCellData.GetRows() : mCellData.GetColumns();
+ unsigned int fitCount = ( dimension == Dimension::WIDTH ) ? mCellData.GetRows() : mCellData.GetColumns();
for( unsigned int j = 0; j < fitCount; ++j )
{
- unsigned int row = ( dimension == WIDTH ) ? j : i;
- unsigned int column = ( dimension == WIDTH ) ? i : j;
+ unsigned int row = ( dimension == Dimension::WIDTH ) ? j : i;
+ unsigned int column = ( dimension == Dimension::WIDTH ) ? i : j;
DALI_ASSERT_DEBUG( row < mCellData.GetRows() );
DALI_ASSERT_DEBUG( column < mCellData.GetColumns() );
- Actor& actor = mCellData[ row ][ column ].actor;
+ const CellData& cellData = mCellData[ row ][ column ];
+ const Actor& actor = cellData.actor;
if( actor )
{
- if( FitToChild( actor, dimension ) )
+ if( FitToChild( actor, dimension ) && ( dimension == Dimension::WIDTH ) ? ( cellData.position.columnSpan == 1 ) : ( cellData.position.rowSpan == 1 ) )
{
- maxActorHeight = std::max( maxActorHeight, actor.GetRelayoutSize( dimension ) );
+ maxActorHeight = std::max( maxActorHeight, actor.GetRelayoutSize( dimension ) + cellPadding.x + cellPadding.y );
}
}
}