Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 46 additions & 10 deletions src/Myra/Graphics2D/UI/Simple/Label.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ public class Label : Widget
SupportsCommands = false
};

[Category("Appearance")]
private bool _singleLine = false;

[Category("Appearance")]
[DefaultValue(0)]
public int VerticalSpacing
{
Expand Down Expand Up @@ -101,10 +103,31 @@ public bool Wrap
}
}

/// <summary>
/// The method used to abbreviate overflowing text.
/// </summary>
[Category("Appearance")]
[Category("Appearance")]
[DefaultValue(false)]
public bool SingleLine
{
get
{
return _singleLine;
}

set
{
if (value == _singleLine)
{
return;
}

_singleLine = value;
InvalidateMeasure();
}
}

/// <summary>
/// The method used to abbreviate overflowing text.
/// </summary>
[Category("Appearance")]
[DefaultValue(AutoEllipsisMethod.None)]
public AutoEllipsisMethod AutoEllipsisMethod
{
Expand Down Expand Up @@ -255,11 +278,24 @@ protected override void InternalArrange()
{
base.InternalArrange();

_richText.Width = _wrap ? ActualBounds.Width : default(int?);
_richText.Height = _wrap ? ActualBounds.Height : default(int?);
}

public void ApplyLabelStyle(LabelStyle style)
if (_singleLine)
{
_richText.Width = ActualBounds.Width;
_richText.Height = Font.LineHeight;
}
else if (_wrap)
{
_richText.Width = ActualBounds.Width;
_richText.Height = ActualBounds.Height;
}
else
{
_richText.Width = default(int?);
_richText.Height = default(int?);
}
}

public void ApplyLabelStyle(LabelStyle style)
{
ApplyWidgetStyle(style);

Expand Down
Loading