DevelControl::SetLayout( hbox, hboxLayout );
hbox.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 600 );
hbox.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
+ DevelControl::SetLayoutingRequired( hbox, true );
hbox.SetAnchorPoint( AnchorPoint::TOP_LEFT ); // LinearLayout will eventually do this internally.
- tet_infoline("Add a control without SetLayout being called");
+ tet_infoline("Add a control without SetLayout being called but with layout required set true");
auto control = Control::New();
control.SetName("Control1");
+ DevelControl::SetLayoutingRequired( control, true );
hbox.Add( control );
control.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
control.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
-
tet_infoline("Add a Textlabel to the control");
auto textLabel = TextLabel::New("Test text");
textLabel.SetName("TextLabel");
+
control.Add( textLabel );
// Ensure layouting happens
// Create a parent layout
auto hbox = Control::New();
auto hboxLayout = LinearLayout::New();
+ DevelControl::SetLayout( hbox, hboxLayout );
hbox.SetName( "HBox");
rootControl.Add( hbox );
- DevelControl::SetLayout( hbox, hboxLayout );
hbox.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 600 );
hbox.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
hbox.SetAnchorPoint( AnchorPoint::TOP_LEFT ); // LinearLayout will eventually do this internally.
- tet_infoline("Add a control without SetLayout being called");
+ tet_infoline("Add a control without SetLayout being called but with layout required set true");
auto control = Control::New();
control.SetName("Control1");
+ DevelControl::SetLayoutingRequired( control, true );
hbox.Add( control );
control.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
control.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
int UtcDaliLayouting_LayoutGroup03(void)
{
ToolkitTestApplication application;
- tet_infoline("UtcDaliLayouting_LayoutGroup03 - Test control witha LayoutGroup as a leaf");
+ tet_infoline("UtcDaliLayouting_LayoutGroup03 - Test control with a LayoutGroup as a leaf");
Control rootControl;
SetupRootLayoutControl( rootControl );
// Create a parent layout
auto hbox = Control::New();
auto hboxLayout = LinearLayout::New();
+ DevelControl::SetLayout( hbox, hboxLayout );
hbox.SetName( "HBox");
rootControl.Add( hbox );
+ hbox.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 600 );
+ hbox.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
+ hbox.SetAnchorPoint( AnchorPoint::TOP_LEFT ); // LinearLayout will eventually do this internally.
+
+ tet_infoline("Add a control without SetLayout being called");
+
+ auto control = Control::New();
+ control.SetName("Control1");
+ hbox.Add( control );
+ control.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
+ control.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, 100 );
+
+ // Ensure layouting happens
+ application.SendNotification();
+ application.Render();
+
+ tet_infoline("Test control is width of it's parent and exact given height");
+ DALI_TEST_EQUALS( control.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 600.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+ DALI_TEST_EQUALS( control.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+
+ END_TEST;
+}
+
+
+int UtcDaliLayouting_LayoutGroup04(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline("UtcDaliLayouting_LayoutGroup04 - Test control with a LayoutGroup as a leaf and with SetLayotRequired = true");
+
+ Control rootControl;
+ SetupRootLayoutControl( rootControl );
+
+ // Create a parent layout
+ auto hbox = Control::New();
+ auto hboxLayout = LinearLayout::New();
DevelControl::SetLayout( hbox, hboxLayout );
+ hbox.SetName( "HBox");
+ rootControl.Add( hbox );
hbox.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 600 );
hbox.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
hbox.SetAnchorPoint( AnchorPoint::TOP_LEFT ); // LinearLayout will eventually do this internally.
auto control = Control::New();
control.SetName("Control1");
+ DevelControl::SetLayoutingRequired( control, true );
hbox.Add( control );
control.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
control.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, 100 );
END_TEST;
}
+int UtcDaliLayouting_IsLayoutingRequired(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline("UtcDaliLayouting_IsLayoutingRequired - Test setting the SetLayoutRequired and then check if flag was set");
+
+ Control rootControl;
+ SetupRootLayoutControl( rootControl );
+
+ // Create a parent layout
+ auto hbox = Control::New();
+ auto hboxLayout = LinearLayout::New();
+ DevelControl::SetLayout( hbox, hboxLayout );
+ hbox.SetName( "HBox");
+ rootControl.Add( hbox );
+ hbox.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 600 );
+ hbox.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
+ hbox.SetAnchorPoint( AnchorPoint::TOP_LEFT ); // LinearLayout will eventually do this internally.
+
+ tet_infoline("Add a control without SetLayout being called");
+
+ auto control = Control::New();
+ control.SetName("Control1");
+ DALI_TEST_EQUALS( DevelControl::IsLayoutingRequired( control ), false, TEST_LOCATION );
+ DevelControl::SetLayoutingRequired( control, true );
+ hbox.Add( control );
+ control.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
+ control.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, 100 );
+
+ // Ensure layouting happens
+ application.SendNotification();
+ application.Render();
+
+ tet_infoline("Test control is width of it's parent and exact given height");
+ DALI_TEST_EQUALS( DevelControl::IsLayoutingRequired( control ), true, TEST_LOCATION );
+
+ END_TEST;
+}
+
int UtcDaliLayouting_LayoutGroupWithPadding01(void)
{
ToolkitTestApplication application;
auto control = Control::New();
control.SetName("Control1");
+ DevelControl::SetLayoutingRequired( control, true );
hbox.Add( control );
control.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
control.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
auto control = Control::New();
control.SetName("Control1");
+ DevelControl::SetLayoutingRequired( control, true );
hbox.Add( control );
control.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
control.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
layoutItem->RequestLayout();
}
}
+void SetLayoutingRequired( Control control, bool layoutingRequired )
+{
+ Internal::Control& internalControl = Toolkit::Internal::GetImplementation( control );
+ Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get( internalControl );
+ controlDataImpl.SetLayoutingRequired( layoutingRequired );
+}
+
+bool IsLayoutingRequired( Control control )
+{
+ Internal::Control& internalControl = Toolkit::Internal::GetImplementation( control );
+ Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get( internalControl );
+ return controlDataImpl.IsLayoutingRequired();
+}
} // namespace DevelControl
*/
DALI_TOOLKIT_API void RequestLayout( Internal::Control& control );
+/**
+ * @brief Set whether the control should have a layout
+ * @param[in] control The Control to set the behaviour on
+ * @param[in] layoutingRequired true if the control should have a layout
+ */
+DALI_TOOLKIT_API void SetLayoutingRequired( Control control, bool layoutingRequired );
+
+/**
+ * @brief Check if the control has been set to require layouting
+ * @param[in] control The Control to query
+ * @return true if the control needs layouting
+ */
+DALI_TOOLKIT_API bool IsLayoutingRequired( Control control );
+
} // namespace DevelControl
} // namespace Toolkit
if( ! childLayout )
{
- // If the child doesn't already have a layout, then create a LayoutItem for it.
- childLayout = LayoutGroup::New( control );
+ // If the child doesn't already have a layout, then create a LayoutItem or LayoutGroup for it.
+ // If control behaviour flag set to Layout then set a LayoutGroup.
+ if( DevelControl::IsLayoutingRequired( control ) )
+ {
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutGroup::ChildAddedToOwner Creating default LayoutGroup for control:%s\n", control?control.GetName().c_str():"Invalid" );
+ childLayout = LayoutGroup::New( control );
+ }
+ else
+ {
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutGroup::ChildAddedToOwner Creating default LayoutItem for control:%s\n", control?control.GetName().c_str():"Invalid" );
+ childLayout = LayoutItem::New( control );
+ }
childLayout->SetAnimateLayout( IsLayoutAnimated() ); // @todo this essentially forces animation inheritance. Bad?
-#if defined(DEBUG_ENABLED)
- auto desiredSize = control.GetNaturalSize();
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutGroup::ChildAddedToOwner desiredSize(%f,%f) (naturalSize)\n", desiredSize.width, desiredSize.height );
-#endif
+
+ DALI_LOG_STREAM( gLogFilter, Debug::Verbose, "LayoutGroup::ChildAddedToOwner control:" << control.GetName().c_str() <<
+ " desiredWidth: " << control.GetNaturalSize().width <<
+ " desiredHeight:" << control.GetNaturalSize().height
+ );
+
childControlDataImpl.SetLayout( *childLayout.Get() );
Vector3 size = child.GetTargetSize();
for( auto&& child : mImpl->mChildren )
{
LayoutGroupPtr parentGroup( dynamic_cast< LayoutGroup* >( child.child.Get() ) );
- if( parentGroup && ( 0 == parentGroup->GetChildCount() ) ) // A leaf LayoutGroup will have no children.
+ if( ! parentGroup )
{
// Change state only in case of leaf children
child.child->SetAnimateLayout( animateLayout );
void LayoutGroup::OnMeasure( MeasureSpec widthMeasureSpec, MeasureSpec heightMeasureSpec )
{
+ auto childCount = GetChildCount();
+
DALI_LOG_STREAM( gLogFilter, Debug::Verbose,
"LayoutGroup::OnMeasure Actor Id:" << Actor::DownCast(GetOwner()).GetId() <<
" Owner:" << Actor::DownCast(GetOwner()).GetName() <<
+ " Child Count:" << childCount <<
" MeasureSpecs( width:"<<widthMeasureSpec<<", height:"<<heightMeasureSpec );
- auto childCount = GetChildCount();
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutGroup::OnMeasure child count(%u)\n", childCount);
-
auto widthMode = widthMeasureSpec.GetMode();
auto heightMode = heightMeasureSpec.GetMode();
LayoutLength widthSpecSize = widthMeasureSpec.GetSize();
layoutHeight = std::max( layoutHeight, childHeight + childMargin.top + childMargin.bottom );
DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutGroup::OnMeasure calculated child width[%d] calculated height(%d)\n", layoutWidth.mValue, layoutHeight.mValue );
}
+ else
+ {
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutGroup::OnMeasure Not a layout\n" );
+ }
}
Extents padding = GetPadding();
layoutHeight = heightSpecSize;
}
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutGroup::OnMeasure Measured size(%d,%d) for : %s \n", layoutWidth.mValue, layoutHeight.mValue, Actor::DownCast(GetOwner()).GetName().c_str() );
+ DALI_LOG_INFO( gLogFilter, Debug::General, "LayoutGroup::OnMeasure Measured size(%d,%d) for : %s \n", layoutWidth.mValue, layoutHeight.mValue, Actor::DownCast(GetOwner()).GetName().c_str() );
SetMeasuredDimensions( MeasuredSize( layoutWidth ), MeasuredSize( layoutHeight ) );
}
void LayoutGroup::OnLayout( bool changed, LayoutLength left, LayoutLength top, LayoutLength right, LayoutLength bottom )
{
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutGroup::OnLayout\n");
-
auto count = GetChildCount();
+ DALI_LOG_STREAM( gLogFilter, Debug::Verbose, "LayoutGroup OnLayout owner:" << ( ( Toolkit::Control::DownCast(GetOwner())) ? Toolkit::Control::DownCast(GetOwner()).GetName() : "invalid" ) << " childCount:" << count );
+
for( unsigned int childIndex = 0; childIndex < count; childIndex++)
{
LayoutItemPtr childLayout = GetChildAt( childIndex );
auto control = Toolkit::Control::DownCast( childOwner );
Extents padding = GetPadding();
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutGroup::OnLayout child width[%d] height(%d)\n", childWidth.mValue, childHeight.mValue );
-
auto childPosition = control.GetProperty< Vector3 >( Actor::Property::POSITION );
auto anchorPoint = control.GetProperty< Vector3 >( Actor::Property::ANCHOR_POINT );
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutGroup::OnLayout child[%s] position(%f,%f)\n", control.GetName().c_str(), childPosition.x, childPosition.y );
+ DALI_LOG_INFO( gLogFilter, Debug::General, "LayoutGroup::OnLayout child[%s] position(%f,%f) child width[%d] height(%d)\n",
+ control.GetName().c_str(),
+ childPosition.x, childPosition.y,
+ childWidth.mValue, childHeight.mValue
+ );
// Margin and Padding only supported when child anchor point is TOP_LEFT.
int paddingAndMarginOffsetX = ( AnchorPoint::TOP_LEFT == anchorPoint ) ? ( padding.top + childMargin.top ) : 0;
void LayoutItem::SetAnimateLayout( bool animateLayout )
{
- DALI_LOG_INFO( gLayoutFilter, Debug::Verbose, "LayoutItem::SetAnimateLayout animateLayout(%s)\n", (animateLayout)?"true":"false" );
-
auto owner = GetOwner();
auto actor = Actor::DownCast(owner);
- if( actor )
- {
- DALI_LOG_INFO( gLayoutFilter, Debug::Verbose, "LayoutItem::SetAnimateLayout animateLayout(%s) owner(%s)\n", (animateLayout)?"true":"false", actor.GetName().c_str() );
- }
+ DALI_LOG_INFO( gLayoutFilter, Debug::Verbose, "LayoutItem::SetAnimateLayout animateLayout(%s) owner(%s)\n", (animateLayout)?"true":"false",
+ ( ( Actor::DownCast( owner) ) ? Actor::DownCast(owner).GetName().c_str() : "Invalid Actor" ) );
mImpl->mAnimated = animateLayout;
const bool needsLayout = specChanged && ( !isSpecExactly || !matchesSpecSize );
- DALI_LOG_STREAM( gLayoutFilter, Debug::Verbose, "LayoutItem::Measure("<<widthMeasureSpec<<", "<<heightMeasureSpec<<") Owner:"<<Actor::DownCast(GetOwner()).GetName() <<" forceLayout="<<forceLayout<<", specChanged="<<specChanged<<", isSpecExactly="<<isSpecExactly<<", matchesSpecSize="<<matchesSpecSize<<", needsLayout="<<needsLayout <<std::endl <<(forceLayout||needsLayout?" Remeasuring":" NoChange"));
+ DALI_LOG_STREAM( gLayoutFilter, Debug::General, "LayoutItem::Measure("<<widthMeasureSpec<<", "<<heightMeasureSpec<<") Owner:"<<Actor::DownCast(GetOwner()).GetName() <<" forceLayout="<<forceLayout<<", specChanged="<<specChanged<<", isSpecExactly="<<isSpecExactly<<", matchesSpecSize="<<matchesSpecSize<<", needsLayout="<<needsLayout <<std::endl <<(forceLayout||needsLayout?" Remeasuring":" NoChange"));
if( forceLayout || needsLayout )
{
#if defined(DEBUG_ENABLED)
std::ostringstream o;
o<<widthMeasureSpec<<","<<heightMeasureSpec;
- DALI_LOG_INFO( gLayoutFilter, Debug::Concise, "LayoutItem::Measure Calling %s OnMeasure( %s )\n", Actor::DownCast(GetOwner()).GetName().c_str(), o.str().c_str());
+ DALI_LOG_INFO( gLayoutFilter, Debug::General, "LayoutItem::Measure Calling %s OnMeasure( %s )\n", Actor::DownCast(GetOwner()).GetName().c_str(), o.str().c_str());
#endif
OnMeasure( widthMeasureSpec, heightMeasureSpec );
mImpl->ClearPrivateFlag( Impl::PRIVATE_FLAG_MEASURE_NEEDED_BEFORE_LAYOUT );
// flag not set, setMeasuredDimension() was not invoked, we raise an exception to warn the developer
DALI_ASSERT_ALWAYS( mImpl->GetPrivateFlag( Impl::PRIVATE_FLAG_MEASURED_DIMENSION_SET ) &&
- "Layout's OnMeasure() mension()" );
+ "Layout's OnMeasure() Measured dimension flag not set" );
mImpl->SetPrivateFlag( Impl::PRIVATE_FLAG_LAYOUT_REQUIRED );
}
#include <dali-toolkit/devel-api/controls/control-depth-index-ranges.h>
#include <dali-toolkit/devel-api/controls/control-devel.h>
#include <dali-toolkit/devel-api/controls/control-wrapper-impl.h>
+#include <dali-toolkit/devel-api/layouting/layout-item.h>
#include <dali-toolkit/internal/styling/style-manager-impl.h>
#include <dali-toolkit/internal/visuals/visual-string-constants.h>
mInputMethodContext(),
mFlags( Control::ControlBehaviour( CONTROL_BEHAVIOUR_DEFAULT ) ),
mIsKeyboardNavigationSupported( false ),
- mIsKeyboardFocusGroup( false )
+ mIsKeyboardFocusGroup( false ),
+ mIsLayoutingRequired( false )
{
}
}
}
+void Control::Impl::SetLayoutingRequired( bool layoutingRequired )
+{
+ mControlImpl.mImpl->mIsLayoutingRequired = layoutingRequired;
+}
+
+bool Control::Impl::IsLayoutingRequired()
+{
+ return mControlImpl.mImpl->mIsLayoutingRequired;
+}
+
} // namespace Internal
} // namespace Toolkit
*/
void RemoveLayout();
+ /**
+ * @copydoc DevelControl::SetLayoutingRequired
+ */
+ void SetLayoutingRequired( bool layoutingRequired );
+
+ /**
+ * @copydoc DevelControl::IsLayoutingRequired()
+ */
+ bool IsLayoutingRequired();
+
private:
/**
ControlBehaviour mFlags : CONTROL_BEHAVIOUR_FLAG_COUNT; ///< Flags passed in from constructor.
bool mIsKeyboardNavigationSupported :1; ///< Stores whether keyboard navigation is supported by the control.
bool mIsKeyboardFocusGroup :1; ///< Stores whether the control is a focus group.
+ bool mIsLayoutingRequired :1; ///< Stores whether the control needs to be Layout
RegisteredVisualContainer mRemoveVisuals; ///< List of visuals that are being replaced by another visual once ready
auto childTop = childPosition.y;
auto childLeft = childPosition.x;
+ DALI_LOG_INFO( gLogFilter, Debug::General, "AbsoluteLayout::OnLayout child[%s] position(%f,%f) child width[%d] height(%d)\n",
+ Toolkit::Control::DownCast( childOwner ).GetName().c_str(),
+ childPosition.x, childPosition.y,
+ childWidth.mValue, childHeight.mValue
+ );
+
childLayout->Layout( childLeft, childTop, childLeft + childWidth, childTop + childHeight );
}
}
Toolkit::Control control = Toolkit::Control::DownCast( root );
if( control )
{
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutController::Measuring control\n" );
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutController::Measuring control:%s\n", control.GetName().c_str() );
Internal::Control& controlImpl = GetImplementation( control );
Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get( controlImpl );