[go: nahoru, domu]

Skip to content

Commit

Permalink
[NUI] Fix text padding issue
Browse files Browse the repository at this point in the history
This patch solves the problem that text with padding does not work in nui layout.

For text components, the control's padding is used to calculatie size in native,
so it should not be set to zero value.

This avoids setting padding to zero when it comes to text layout.

Signed-off-by: Bowon Ryu <bowon.ryu@samsung.com>
  • Loading branch information
wonrst authored and dongsug-song committed Jan 9, 2024
1 parent 9730842 commit 4515dc8
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/Tizen.NUI/src/public/BaseComponents/TextEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2827,7 +2827,7 @@ private void OnGrabHandleColorChanged(float r, float g, float b, float a)
GrabHandleColor = new Color(r, g, b, a);
}

private class TextEditorLayout : LayoutItem
internal class TextEditorLayout : LayoutItem
{
protected override void OnMeasure(MeasureSpecification widthMeasureSpec, MeasureSpecification heightMeasureSpec)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Tizen.NUI/src/public/BaseComponents/TextField.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2832,7 +2832,7 @@ private void OnGrabHandleColorChanged(float r, float g, float b, float a)
GrabHandleColor = new Color(r, g, b, a);
}

private class TextFieldLayout : LayoutItem
internal class TextFieldLayout : LayoutItem
{
protected override void OnMeasure(MeasureSpecification widthMeasureSpec, MeasureSpecification heightMeasureSpec)
{
Expand Down
4 changes: 2 additions & 2 deletions src/Tizen.NUI/src/public/BaseComponents/TextLabel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ namespace Tizen.NUI.BaseComponents
/// <since_tizen> 3 </since_tizen>
public partial class TextLabel : View
{
private class TextLayout : LayoutItem
internal class TextLabelLayout : LayoutItem
{
protected override void OnMeasure(MeasureSpecification widthMeasureSpec, MeasureSpecification heightMeasureSpec)
{
Expand Down Expand Up @@ -1765,7 +1765,7 @@ protected override ViewStyle CreateViewStyle()

internal override LayoutItem CreateDefaultLayout()
{
return new TextLayout();
return new TextLabelLayout();
}

/// <summary>
Expand Down
8 changes: 7 additions & 1 deletion src/Tizen.NUI/src/public/BaseComponents/View.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3008,7 +3008,13 @@ private LayoutItem InternalLayout
setMargin = true;
}

if (padding.Top != 0 || padding.Bottom != 0 || padding.Start != 0 || padding.End != 0)
// The calculation of the native size of the text component requires padding.
// Don't overwrite the zero padding.
bool isTextLayout = (value is Tizen.NUI.BaseComponents.TextLabel.TextLabelLayout) ||
(value is Tizen.NUI.BaseComponents.TextField.TextFieldLayout) ||
(value is Tizen.NUI.BaseComponents.TextEditor.TextEditorLayout);

if (!isTextLayout && (padding.Top != 0 || padding.Bottom != 0 || padding.Start != 0 || padding.End != 0))
{
// If View already has a padding set then store it in Layout instead.
value.Padding = padding;
Expand Down

0 comments on commit 4515dc8

Please sign in to comment.