Layout base gets and sets padding and margin using Control Properties.
Control::Property::PADDING
Control::Property::MARGIN
Extra logging and GetNaturalSize fix squashed in
Change-Id: I4a8acbb2bf9761fea153581a66c1f76d620f852b
END_TEST;
}
-
-
-
int UtcDaliLayouting_HboxLayout02(void)
{
ToolkitTestApplication application;
END_TEST;
}
-
-
-
int UtcDaliLayouting_HboxLayout04(void)
{
ToolkitTestApplication application;
END_TEST;
}
+// Padding tests
+
+int UtcDaliLayouting_HboxLayout_Padding01(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline("UtcDaliLayouting_HboxLayout_Padding01 - Adding Padding to a single child");
+
+ Stage stage = Stage::GetCurrent();
+ auto hbox = Control::New();
+ auto hboxLayout = HboxLayout::New();
+ DevelControl::SetLayout( hbox, hboxLayout );
+ hbox.SetName( "HBox");
+
+ std::vector< Control > controls;
+ controls.push_back( CreateLeafControl( 40, 40 ) );
+ controls.push_back( CreateLeafControl( 60, 40 ) );
+ controls.push_back( CreateLeafControl( 80, 40 ) );
+ controls.push_back( CreateLeafControl( 100, 40 ) );
+
+ const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
+ tet_printf( "\nAdding Padding to control at index %u \n", 1 );
+ controls[1].SetProperty(Toolkit::Control::Property::PADDING, CONTROL_PADDING );
+
+ for( auto&& iter : controls )
+ {
+ hbox.Add( iter );
+ }
+ hbox.SetParentOrigin( ParentOrigin::CENTER );
+ hbox.SetAnchorPoint( AnchorPoint::CENTER );
+ stage.Add( hbox );
+
+ // Ensure layouting happens
+ application.SendNotification();
+ application.Render();
+
+ // hbox centers elements vertically, it fills test harness stage, which is 480x800.
+ // hbox left justifies elements
+ tet_infoline("Test Child Actor Position");
+ float xPositionOfControlBeingTested = 0.0f;
+ DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
+ 380.0f,
+ 0.0f ), 0.0001f, TEST_LOCATION );
+ xPositionOfControlBeingTested += 40.0f;
+
+ DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
+ 380.0f - ( ( CONTROL_PADDING.top + CONTROL_PADDING.bottom) * 0.5f ), 0.0f ),
+ 0.0001f, TEST_LOCATION );
+
+ xPositionOfControlBeingTested += 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
+ DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+
+ xPositionOfControlBeingTested += 80.0f;
+ DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+
+ tet_infoline("Test Child Actor Size");
+ DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+
+ DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
+ 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom , 0.0f ),
+ 0.0001f, TEST_LOCATION );
+
+ DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+ DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliLayouting_HboxLayout_Padding02(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline("UtcDaliLayouting_HboxLayout_Padding02 - Adding Padding to a all children");
+
+ Stage stage = Stage::GetCurrent();
+ auto hbox = Control::New();
+ auto hboxLayout = HboxLayout::New();
+ DevelControl::SetLayout( hbox, hboxLayout );
+ hbox.SetName( "HBox");
+
+ std::vector< Control > controls;
+ controls.push_back( CreateLeafControl( 40, 40 ) );
+ controls.push_back( CreateLeafControl( 60, 40 ) );
+ controls.push_back( CreateLeafControl( 80, 40 ) );
+ controls.push_back( CreateLeafControl( 100, 40 ) );
+
+ const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
+
+ for( auto&& iter : controls )
+ {
+ iter.SetProperty(Toolkit::Control::Property::PADDING, CONTROL_PADDING );
+ hbox.Add( iter );
+ }
+ hbox.SetParentOrigin( ParentOrigin::CENTER );
+ hbox.SetAnchorPoint( AnchorPoint::CENTER );
+ stage.Add( hbox );
+
+ // Ensure layouting happens
+ application.SendNotification();
+ application.Render();
+
+ // hbox centers elements vertically, it fills test harness stage, which is 480x800.
+ // hbox left justifies elements
+ tet_infoline("Test Child Actor Position");
+ float xPositionOfControlBeingTested = 0.0f;
+ float yPositionOfControlBeingTested = ( 800.0f * 0.5) - ( 0.5 * ( 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom ) );
+
+ DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
+ yPositionOfControlBeingTested,
+ 0.0f ), 0.0001f, TEST_LOCATION );
+ xPositionOfControlBeingTested += 40.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
+
+ DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
+ yPositionOfControlBeingTested,
+ 0.0f ),
+ 0.0001f, TEST_LOCATION );
+
+ xPositionOfControlBeingTested += 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
+ DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
+ yPositionOfControlBeingTested,
+ 0.0f ), 0.0001f, TEST_LOCATION );
+
+ xPositionOfControlBeingTested += 80.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
+ DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
+ yPositionOfControlBeingTested,
+ 0.0f ), 0.0001f, TEST_LOCATION );
+
+ tet_infoline("Test Child Actor Size");
+ DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
+ 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
+ 0.0f ), 0.0001f, TEST_LOCATION );
+
+ DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
+ 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
+ 0.0f ), 0.0001f, TEST_LOCATION );
+
+ DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f + CONTROL_PADDING.start + CONTROL_PADDING.end ,
+ 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
+ 0.0f ), 0.0001f, TEST_LOCATION );
+
+ DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
+ 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
+ 0.0f ), 0.0001f, TEST_LOCATION );
+
+ END_TEST;
+}
+
+
+int UtcDaliLayouting_HboxLayout_Padding03(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline("UtcDaliLayouting_HboxLayout_Padding03 - Adding Changing padding on a single child");
+
+ Stage stage = Stage::GetCurrent();
+ auto hbox = Control::New();
+ auto hboxLayout = HboxLayout::New();
+ DevelControl::SetLayout( hbox, hboxLayout );
+ hbox.SetName( "HBox");
+
+ std::vector< Control > controls;
+ controls.push_back( CreateLeafControl( 40, 40 ) );
+ controls.push_back( CreateLeafControl( 40, 40 ) );
+ controls.push_back( CreateLeafControl( 40, 40 ) );
+
+ const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
+ tet_printf( "\nAdding Padding to control at index 1 \n" );
+ controls[1].SetProperty(Toolkit::Control::Property::PADDING, CONTROL_PADDING );
+
+ for( auto&& iter : controls )
+ {
+ hbox.Add( iter );
+ }
+ hbox.SetParentOrigin( ParentOrigin::CENTER );
+ hbox.SetAnchorPoint( AnchorPoint::CENTER );
+ stage.Add( hbox );
+
+ // Ensure layouting happens
+ application.SendNotification();
+ application.Render();
+
+ // hbox centers elements vertically, it fills test harness stage, which is 480x800.
+ // hbox left justifies elements
+ tet_infoline("Test Child Actor Position");
+ float xPositionOfControlBeingTested = 0.0f;
+ DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
+ 380.0f,
+ 0.0f ), 0.0001f, TEST_LOCATION );
+ xPositionOfControlBeingTested += 40.0f;
+
+ DALI_TEST_EQUALS( controls[ 1 ].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
+ 380.0f - ( ( CONTROL_PADDING.top + CONTROL_PADDING.bottom) * 0.5f ), 0.0f ),
+ 0.0001f, TEST_LOCATION );
+
+ xPositionOfControlBeingTested += 40.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
+ DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+
+ const Extents NEW_CONTROL_PADDING = Extents(10, 10, 20, 2 );
+ tet_printf( "\nChanging Padding to control at index 1 \n" );
+ controls[1].SetProperty(Toolkit::Control::Property::PADDING, NEW_CONTROL_PADDING );
+
+ // Ensure layouting happens
+ application.SendNotification();
+ application.Render();
+
+ xPositionOfControlBeingTested = 0.0f; // reset
+
+ tet_infoline("Test Child Actor Position");
+ DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
+ 380.0f,
+ 0.0f ), 0.0001f, TEST_LOCATION );
+ xPositionOfControlBeingTested += 40.0f;
+
+ DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
+ 380.0f - ( ( NEW_CONTROL_PADDING.top + NEW_CONTROL_PADDING.bottom) * 0.5f ), 0.0f ),
+ 0.0001f, TEST_LOCATION );
+
+ xPositionOfControlBeingTested += 40.0f + NEW_CONTROL_PADDING.start + NEW_CONTROL_PADDING.end;
+ tet_printf( "\nIf x position %u then change has not been processed \n", 40 + 40 + CONTROL_PADDING.start + CONTROL_PADDING.end );
+ DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+
+ tet_infoline("Test Child Actor Size");
+ DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ) , Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+
+ DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ) , Vector3( 40.0f + NEW_CONTROL_PADDING.start + NEW_CONTROL_PADDING.end,
+ 40.0f + NEW_CONTROL_PADDING.top + NEW_CONTROL_PADDING.bottom , 0.0f ),
+ 0.0001f, TEST_LOCATION );
+
+ DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ) , Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+
+ END_TEST;
+}
+
+// Margin Tests
+
+int UtcDaliLayouting_HboxLayout_Margin01(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline("UtcDaliLayouting_HboxLayout_Margin01 - Adding a margin to a single child");
+
+ Stage stage = Stage::GetCurrent();
+ auto hbox = Control::New();
+ auto hboxLayout = HboxLayout::New();
+ DevelControl::SetLayout( hbox, hboxLayout );
+ hbox.SetName( "HBox");
+
+ std::vector< Control > controls;
+ controls.push_back( CreateLeafControl( 40, 40 ) );
+ controls.push_back( CreateLeafControl( 60, 40 ) );
+ controls.push_back( CreateLeafControl( 80, 40 ) );
+ controls.push_back( CreateLeafControl( 100, 40 ) );
+
+ const Extents CONTROL_MARGIN = Extents(5, 10, 20, 0 );
+ tet_printf( "\nAdding Margin to control at index 1 \n" );
+ controls[1].SetProperty(Toolkit::Control::Property::MARGIN, CONTROL_MARGIN );
+
+ for( auto&& iter : controls )
+ {
+ hbox.Add( iter );
+ }
+ hbox.SetParentOrigin( ParentOrigin::CENTER );
+ hbox.SetAnchorPoint( AnchorPoint::CENTER );
+ stage.Add( hbox );
+
+ // Ensure layouting happens
+ application.SendNotification();
+ application.Render();
+
+ // hbox centers elements vertically, it fills test harness stage, which is 480x800.
+ // hbox left justifies elements
+ tet_infoline("Test Child Actor Position");
+ auto xPositionOfControlBeingTested = 0.0f;
+ DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
+ 380.0f,
+ 0.0f ), 0.0001f, TEST_LOCATION );
+ xPositionOfControlBeingTested += 40.0f + CONTROL_MARGIN.start;
+
+ DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
+ 380.0f + CONTROL_MARGIN.top, 0.0f ),
+ 0.0001f, TEST_LOCATION );
+
+ xPositionOfControlBeingTested += 60.0f + CONTROL_MARGIN.end;
+ DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+
+ xPositionOfControlBeingTested += 80.0f;
+ DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+
+ tet_infoline("Test Child Actor Size is the same after Margin added");
+ DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+ DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f , 0.0f ), 0.0001f, TEST_LOCATION );
+ DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+ DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+
+ END_TEST;
+}
+
int UtcDaliLayouting_VboxLayout01(void)
{
*/
// CLASS HEADER
+#include <dali-toolkit/devel-api/layouting/layout-group-impl.h>
+
+// EXTERNAL INCLUDES
#include <dali/public-api/object/type-registry-helper.h>
#include <dali/devel-api/actors/actor-devel.h>
#include <dali/devel-api/object/handle-devel.h>
-#include <dali-toolkit/devel-api/layouting/layout-group-impl.h>
+#include <dali/integration-api/debug.h>
+
+// INTERNAL INCLUDES
#include <dali-toolkit/internal/layouting/layout-group-data-impl.h>
#include <dali-toolkit/public-api/controls/control-impl.h>
#include <dali-toolkit/internal/controls/control/control-data-impl.h>
-
namespace
{
-const char* MARGIN_SPECIFICATION_NAME( "marginSpec" );
+#if defined(DEBUG_ENABLED)
+Debug::Filter* gLogFilter = Debug::Filter::New( Debug::Concise, false, "LOG_LAYOUT" );
+#endif
}
namespace Dali
void LayoutGroup::OnSetChildProperties( Handle& handle, Property::Index index, Property::Value value )
{
- if ( ( index >= CHILD_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= CHILD_PROPERTY_REGISTRATION_MAX_INDEX ) )
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutGroup::OnSetChildProperties");
+
+ if ( ( ( index >= CHILD_PROPERTY_REGISTRATION_START_INDEX ) &&
+ ( index <= CHILD_PROPERTY_REGISTRATION_MAX_INDEX ) )
+ ||
+ ( index == Toolkit::Control::Property::MARGIN || index == Toolkit::Control::Property::PADDING ) )
{
// If any child properties are set, must perform relayout
RequestLayout();
Toolkit::ChildLayoutData::WRAP_CONTENT );
child.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION,
Toolkit::ChildLayoutData::WRAP_CONTENT );
- child.SetProperty( Toolkit::LayoutGroup::ChildProperty::MARGIN_SPECIFICATION, Extents() );
}
void LayoutGroup::MeasureChildren( MeasureSpec widthMeasureSpec, MeasureSpec heightMeasureSpec)
MeasureSpec parentWidthMeasureSpec,
MeasureSpec parentHeightMeasureSpec )
{
+ DALI_LOG_TRACE_METHOD( gLogFilter );
+
auto childOwner = child->GetOwner();
+
+ auto control = Toolkit::Control::DownCast( childOwner );
+
+#if defined( DEBUG_ENABLED )
+ if ( control )
+ {
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutGroup::MeasureChildWithMargins naturalSizewidth(%f)\n", control.GetNaturalSize().width );
+ }
+#endif
+
+ // Get last stored width and height specifications for the child
auto desiredWidth = childOwner.GetProperty<int>( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION );
auto desiredHeight = childOwner.GetProperty<int>( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION );
- auto padding = GetPadding();
+ // The size of the control could have changed due to padding being altered, the XXX_SPECIFICATIONs will not have been updated.
+ // So GetNaturalSize is called, if the control's natural size includes padding then th size will be updated.
+ if ( control )
+ {
+ auto desiredSize = control.GetNaturalSize(); // Get's child control's size which could include new padding values.
+
+ // Check if WIDTH_SPECIFICATION was a size value, if so then get update to child controls's width.
+ if ( desiredWidth > 0 )
+ {
+ desiredWidth = desiredSize.width;
+ childOwner.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, LayoutLength::IntType( desiredWidth ) );
+ }
+
+ // Check if HEIGHT_SPECIFICATION was a size value, if so then get update to child controls's height.
+ if ( desiredHeight > 0)
+ {
+ desiredHeight = desiredSize.height;
+ childOwner.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, LayoutLength::IntType( desiredHeight ) );
+ }
+ }
+
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutGroup::MeasureChild desiredWidth(%d)\n", desiredWidth );
+
+ auto padding = GetPadding(); // Padding of this layout's owner, not of the child being measured.
const MeasureSpec childWidthMeasureSpec = GetChildMeasureSpec( parentWidthMeasureSpec,
padding.start + padding.end,
auto childOwner = child->GetOwner();
auto desiredWidth = childOwner.GetProperty<int>( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION );
auto desiredHeight = childOwner.GetProperty<int>( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION );
- auto desiredMargin = childOwner.GetProperty<Extents>( Toolkit::LayoutGroup::ChildProperty::MARGIN_SPECIFICATION );
- auto padding = GetPadding();
+
+ auto padding = GetPadding(); // Padding of this layout's owner, not of the child being measured.
+
+
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutGroup::MeasureChildWithMargins desiredWidth(%d)\n", desiredWidth );
MeasureSpec childWidthMeasureSpec = GetChildMeasureSpec( parentWidthMeasureSpec,
padding.start + padding.end +
- desiredMargin.start + desiredMargin.end +
widthUsed, desiredWidth );
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutGroup::MeasureChildWithMargins desiredHeight(%d)\n", desiredHeight );
+
MeasureSpec childHeightMeasureSpec = GetChildMeasureSpec( parentHeightMeasureSpec,
padding.top + padding.bottom +
- desiredMargin.top + desiredMargin.end +
heightUsed, desiredHeight );
child->Measure( childWidthMeasureSpec, childHeightMeasureSpec );
auto specMode = measureSpec.GetMode();
LayoutLength specSize = measureSpec.GetSize();
- auto size = std::max( LayoutLength(0), specSize - padding );
+ auto size = std::max( LayoutLength(0), specSize - padding ); // reduce available size by the owners padding
MeasureSpec::IntType resultSize = 0;
MeasureSpec::Mode resultMode = MeasureSpec::Mode::UNSPECIFIED;
// Parent has imposed an exact size on us
case MeasureSpec::Mode::EXACTLY:
{
-
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutGroup::GetChildMeasureSpec MeasureSpec::Mode::EXACTLY\n");
if (childDimension == Toolkit::ChildLayoutData::MATCH_PARENT)
{
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutGroup::GetChildMeasureSpec childDimension MATCH_PARENT\n");
+
// Child wants to be our size. So be it.
resultSize = size;
resultMode = MeasureSpec::Mode::EXACTLY;
}
else if (childDimension == Toolkit::ChildLayoutData::WRAP_CONTENT)
{
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutGroup::GetChildMeasureSpec childDimension WRAP_CONTENT\n");
+
// Child wants to determine its own size. It can't be
// bigger than us.
resultSize = size;
}
else
{
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutGroup::GetChildMeasureSpec childDimension UNSPECIFIED\n");
resultSize = childDimension;
resultMode = MeasureSpec::Mode::EXACTLY;
}
// Parent has imposed a maximum size on us
case MeasureSpec::Mode::AT_MOST:
{
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutGroup::GetChildMeasureSpec MeasureSpec::Mode::AT_MOST\n");
if (childDimension == Toolkit::ChildLayoutData::MATCH_PARENT)
{
// Child wants to be our size, but our size is not fixed.
else
{
// Child wants a specific size... so be it
- resultSize = childDimension;
+ resultSize = childDimension + padding;
resultMode = MeasureSpec::Mode::EXACTLY;
}
// Parent asked to see how big we want to be
case MeasureSpec::Mode::UNSPECIFIED:
{
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutGroup::GetChildMeasureSpec MeasureSpec::Mode::UNSPECIFIED\n");
+
if (childDimension == Toolkit::ChildLayoutData::MATCH_PARENT)
{
// Child wants to be our size... find out how big it should be
else
{
// Child wants a specific size... let him have it
- resultSize = childDimension;
+ resultSize = childDimension + padding;
resultMode = MeasureSpec::Mode::EXACTLY;
}
break;
}
}
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutGroup::GetChildMeasureSpec resultSize(%u)\n", resultSize );
+
+
//noinspection ResourceType
return MeasureSpec( resultSize, resultMode );
}
void LayoutGroup::OnRegisterChildProperties( const std::string& containerType )
{
- auto typeInfo = TypeRegistry::Get().GetTypeInfo( containerType );
- if( typeInfo )
- {
- Property::IndexContainer indices;
- typeInfo.GetChildPropertyIndices( indices );
-
- if( std::find( indices.Begin(), indices.End(), Toolkit::LayoutGroup::ChildProperty::MARGIN_SPECIFICATION ) ==
- indices.End() )
- {
- ChildPropertyRegistration( typeInfo.GetName(), MARGIN_SPECIFICATION_NAME, Toolkit::LayoutGroup::ChildProperty::MARGIN_SPECIFICATION, Property::EXTENTS );
- }
- }
-
DoRegisterChildProperties( containerType );
}
{
LayoutItemPtr childLayout;
Toolkit::Control control = Toolkit::Control::DownCast( child );
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutGroup::ChildAddedToOwner(%s)\n", control.GetName().c_str() );
if( control ) // Can only support adding Controls, not Actors to layout
{
childLayout->SetAnimateLayout( IsLayoutAnimated() ); // @todo this essentially forces animation inheritance. Bad?
auto desiredSize = control.GetNaturalSize();
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutGroup::ChildAddedToOwner desiredSize(%f,%f) (naturalSize)\n", desiredSize.width, desiredSize.height );
+
childControlDataImpl.SetLayout( *childLayout.Get() );
- // HBoxLayout will apply default layout data for this object
+ // Default layout data for this object
child.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, LayoutLength::IntType( desiredSize.width ) );
child.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, LayoutLength::IntType( desiredSize.height ) );
- child.SetProperty( Toolkit::LayoutGroup::ChildProperty::MARGIN_SPECIFICATION, Extents() );
}
Add( *childLayout.Get() );
void LayoutGroup::OnOwnerPropertySet( Handle& handle, Property::Index index, Property::Value value )
{
+ DALI_LOG_INFO( gLogFilter, Debug::Concise, "LayoutGroup::OnOwnerPropertySet\n");
auto actor = Actor::DownCast( handle );
- if( actor && index == Actor::Property::LAYOUT_DIRECTION )
+ if( actor &&
+ (
+ index == Actor::Property::LAYOUT_DIRECTION ||
+ index == Toolkit::Control::Property::PADDING ||
+ index == Toolkit::Control::Property::MARGIN
+ )
+ )
{
RequestLayout();
}
}
-
} // namespace Internal
} // namespace Toolkit
} // namespace Dali
#include <dali-toolkit/devel-api/layouting/layout-item-impl.h>
#include <dali-toolkit/internal/layouting/layout-item-data-impl.h>
+namespace
+{
+
#if defined(DEBUG_ENABLED)
- Debug::Filter* gLayoutFilter = Debug::Filter::New( Debug::Verbose, false, "LOG_LAYOUT" );
+Debug::Filter* gLayoutFilter = Debug::Filter::New( Debug::Verbose, false, "LOG_LAYOUT" );
#endif
-namespace
-{
const char* WIDTH_SPECIFICATION_NAME( "widthSpecification" );
const char* HEIGHT_SPECIFICATION_NAME( "heightSpecification" );
void LayoutItem::Measure( MeasureSpec widthMeasureSpec, MeasureSpec heightMeasureSpec )
{
+ DALI_LOG_TRACE_METHOD( gLayoutFilter );
+
const bool forceLayout = mImpl->GetPrivateFlag( Impl::PRIVATE_FLAG_FORCE_LAYOUT );
const bool specChanged =
Extents LayoutItem::GetPadding() const
{
- return mImpl->mPadding;
+ Toolkit::Control control = Toolkit::Control::DownCast( mImpl->mOwner );
+ if( control )
+ {
+ Extents padding = control.GetProperty<Extents>( Toolkit::Control::Property::PADDING );
+
+ DALI_LOG_INFO( gLayoutFilter, Debug::Verbose, "LayoutBase::Padding for %s : (%d,%d,%d,%d) \n",
+ control.GetName().c_str(),
+ padding.start, padding.end, padding.top, padding.bottom
+ );
+ return padding;
+ }
+ else
+ {
+ return Extents();
+ }
+}
+
+Extents LayoutItem::GetMargin() const
+{
+ Toolkit::Control control = Toolkit::Control::DownCast( mImpl->mOwner );
+ if ( control )
+ {
+ return control.GetProperty<Extents>( Toolkit::Control::Property::MARGIN );
+ }
+ else
+ {
+ return Extents();
+ }
}
LayoutLength LayoutItem::GetDefaultSize( LayoutLength size, MeasureSpec measureSpec )
void LayoutItem::SetMeasuredDimensions( MeasuredSize measuredWidth, MeasuredSize measuredHeight )
{
+ DALI_LOG_INFO( gLayoutFilter, Debug::Verbose, "LayoutBase::SetMeasuredDimensions width(%d) height(%d) \n",
+ MeasureSpec::IntType( measuredWidth.GetSize() ),
+ MeasureSpec::IntType( measuredHeight.GetSize() )
+ );
+
mImpl->SetPrivateFlag( Impl::PRIVATE_FLAG_MEASURED_DIMENSION_SET );
mImpl->mMeasuredWidth = measuredWidth;
mImpl->mMeasuredHeight = measuredHeight;
LayoutLength GetMinimumHeight() const;
/**
- * Get the padding information
+ * Get the padding information.
* @return The padding information
*/
Extents GetPadding() const;
+ /**
+ * Get the margin information.
+ * @return The margin information
+ */
+ Extents GetMargin() const;
+
protected:
/**
* @brief Allow directly deriving classes to remove layout children when unparented
*/
virtual void OnRegisterChildProperties( const std::string& containerType );
-
/**
* @brief Measure the layout and its content to determine the measured width and the
* measured height.
#include <dali-toolkit/public-api/controls/control-impl.h>
#include <dali-toolkit/internal/controls/control/control-data-impl.h>
-
+namespace
+{
#if defined(DEBUG_ENABLED)
static Debug::Filter* gLogFilter = Debug::Filter::New( Debug::Concise, false, "LOG_LAYOUT" );
#endif
+}
namespace Dali
{
DALI_LOG_INFO( gLogFilter, Debug::Concise, oss.str().c_str() );
#endif
+ DALI_LOG_INFO( gLogFilter, Debug::Concise, "HboxLayout::OnMeasure widthSize(%d) \n", widthMeasureSpec.GetSize());
+
auto widthMode = widthMeasureSpec.GetMode();
auto heightMode = heightMeasureSpec.GetMode();
bool isExactly = (widthMode == MeasureSpec::Mode::EXACTLY);
auto childOwner = childLayout->GetOwner();
auto desiredHeight = childOwner.GetProperty<int>( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION );
- MeasureChildWithMargins( childLayout, widthMeasureSpec, 0, heightMeasureSpec, 0 );
+ MeasureChild( childLayout, widthMeasureSpec, heightMeasureSpec );
auto childWidth = childLayout->GetMeasuredWidth();
- auto childMargin = childOwner.GetProperty<Extents>( Toolkit::LayoutGroup::ChildProperty::MARGIN_SPECIFICATION );
+ auto childMargin = childLayout->GetMargin();
+
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "HboxLayout::OnMeasure childWidth(%d)\n", MeasureSpec::IntType( childWidth ) );
+
auto length = childWidth + LayoutLength::IntType(childMargin.start + childMargin.end);
auto cellPadding = i<GetChildCount()-1 ? mCellPadding.width: 0;
auto childWidth = childLayout->GetMeasuredWidth();
auto childHeight = childLayout->GetMeasuredHeight();
- auto childOwner = childLayout->GetOwner();
- auto childMargin = childOwner.GetProperty<Extents>( Toolkit::LayoutGroup::ChildProperty::MARGIN_SPECIFICATION );
+ auto childMargin = childLayout->GetMargin();
childTop = LayoutLength(padding.top) + ((childSpace - childHeight) / 2) + childMargin.top - childMargin.bottom;
using namespace Dali;
+namespace
+{
+
#if defined(DEBUG_ENABLED)
static Debug::Filter* gLogFilter = Debug::Filter::New( Debug::Concise, false, "LOG_LAYOUT" );
#endif
+}
+
namespace Dali
{
namespace Toolkit
Toolkit::Control control = Toolkit::Control::DownCast( root );
if( control )
{
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutController::Measuring leaf\n" );
Internal::Control& controlImpl = GetImplementation( control );
+
Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get( controlImpl );
LayoutItemPtr layout = controlDataImpl.GetLayout();
}
else
{
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutController::Measuring (%u) children\n", root.GetChildCount() );
// Depth first descent through actor children
for( unsigned int i = 0, count = root.GetChildCount(); i < count; ++i )
{
Toolkit::Control control = Toolkit::Control::DownCast( root );
if( control )
{
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutController::PerformLayout on leaf\n" );
Internal::Control& controlImpl = GetImplementation( control );
Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get( controlImpl );
LayoutItemPtr layout = controlDataImpl.GetLayout();
if( layout )
{
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutController::PerformLayout on layout\n" );
layout->Layout( left, top, right, bottom );
}
}
else
{
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutController::PerformLayout (%u) children\n", root.GetChildCount() );
// Depth first descent through actor children
for( unsigned int i = 0, count = root.GetChildCount(); i < count; ++i )
{
mBottom( 0 ),
mViewFlags( 0 ),
mPrivateFlags( 0 ),
- mAnimated(false)
+ mAnimated( false )
{
}
MeasuredSize mMeasuredWidth;
MeasuredSize mMeasuredHeight;
- Extents mMargin; ///< Distances in pixels from the edges of this view to this view's parent.
- Extents mPadding; ///< Distances in pixels from the edges of this view to this view's content.
-
LayoutLength mLeft;
LayoutLength mRight;
LayoutLength mTop;
//CLASS HEADER
#include <dali-toolkit/internal/layouting/vbox-layout-impl.h>
-//EXTERNAL HEADERS
//INTERNAL HEADERS
#include <dali/integration-api/debug.h>
#include <dali/public-api/common/extents.h>
#include <dali-toolkit/public-api/controls/control-impl.h>
#include <dali-toolkit/internal/controls/control/control-data-impl.h>
-
+namespace
+{
#if defined(DEBUG_ENABLED)
static Debug::Filter* gLogFilter = Debug::Filter::New( Debug::Concise, false, "LOG_LAYOUT" );
#endif
+}
namespace Dali
{
alternativeMaxWidth = std::max( alternativeMaxWidth, matchWidthLocally ? marginWidth : childWidth );
}
}
-
Extents padding = GetPadding();
mTotalLength += padding.top + padding.bottom;
auto heightSize = mTotalLength;
void VboxLayout::OnLayout( bool changed, LayoutLength left, LayoutLength top, LayoutLength right, LayoutLength bottom )
{
- auto owner = GetOwner();
Extents padding = GetPadding();
LayoutLength childTop( 0 );