Prevent negative content size due to large padding 75/315075/1
authorBowon Ryu <bowon.ryu@samsung.com>
Wed, 24 Jul 2024 11:10:03 +0000 (20:10 +0900)
committerBowon Ryu <bowon.ryu@samsung.com>
Wed, 24 Jul 2024 11:10:03 +0000 (20:10 +0900)
Previously, content size was calculated using simple subtraction without checking for negative values.
This causes incorrect rendering results in visual updates.

Change-Id: I23cd6b6d1536e10fa8baf3ed7cef673de4b2abd7
Signed-off-by: Bowon Ryu <bowon.ryu@samsung.com>
dali-toolkit/internal/controls/text-controls/text-label-impl.cpp

index 4792391..09cef9d 100644 (file)
@@ -1203,7 +1203,9 @@ void TextLabel::OnRelayout(const Vector2& size, RelayoutContainer& container)
   Extents padding;
   padding = self.GetProperty<Extents>(Toolkit::Control::Property::PADDING);
 
-  Vector2 contentSize(size.x - (padding.start + padding.end), size.y - (padding.top + padding.bottom));
+  float width  = std::max(size.x - (padding.start + padding.end), 0.0f);
+  float height = std::max(size.y - (padding.top + padding.bottom), 0.0f);
+  Vector2 contentSize(width, height);
 
   if(mController->IsTextFitArrayEnabled())
   {