namespace
{
+/*
+ * Custom properties for where to put the actor.
+ *
+ * When an actor is add to the tableView through Actor::Add() instead of TableView::AddChild,
+ * the following custom properties of the actor are checked to decide the actor position inside the table
+ *
+ * These non-animatable properties should be registered to the child which would be added to the table
+ */
+const char * const CELL_INDEX_PROPERTY_NAME("cell-index");
+const char * const ROW_SPAN_PROPERTY_NAME("row-span");
+const char * const COLUMN_SPAN_PROPERTY_NAME("column-span");
+const char * const CELL_HORIZONTAL_ALIGNMENT_PROPERTY_NAME("cell-horizontal-alignment");
+const char * const CELL_VERTICAL_ALIGNMENT_PROPERTY_NAME("cell-vertical-alignment");
/**
* @brief Should the tableview fit around the given actor
*
* @param[in] actor The child actor to test against
- * @param[dimension] The dimnesion to test against
+ * @param[dimension] The dimension to test against
*/
bool FitToChild( Actor actor, Dimension::Type dimension )
{
{
{ "fixed", Toolkit::TableView::FIXED },
{ "relative", Toolkit::TableView::RELATIVE },
- { "fill", Toolkit::TableView::FILL }
+ { "fill", Toolkit::TableView::FILL },
+ { "fit", Toolkit::TableView::FIT }
};
-
const unsigned int LAYOUT_POLICY_STRING_TABLE_COUNT = sizeof(LAYOUT_POLICY_STRING_TABLE) / sizeof( LAYOUT_POLICY_STRING_TABLE[0] );
+const Scripting::StringEnum HORIZONTAL_ALIGNMENT_STRING_TABLE[] =
+{
+ {"left", HorizontalAlignment::LEFT},
+ {"center", HorizontalAlignment::CENTER},
+ {"right", HorizontalAlignment::RIGHT}
+};
+const unsigned int HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT = sizeof(HORIZONTAL_ALIGNMENT_STRING_TABLE) / sizeof( HORIZONTAL_ALIGNMENT_STRING_TABLE[0] );
+
+const Scripting::StringEnum VERTICAL_ALIGNMENT_STRING_TABLE[] =
+{
+ {"top", VerticalAlignment::TOP},
+ {"center", VerticalAlignment::CENTER},
+ {"bottom", VerticalAlignment::BOTTOM}
+};
+const unsigned int VERTICAL_ALIGNMENT_STRING_TABLE_COUNT = sizeof(VERTICAL_ALIGNMENT_STRING_TABLE) / sizeof( VERTICAL_ALIGNMENT_STRING_TABLE[0] );
+
} // Unnamed namespace
Toolkit::TableView TableView::New( unsigned int initialRows, unsigned int initialColumns )
DALI_ASSERT_ALWAYS( child );
// if child is already parented, we adopt it
- if( child.GetParent() )
- {
- child.GetParent().Remove( child );
- }
+ child.Unparent();
// check if we need to expand our data array
if( position.rowIndex >= mCellData.GetRows() )
return mPadding;
}
-void TableView::SetRowPolicy( unsigned int rowIndex, CellSizePolicy policy )
+void TableView::SetFitHeight( unsigned int rowIndex )
{
DALI_ASSERT_ALWAYS( rowIndex < mRowData.Size() );
- if( mRowData[ rowIndex ].sizePolicy != policy )
+ if( mRowData[ rowIndex ].sizePolicy != Toolkit::TableView::FIT )
{
- mRowData[ rowIndex ].sizePolicy = policy;
+ mRowData[ rowIndex ].sizePolicy = Toolkit::TableView::FIT;
mRowColumnDirty = true;
RelayoutRequest();
}
}
-TableView::CellSizePolicy TableView::GetRowPolicy( unsigned int rowIndex ) const
+bool TableView::IsFitHeight( unsigned int rowIndex ) const
{
DALI_ASSERT_ALWAYS( rowIndex < mRowData.Size() );
- return mRowData[ rowIndex ].sizePolicy;
+ return mRowData[ rowIndex ].sizePolicy == Toolkit::TableView::FIT;
}
-void TableView::SetColumnPolicy( unsigned int columnIndex, CellSizePolicy policy )
+void TableView::SetFitWidth( unsigned int columnIndex )
{
DALI_ASSERT_ALWAYS( columnIndex < mColumnData.Size() );
- if( mColumnData[ columnIndex ].sizePolicy != policy )
+ if( mColumnData[ columnIndex ].sizePolicy != Toolkit::TableView::FIT )
{
- mColumnData[ columnIndex ].sizePolicy = policy;
+ mColumnData[ columnIndex ].sizePolicy = Toolkit::TableView::FIT;
mRowColumnDirty = true;
RelayoutRequest();
}
}
-TableView::CellSizePolicy TableView::GetColumnPolicy( unsigned int columnIndex ) const
+bool TableView::IsFitWidth( unsigned int columnIndex ) const
{
DALI_ASSERT_ALWAYS( columnIndex < mColumnData.Size() );
- return mColumnData[ columnIndex ].sizePolicy;
+ return mColumnData[ columnIndex ].sizePolicy == Toolkit::TableView::FIT;
}
void TableView::SetFixedHeight( unsigned int rowIndex, float height )
RowColumnData& data = mRowData[ rowIndex ];
data.size = height;
- data.sizePolicy = FIXED;
+ data.sizePolicy = Toolkit::TableView::FIXED;
mRowColumnDirty = true;
RelayoutRequest();
RowColumnData& data = mColumnData[ columnIndex ];
data.size = width;
- data.sizePolicy = FIXED;
+ data.sizePolicy = Toolkit::TableView::FIXED;
mRowColumnDirty = true;
RelayoutRequest();
RowColumnData& data = mRowData[ rowIndex ];
data.fillRatio = heightPercentage;
- data.userFillRatio = true;
- data.sizePolicy = FILL;
+ data.sizePolicy = Toolkit::TableView::RELATIVE;
mRowColumnDirty = true;
RelayoutRequest();
RowColumnData& data = mColumnData[ columnIndex ];
data.fillRatio = widthPercentage;
- data.userFillRatio = true;
- data.sizePolicy = FILL;
+ data.sizePolicy = Toolkit::TableView::RELATIVE;
mRowColumnDirty = true;
RelayoutRequest();
{
CalculateRowColumnData();
- // Go through the layout data
- float cumulatedHeight = 0.0f;
-
- const unsigned int rowCount = mCellData.GetRows();
+ // update every column position in ColumnData array
+ float cumulatedWidth = 0.0f;
const unsigned int columnCount = mCellData.GetColumns();
+ for( unsigned int column = 0; column < columnCount; ++column )
+ {
+ mColumnData[column].position = cumulatedWidth;
+ cumulatedWidth += mColumnData[ column ].size;
+ }
+ // update every row position in RowData array
+ float cumulatedHeight = 0.0f;
+ const unsigned int rowCount = mCellData.GetRows();
for( unsigned int row = 0; row < rowCount; ++row )
{
- float cumulatedWidth = 0.0f;
+ mRowData[row].position = cumulatedHeight;
+ cumulatedHeight += mRowData[ row ].size;
+ }
+ // Go through the layout data
+ for( unsigned int row = 0; row < rowCount; ++row )
+ {
for( unsigned int column = 0; column < columnCount; ++column )
{
- Actor& actor = mCellData[ row ][ column ].actor;
- const Toolkit::TableView::CellPosition position = mCellData[ row ][ column ].position;
+ CellData& cellData= mCellData[ row ][ column ];
+ Actor& actor = cellData.actor;
+ const Toolkit::TableView::CellPosition position = cellData.position;
// If there is an actor and this is the main cell of the actor.
- // An actor can be in multiple cells if its row or columnspan is more than 1.
+ // An actor can be in multiple cells if its row or column span is more than 1.
// We however must lay out each actor only once.
- if( actor && ( position.rowIndex == row ) && ( position.columnIndex == column ) )
+ if( actor && position.rowIndex == row && position.columnIndex == column )
{
- // Anchor actor to top left of table view
+ // Anchor actor to top left of the cell
actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
actor.SetParentOrigin( ParentOrigin::TOP_LEFT );
+ Vector2( actor.GetRelayoutSize( Dimension::WIDTH ), actor.GetRelayoutSize( Dimension::HEIGHT ) );
+
Padding padding;
actor.GetPadding( padding );
- Vector3 actorPosition( cumulatedWidth + mPadding.width + padding.left, // Left padding
- cumulatedHeight + mPadding.height + padding.top, // Top padding
- 0.0f );
- actor.SetPosition( actorPosition );
- }
+ if( cellData.horizontalAlignment == HorizontalAlignment::LEFT )
+ {
+ actor.SetX( mColumnData[column].position + mPadding.width + padding.left );
+ }
+ else
+ {
+ float cellRightPosition = column+position.columnSpan < columnCount ? mColumnData[column+position.columnSpan].position : cumulatedWidth;
- DALI_ASSERT_DEBUG( column < mColumnData.Size() );
- cumulatedWidth += mColumnData[ column ].size;
- }
+ if( cellData.horizontalAlignment == HorizontalAlignment::RIGHT )
+ {
+ actor.SetX( cellRightPosition - mPadding.width - padding.right - actor.GetRelayoutSize( Dimension::WIDTH ) );
+ }
+ else //if( cellData.horizontalAlignment == HorizontalAlignment::CENTER )
+ {
+ actor.SetX( (mColumnData[column].position + cellRightPosition
+ + padding.left - padding.right
+ - actor.GetRelayoutSize( Dimension::WIDTH )) * 0.5f );
+ }
+ }
- DALI_ASSERT_DEBUG( row < mRowData.Size() );
- cumulatedHeight += mRowData[ row ].size;
+ if( cellData.verticalAlignment == VerticalAlignment::TOP )
+ {
+ actor.SetY( mRowData[row].position + mPadding.height + padding.top );
+ }
+ else
+ {
+ float cellBottomPosition = row+position.rowSpan < rowCount ? mRowData[row+position.rowSpan].position : cumulatedHeight;
+
+ if( cellData.verticalAlignment == VerticalAlignment::BOTTOM )
+
+ {
+ actor.SetY( cellBottomPosition - mPadding.height - padding.bottom - actor.GetRelayoutSize( Dimension::HEIGHT ) );
+ }
+ else //if( cellData.verticalAlignment = VerticalAlignment::CENTER )
+ {
+ actor.SetY( (mRowData[row].position + cellBottomPosition
+ + padding.top - padding.bottom
+ - actor.GetRelayoutSize( Dimension::HEIGHT )) * 0.5f );
+ }
+ }
+ }
+ }
}
}
}
case Toolkit::TableView::Property::LAYOUT_ROWS:
{
- SetHeightOrWidthProperty( tableViewImpl, &TableView::SetFixedHeight, &TableView::SetRelativeHeight, value );
+ SetHeightOrWidthProperty( tableViewImpl, &TableView::SetFixedHeight, &TableView::SetRelativeHeight, &TableView::SetFitHeight, value );
break;
}
case Toolkit::TableView::Property::LAYOUT_COLUMNS:
{
- SetHeightOrWidthProperty( tableViewImpl, &TableView::SetFixedWidth, &TableView::SetRelativeWidth, value );
+ SetHeightOrWidthProperty( tableViewImpl, &TableView::SetFixedWidth, &TableView::SetRelativeWidth, &TableView::SetFitWidth, value );
break;
}
}
return;
}
- RelayoutRequest();
-
// Test properties on actor
+ HorizontalAlignment::Type horizontalAlignment = HorizontalAlignment::LEFT;
+ VerticalAlignment::Type verticalAlignment = VerticalAlignment::TOP;
+ if( child.GetPropertyIndex( CELL_HORIZONTAL_ALIGNMENT_PROPERTY_NAME ) != Property::INVALID_INDEX )
+ {
+ std::string value = child.GetProperty( child.GetPropertyIndex(CELL_HORIZONTAL_ALIGNMENT_PROPERTY_NAME) ).Get<std::string >();
+ Scripting::GetEnumeration< HorizontalAlignment::Type >( value.c_str(),
+ HORIZONTAL_ALIGNMENT_STRING_TABLE,
+ HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT,
+ horizontalAlignment );
+ }
+ if( child.GetPropertyIndex( CELL_VERTICAL_ALIGNMENT_PROPERTY_NAME ) != Property::INVALID_INDEX )
+ {
+ std::string value = child.GetProperty( child.GetPropertyIndex(CELL_VERTICAL_ALIGNMENT_PROPERTY_NAME) ).Get<std::string >();
+ Scripting::GetEnumeration< VerticalAlignment::Type >( value.c_str(),
+ VERTICAL_ALIGNMENT_STRING_TABLE,
+ VERTICAL_ALIGNMENT_STRING_TABLE_COUNT,
+ verticalAlignment );
+ }
+
+
Toolkit::TableView::CellPosition cellPosition;
- if( child.GetPropertyIndex(Toolkit::TableView::ROW_SPAN_PROPERTY_NAME) != Property::INVALID_INDEX )
+ if( child.GetPropertyIndex(ROW_SPAN_PROPERTY_NAME) != Property::INVALID_INDEX )
{
- cellPosition.rowSpan = static_cast<unsigned int>( child.GetProperty( child.GetPropertyIndex(Toolkit::TableView::ROW_SPAN_PROPERTY_NAME) ).Get<float>() );
+ cellPosition.rowSpan = static_cast<unsigned int>( child.GetProperty( child.GetPropertyIndex(ROW_SPAN_PROPERTY_NAME) ).Get<float>() );
}
- if( child.GetPropertyIndex(Toolkit::TableView::COLUMN_SPAN_PROPERTY_NAME) != Property::INVALID_INDEX )
+ if( child.GetPropertyIndex(COLUMN_SPAN_PROPERTY_NAME) != Property::INVALID_INDEX )
{
- cellPosition.columnSpan = static_cast<unsigned int>( child.GetProperty( child.GetPropertyIndex(Toolkit::TableView::COLUMN_SPAN_PROPERTY_NAME) ).Get<float>() );
+ cellPosition.columnSpan = static_cast<unsigned int>( child.GetProperty( child.GetPropertyIndex(COLUMN_SPAN_PROPERTY_NAME) ).Get<float>() );
}
- if( child.GetPropertyIndex(Toolkit::TableView::CELL_INDICES_PROPERTY_NAME) != Property::INVALID_INDEX )
+ if( child.GetPropertyIndex(CELL_INDEX_PROPERTY_NAME) != Property::INVALID_INDEX )
{
- Vector2 indices = child.GetProperty( child.GetPropertyIndex(Toolkit::TableView::CELL_INDICES_PROPERTY_NAME) ).Get<Vector2 >();
+ Vector2 indices = child.GetProperty( child.GetPropertyIndex(CELL_INDEX_PROPERTY_NAME) ).Get<Vector2 >();
cellPosition.rowIndex = static_cast<unsigned int>( indices.x );
cellPosition.columnIndex = static_cast<unsigned int>( indices.y );
AddChild( child, cellPosition );
+ SetCellAlignment(cellPosition, horizontalAlignment, verticalAlignment);
// Do not continue
+ RelayoutRequest();
return;
}
data.actor = child;
data.position.columnIndex = column;
data.position.rowIndex = row;
+ data.horizontalAlignment = horizontalAlignment;
+ data.verticalAlignment = verticalAlignment;
mCellData[ row ][ column ] = data;
// Don't continue
+ RelayoutRequest();
return;
}
}
data.actor = child;
data.position.rowIndex = rowCount;
data.position.columnIndex = 0;
+ data.horizontalAlignment = horizontalAlignment;
+ data.verticalAlignment = verticalAlignment;
mCellData[ rowCount ][ 0 ] = data;
+ RelayoutRequest();
}
void TableView::OnControlChildRemove( Actor& child )
void TableView::SetHeightOrWidthProperty(TableView& tableViewImpl,
void(TableView::*funcFixed)(unsigned int, float),
void(TableView::*funcRelative)(unsigned int, float),
+ void(TableView::*funcFit)(unsigned int),
const Property::Value& value )
{
Property::Map* map = value.GetMap();
if( map )
{
- unsigned int rowIndex(0);
+ unsigned int index(0);
for ( unsigned int i = 0, count = map->Count(); i < count; ++i )
{
Property::Value& item = map->GetValue(i);
Property::Map* childMap = item.GetMap();
- std::istringstream( map->GetKey(i) ) >> rowIndex;
+ std::istringstream( map->GetKey(i) ) >> index;
if( childMap )
{
Property::Value* policy = childMap->Find( "policy" );
LAYOUT_POLICY_STRING_TABLE_COUNT,
policy ) )
{
- if( policy == Toolkit::TableView::FIXED )
+ if( policy == Toolkit::TableView::FIXED )
{
- (tableViewImpl.*funcFixed)( rowIndex, value->Get<float>() );
+ (tableViewImpl.*funcFixed)( index, value->Get<float>() );
}
else if( policy == Toolkit::TableView::RELATIVE )
{
- (tableViewImpl.*funcRelative)( rowIndex, value->Get<float>() );
+ (tableViewImpl.*funcRelative)( index, value->Get<float>() );
+ }
+ else if( policy == Toolkit::TableView::FIT )
+ {
+ (tableViewImpl.*funcFit)( index );
}
+ // do nothing for FILL policy
}
}
}
void TableView::GetMapPropertyValue( const RowColumnArray& data, Property::Map& map )
{
- 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 char* fixedPolicy = Scripting::GetEnumerationName< Toolkit::TableView::LayoutPolicy >( Toolkit::TableView::FIXED,
+ LAYOUT_POLICY_STRING_TABLE,
+ LAYOUT_POLICY_STRING_TABLE_COUNT );
+ const char* relativePolicy = Scripting::GetEnumerationName< Toolkit::TableView::LayoutPolicy >( Toolkit::TableView::RELATIVE,
+ LAYOUT_POLICY_STRING_TABLE,
+ LAYOUT_POLICY_STRING_TABLE_COUNT );
+ const char* fillPolicy = Scripting::GetEnumerationName< Toolkit::TableView::LayoutPolicy >( Toolkit::TableView::FILL,
+ LAYOUT_POLICY_STRING_TABLE,
+ LAYOUT_POLICY_STRING_TABLE_COUNT );
+ const char* fitPolicy = Scripting::GetEnumerationName< Toolkit::TableView::LayoutPolicy >( Toolkit::TableView::FIT,
+ LAYOUT_POLICY_STRING_TABLE,
+ LAYOUT_POLICY_STRING_TABLE_COUNT );
const RowColumnArray::SizeType count = data.Size();
for( RowColumnArray::SizeType i = 0; i < count; i++ )
{
const RowColumnData& dataInstance = data[ i ];
+ Property::Map item;
switch( dataInstance.sizePolicy )
{
- case FIXED:
+ case Toolkit::TableView::FIXED:
{
- Property::Map item;
item[ "policy" ] = fixedPolicy;
item[ "value" ] = dataInstance.size;
-
- std::ostringstream ss;
- ss << i;
-
- map[ ss.str() ] = item;
-
break;
}
-
- case FILL:
+ case Toolkit::TableView::RELATIVE:
{
- Property::Map item;
item[ "policy" ] = relativePolicy;
item[ "value" ] = dataInstance.fillRatio;
-
- std::ostringstream ss;
- ss << i;
-
- map[ ss.str() ] = item;
-
break;
}
-
+ case Toolkit::TableView::FIT:
+ {
+ item[ "policy" ] = fitPolicy;
+ item[ "value" ] = 0.f;
+ break;
+ }
+ case Toolkit::TableView::FILL:
default:
{
+ item[ "policy" ] = fillPolicy;
+ item[ "value" ] = 0.f;
break;
}
}
+ std::ostringstream ss;
+ ss << i;
+ map[ ss.str() ] = item;
}
}
}
// Apply padding
- cellSize -= mPadding.width * 2.0f;
+ cellSize -= mPadding.height * 2.0f;
if( cellSize < 0.0f )
{
cellSize = 0.0f;
{
RowColumnData& dataInstance = data[ i ];
- if( dataInstance.sizePolicy == FILL )
+ if( dataInstance.sizePolicy == Toolkit::TableView::RELATIVE )
{
- if( dataInstance.userFillRatio )
- {
- relativeTotal += dataInstance.fillRatio;
- }
- else
- {
- fillData.PushBack( &dataInstance );
- }
+ relativeTotal += dataInstance.fillRatio;
+ }
+ else if(dataInstance.sizePolicy == Toolkit::TableView::FILL)
+ {
+ fillData.PushBack( &dataInstance );
}
}
switch( dataInstance.sizePolicy )
{
- case FIXED:
- case FIT:
+ // we have absolute size to FIXED and FIT column/row and relative size for RELATIVE and FILL column/row
+ case Toolkit::TableView::FIXED:
+ case Toolkit::TableView::FIT:
{
totalSize += dataInstance.size;
break;
{
RowColumnData& dataInstance = data[ i ];
- if( dataInstance.sizePolicy == FIT )
+ if( dataInstance.sizePolicy == Toolkit::TableView::FIT )
{
// Find the size of the biggest actor in the row or column
float maxActorHeight = 0.0f;
{
RowColumnData& dataInstance = data[ i ];
- if( dataInstance.sizePolicy == FILL )
+ if( dataInstance.sizePolicy == Toolkit::TableView::FILL || dataInstance.sizePolicy == Toolkit::TableView::RELATIVE)
{
dataInstance.size = dataInstance.fillRatio * size;
}
{
for( unsigned int i = 0, count = data.Size(); i < count; ++i )
{
- if( data[ i ].sizePolicy == FIT )
+ if( data[ i ].sizePolicy == Toolkit::TableView::FIT )
{
return true;
}
public:
/**
- * Enum for the size policies of rows and columns
- */
- enum CellSizePolicy
- {
- FILL, ///< Fill up available space, may have a ratio associated with it
- FIXED, ///< A specific fixed width or height
- FIT ///< Fit around actors in the row or column
- };
-
- /**
* Create a new TableView.
* @return A smart-pointer to the newly allocated TableView.
*/
Size GetCellPadding();
/**
- * @brief Set a row policy
- *
- * @param[in] rowIndex The row to set the policy for
- * @param[in] policy The policy to set
+ * @copydoc Toolkit::TableView::SetFitHeight
*/
- void SetRowPolicy( unsigned int rowIndex, CellSizePolicy policy );
+ void SetFitHeight( unsigned int rowIndex );
/**
- * @brief Querry a row policy
- *
- * @param[in] rowIndex The row to querry
- * @return Return the policy
+ * @copydoc Toolkit::TableView::IsFitHeight
*/
- CellSizePolicy GetRowPolicy( unsigned int rowIndex ) const;
+ bool IsFitHeight( unsigned int rowIndex ) const;
/**
- * @brief Set a column policy
- *
- * @param[in] columnIndex The column to set the policy for
- * @param[in] policy The policy to set
+ * @copydoc Toolkit::TableView::SetFitWidth
*/
- void SetColumnPolicy( unsigned int columnIndex, CellSizePolicy policy );
+ void SetFitWidth( unsigned int columnIndex );
/**
- * @brief Querry a column policy
- *
- * @param[in] columnIndex The column to querry
- * @return Return the policy
+ * @copydoc Toolkit::TableView::IsFitWidth
*/
- CellSizePolicy GetColumnPolicy( unsigned int columnIndex ) const;
+ bool IsFitWidth( unsigned int columnIndex ) const;
/**
* @copydoc Toolkit::TableView::SetFixedWidth
RowColumnData()
: size( 0.0f ),
fillRatio( 0.0f ),
- sizePolicy( FILL ),
- userFillRatio( false )
+ position(0.0f),
+ sizePolicy( Toolkit::TableView::FILL )
{
}
* @param[in] newSize The size to set for this data
* @param[in] newSizePolicy The policy used to interpret the size value
*/
- RowColumnData( float newSize, float newFillRatio, CellSizePolicy newSizePolicy, bool newUserFillRatio )
+ RowColumnData( float newSize, float newFillRatio, Toolkit::TableView::LayoutPolicy newSizePolicy )
: size( newSize ),
fillRatio( newFillRatio ),
- sizePolicy( newSizePolicy ),
- userFillRatio( newUserFillRatio )
+ position(0.0f),
+ sizePolicy( newSizePolicy )
{
}
- float size; ///< Set or calculated size
- float fillRatio; ///< Ratio to fill remaining space
- CellSizePolicy sizePolicy; ///< The size policy used to interpret the size value
- bool userFillRatio : 1; ///< FillRatio was set by user
+ float size; ///< Set or calculated size
+ float fillRatio; ///< Ratio to fill remaining space, only valid with RELATIVE or FILL policy
+ float position; ///< Position of the row/column, this value is updated during every Relayout round
+ Toolkit::TableView::LayoutPolicy sizePolicy; ///< The size policy used to interpret the size value
};
typedef Dali::Vector<RowColumnData> RowColumnArray;
/**
* Called to set the heights/widths property.
* @param[in] tableViewImpl The object whose property is set.
- * @param[in] funcFixed The set function to call, it can be SetFixedHeight or SetFixedWidths.
- * @param[in] funcRelative The set function to call, it can be SetRelativeHeight or SetRelativeWidths.
+ * @param[in] funcFixed The set function to call, it can be SetFixedHeight or SetFixedWidth.
+ * @param[in] funcRelative The set function to call, it can be SetRelativeHeight or SetRelativeWidth.
+ * @param[in] funcFit The set function to call, it can be SetFitHeight or SetFiltWidth.
* @param[in] value The new property value.
*/
static void SetHeightOrWidthProperty( TableView& tableViewImpl,
void(TableView::*funcFixed)(unsigned int, float),
void(TableView::*funcRelative)(unsigned int, float),
+ void(TableView::*funcFit)(unsigned int),
const Property::Value& map );
/**
private: // Data
- Array2d<CellData> mCellData; ///< Data for each cell: Actor, alignment settings etc
+ Array2d<CellData> mCellData; ///< Data for each cell: Actor, alignment settings etc
RowColumnArray mRowData; ///< Data for each row
RowColumnArray mColumnData; ///< Data for each column
Size mPadding; ///< Padding to apply to each cell
bool mLayoutingChild; ///< Can't be a bitfield due to Relayouting lock
- bool mRowColumnDirty : 1; ///< Flag to indicate the row column data is dirty
+ bool mRowColumnDirty : 1; ///< Flag to indicate the row column data is dirty
};
} // namespace Internal
* TableView constrains the x and y position and width and height of the child actors.
* z position and depth are left intact so that 3D model actors can also be laid out
* in a grid without loosing their depth scaling.
+ *
+ * @nosubgrouping
+ *
+ * Per-child Custom properties for script supporting.
+ *
+ * When an actor is add to the tableView through Actor::Add() instead of TableView::AddChild,
+ * the following custom properties of the actor are checked to decide the actor position inside the table
+ *
+ * These properties are registered dynamically to the child and is non-animatable.
+ *
+ * | %Property Name | Type |
+ * |---------------------------|--------------------|
+ * | cell-index | Vector2 |
+ * | row-span | float | // type float (Currently builder is unable to differentiate integer and float from Json string)
+ * | column-span | float | // type float (Currently builder is unable to differentiate integer and float from Json string)
+ * | cell-horizontal-alignment | string | // available values: left, center, right
+ * | cell-vertical-alignment | string | // available values: top, center, bottom
+ *
+ * @code
+ * "name":"gallery-1",
+ * "type":"ImageActor",
+ * "image": {
+ * "filename": "{DALI_IMAGE_DIR}gallery-small-1.jpg"
+ * },
+ * "custom-properties": {
+ * "cell-index":[1,1], // property to specify the top-left cell this child occupies, if not set, the first available cell is used
+ * "row-span":3, // property to specify how many rows this child occupies, if not set, default value is 1
+ * "column-span": 2, // property to specify how many columns this child occupies, if nor set, default value is 1
+ * "cell-horizontal-alignment": "left", // property to specify how to align horizontally inside the cells, if not set, default value is 'left'
+ * "cell-vertical-alignment": "center" // property to specify how to align vertically inside the cells, if not set, default value is 'top'
+ * }
+ * @endcode
*/
class DALI_IMPORT_API TableView : public Control
{
* "layout-rows":
{
"0": { "policy": "fixed", "value": 40 }, //@see SetFixedHight
- "2": { "policy": "relative", "value": 0.33 } //@see SetRelativeHeight
+ "2": { "policy": "relative", "value": 0.33 }, //@see SetRelativeHeight
+ "3": { "policy": "fit", "value":0.0 } //@see SetFitHeight, the value is not used, its height is decided by the children in this row
}
* @endcode
*
* "layout-columns":
{
"0": { "policy": "fixed", "value": 40 }, //@see SetFixedWidth
+ "1": { "policy": "fit", "value":0.0 } //@see SetFitHeight, the value is not used, its width is decided by the children in this column
"2": { "policy": "relative", "value": 0.33 } //@see SetRelativeWidth
}
* @endcode
};
};
- // Custom properties for where to put the actor, these properties should be registered to the child which would be added to the table
- static const std::string CELL_INDICES_PROPERTY_NAME; ///< Property, name "cell-indices", type Vector2
- static const std::string ROW_SPAN_PROPERTY_NAME; ///< Property, name "row-span", type float (Currently builder is unable to differentiate integer and float from Json string)
- static const std::string COLUMN_SPAN_PROPERTY_NAME; ///< Property, name "column-span", type float (Currently builder is unable to differentiate integer and float from Json string)
-
/**
* @brief Describes how the size of a row / column been set
*/
{
FIXED, ///< Fixed with the given value.
RELATIVE, ///< Calculated as percentage of the remainder after subtracting Padding and Fixed height/width
- FILL ///< Get the remainder of the 100% (after subtracting Padding, Fixed and Relative height/ width) divided evenly between 'fill' rows/columns
+ FILL, ///< Default policy, get the remainder of the 100% (after subtracting Padding, Fixed and Relative height/ width) divided evenly between 'fill' rows/columns
+ FIT ///< Fit around its children.
};
/**
unsigned int GetColumns();
/**
- * @brief Set the alignment on a cell
+ * @brief Set the alignment on a cell.
+ *
+ * Cells without calling this function have the default values of LEFT and TOP respectively.
*
- * @param[in] position The cell to set alignment on
- * @param[in] horizontal The horizontal alignment
- * @param[in] vertical The vertical alignment
+ * @param[in] position The cell to set alignment on.
+ * @param[in] horizontal The horizontal alignment.
+ * @param[in] vertical The vertical alignment.
*/
void SetCellAlignment( CellPosition position, HorizontalAlignment::Type horizontal, VerticalAlignment::Type vertical );