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::Verbose, "LayoutItem::Measure("<<widthMeasureSpec<<", "<<heightMeasureSpec<<") Owner:"
+ <<Actor::DownCast(GetOwner()).GetName() <<" forceLayout="<<forceLayout
+ <<", specChanged="<<specChanged<<", isSpecExactly="<<isSpecExactly
+ <<", matchesSpecSize="<<matchesSpecSize
+ <<", needsLayout="<<needsLayout <<(forceLayout||needsLayout?" Remeasuring":" NoChange"));
if( forceLayout || needsLayout )
{
#if defined(DEBUG_ENABLED)
std::ostringstream o;
o<<widthMeasureSpec<<","<<heightMeasureSpec;
- DALI_LOG_INFO( gLayoutFilter, Debug::Concise, "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 );
}
auto specMode = measureSpec.GetMode();
auto specSize = measureSpec.GetSize();
+ DALI_LOG_STREAM( gLayoutFilter, Debug::Verbose, "LayoutItem::GetDefaultSize MeasureSpec("<<measureSpec<< ") size:" << size << "\n" );
+
switch (specMode)
{
case MeasureSpec::Mode::UNSPECIFIED:
}
case MeasureSpec::Mode::AT_MOST:
{
+ // Ensure the default size does not exceed the spec size unless the default size is 0.
+ // Another container could provide a default size of 0.
LayoutLength tmp = specSize;
- if( size < tmp )
+
+ // Do not set size to 0, use specSize in this case as could be a legacy container
+ if( size < tmp && size > LayoutLength( 0 ) )
{
result = size;
}
break;
}
}
+ DALI_LOG_STREAM( gLayoutFilter, Debug::General, "LayoutItem::GetDefaultSize setting default size:" << result << "\n" );
return result;
}
{
DALI_LOG_INFO( gLayoutFilter, Debug::Verbose, "LayoutItem::OnMeasure\n");
+ // GetDefaultSize will limit the MeasureSpec to the suggested minimumWidth and minimumHeight
SetMeasuredDimensions( GetDefaultSize( GetSuggestedMinimumWidth(), widthMeasureSpec ),
GetDefaultSize( GetSuggestedMinimumHeight(), heightMeasureSpec ) );
}
void LayoutItem::SetParent( LayoutParent* parent )
{
mImpl->mLayoutParent = parent;
+ mImpl->SetPrivateFlag( Impl::PRIVATE_FLAG_FORCE_SET_FRAME );
}
LayoutParent* LayoutItem::GetParent()
mImpl->SetPrivateFlag( Impl::PRIVATE_FLAG_FORCE_LAYOUT );
}
+bool LayoutItem::IsResizePolicyRequired() const
+{
+ return mImpl->GetPrivateFlag( Impl::PRIVATE_FLAG_USE_RESIZE_POLICY );
+}
+
+void LayoutItem::SetResizePolicyRequired( bool resizePolicyRequired )
+{
+ if( resizePolicyRequired )
+ {
+ mImpl->SetPrivateFlag( Impl::PRIVATE_FLAG_USE_RESIZE_POLICY );
+ }
+ else
+ {
+ mImpl->ClearPrivateFlag( Impl::PRIVATE_FLAG_USE_RESIZE_POLICY );
+ }
+}
+
void LayoutItem::SetMeasuredDimensions( MeasuredSize measuredWidth, MeasuredSize measuredHeight )
{
- DALI_LOG_INFO( gLayoutFilter, Debug::Verbose, "LayoutItem::SetMeasuredDimensions width(%d) height(%d) \n",
- MeasureSpec::IntType( measuredWidth.GetSize() ),
- MeasureSpec::IntType( measuredHeight.GetSize() )
- );
+
+ DALI_LOG_STREAM( gLayoutFilter, Debug::Verbose, "LayoutItem::SetMeasuredDimensions width(" << measuredWidth.GetSize() << ") height(" << measuredHeight.GetSize() << ") Control:" <<
+ ( ( Actor::DownCast( GetOwner()) ) ? Actor::DownCast(GetOwner()).GetName().c_str() : "Invalid Actor" ) << "\n" );
mImpl->SetPrivateFlag( Impl::PRIVATE_FLAG_MEASURED_DIMENSION_SET );
mImpl->mMeasuredWidth = measuredWidth;
auto actor = Actor::DownCast(owner);
auto naturalSize = actor ? actor.GetNaturalSize() : Vector3::ZERO;
- return std::max( mImpl->mMinimumSize.GetWidth(), LayoutLength::IntType( naturalSize.width ) );
+ return std::max( mImpl->mMinimumSize.GetWidth(), LayoutLength( naturalSize.width ) );
}
LayoutLength LayoutItem::GetSuggestedMinimumHeight() const
auto actor = Actor::DownCast(owner);
auto naturalSize = actor ? actor.GetNaturalSize() : Vector3::ZERO;
- return std::max( mImpl->mMinimumSize.GetHeight(), LayoutLength::IntType(naturalSize.height) );
+ return std::max( mImpl->mMinimumSize.GetHeight(), LayoutLength( naturalSize.height ) );
}
MeasuredSize LayoutItem::ResolveSizeAndState( LayoutLength size, MeasureSpec measureSpec, MeasuredSize::State childMeasuredState )
{
bool changed = false;
- DALI_LOG_INFO( gLayoutFilter, Debug::Verbose, "LayoutItem::SetFrame enter(%d, %d, %d, %d)\n", left.mValue, top.mValue, right.mValue, bottom.mValue );
+ DALI_LOG_STREAM( gLayoutFilter, Debug::Verbose, "LayoutItem::SetFrame enter(" << left << ", " << top << ", " << right << ", " << bottom << ")\n" );
- if( mImpl->mLeft != left || mImpl->mRight != right || mImpl->mTop != top || mImpl->mBottom != bottom )
+ if( mImpl->mLeft != left || mImpl->mRight != right || mImpl->mTop != top || mImpl->mBottom != bottom || mImpl->GetPrivateFlag( Impl::PRIVATE_FLAG_FORCE_SET_FRAME ) )
{
changed = true;
- auto oldWidth = mImpl->mRight - mImpl->mLeft;
- auto oldHeight = mImpl->mBottom - mImpl->mTop;
- auto newWidth = right - left;
- auto newHeight = bottom - top;
+ LayoutLength oldWidth = mImpl->mRight - mImpl->mLeft;
+ LayoutLength oldHeight = mImpl->mBottom - mImpl->mTop;
+ LayoutLength newWidth = right - left;
+ LayoutLength newHeight = bottom - top;
bool sizeChanged = (newWidth != oldWidth) || (newHeight != oldHeight);
mImpl->mLeft = left;
mImpl->mRight = right;
mImpl->mBottom = bottom;
- mImpl->SetPrivateFlag( Impl::PRIVATE_FLAG_HAS_BOUNDS );
+ mImpl->ClearPrivateFlag( Impl::PRIVATE_FLAG_FORCE_SET_FRAME );
// Reflect up to parent control
auto actor = Actor::DownCast(owner);
if( actor )
{
- DALI_LOG_INFO( gLayoutFilter, Debug::Verbose, "LayoutItem::SetFrame owner(%s) (%d, %d, %d, %d)\n", actor.GetName().c_str(),
- left.mValue, top.mValue, right.mValue, bottom.mValue );
+ DALI_LOG_STREAM( gLayoutFilter, Debug::Verbose, "LayoutItem::SetFrame owner(" << left << ", " << top << ", " << right << ", " << bottom << ")\n" );
+
if( mImpl->mAnimated )
{
auto animation = Animation::New( 0.5f );
- animation.AnimateTo( Property( actor, Actor::Property::POSITION ),
- Vector3( float(left.mValue), float(top.mValue), 0.0f ) );
- animation.AnimateTo( Property( actor, Actor::Property::SIZE ),
- Vector3( right-left, bottom-top, 0.0f ) );
+ animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), left.AsInteger() );
+ animation.AnimateTo( Property( actor, Actor::Property::POSITION_Y ), top.AsInteger() );
+
+ animation.AnimateTo( Property( actor, Actor::Property::SIZE_WIDTH ), newWidth.AsInteger() );
+ animation.AnimateTo( Property( actor, Actor::Property::SIZE_HEIGHT ), newHeight.AsInteger() );
+
animation.FinishedSignal().Connect( mSlotDelegate, &LayoutItem::OnLayoutAnimationFinished );
animation.Play();
}
else
{
// @todo Collate into list of Property & Property::Value pairs.
- actor.SetPosition( Vector3( float(left.mValue), float(top.mValue), 0.0f ) );
- actor.SetSize( Vector3( right-left, bottom-top, 0.0f ) );
+ actor.SetX( left.AsInteger() );
+ actor.SetY( top.AsInteger() );
+ actor.SetProperty( Actor::Property::SIZE_WIDTH, newWidth.AsInteger() );
+ actor.SetProperty( Actor::Property::SIZE_HEIGHT, newHeight.AsInteger() );
}
}
}
}
- DALI_LOG_INFO( gLayoutFilter, Debug::Verbose, "LayoutItem::SetFrame exit(%d, %d, %d, %d)\n", left.mValue, top.mValue, right.mValue, bottom.mValue );
+ DALI_LOG_STREAM( gLayoutFilter, Debug::Verbose, "LayoutItem::SetFrame exit(" << left << ", " << top << ", " << right << ", " << bottom << ")\n" );
return changed;
}
auto actor = Actor::DownCast(owner);
if( actor )
{
- actor.SetSize( Vector3( mImpl->mRight-mImpl->mLeft, mImpl->mBottom-mImpl->mTop, 0.0f ) );
+ actor.SetSize( Vector3( mImpl->mRight.AsInteger() - mImpl->mLeft.AsInteger(), mImpl->mBottom.AsInteger() - mImpl->mTop.AsInteger(), 0.0f ) );
}
}