diff --git a/src/Eto.Mac/Forms/Controls/MacLabel.cs b/src/Eto.Mac/Forms/Controls/MacLabel.cs index 77255a370..71a4d508d 100644 --- a/src/Eto.Mac/Forms/Controls/MacLabel.cs +++ b/src/Eto.Mac/Forms/Controls/MacLabel.cs @@ -96,9 +96,6 @@ public abstract class MacLabel : MacView Control; @@ -110,23 +107,26 @@ protected override SizeF GetNaturalSize(SizeF availableSize) if (float.IsPositiveInfinity(availableSize.Width)) { - if (naturalSizeInfinity != null) - return naturalSizeInfinity.Value; + if (NaturalSizeInfinity != null) + return NaturalSizeInfinity.Value; var width = UserPreferredSize.Width; if (width < 0) width = int.MaxValue; var size = Control.Cell.CellSizeForBounds(new CGRect(0, 0, width, int.MaxValue)).ToEto(); - naturalSizeInfinity = Size.Ceiling(size); - return naturalSizeInfinity.Value; + NaturalSizeInfinity = Size.Ceiling(size); + return NaturalSizeInfinity.Value; } - if (Widget.Loaded && Wrap != WrapMode.None && UserPreferredSize.Width > 0) + if (Widget.Loaded && Wrap != WrapMode.None) { - /*if (!float.IsPositiveInfinity(availableSize.Width)) - availableSize.Width = Math.Max(Size.Width, availableSize.Width); - else*/ - availableSize.Width = UserPreferredSize.Width; - availableSize.Height = float.PositiveInfinity; + if (UserPreferredSize.Width > 0) + { + /*if (!float.IsPositiveInfinity(availableSize.Width)) + availableSize.Width = Math.Max(Size.Width, availableSize.Width); + else*/ + availableSize.Width = UserPreferredSize.Width; + availableSize.Height = float.PositiveInfinity; + } } var availableSizeTruncated = availableSize.TruncateInfinity(); @@ -140,24 +140,6 @@ protected override SizeF GetNaturalSize(SizeF availableSize) return NaturalSize.Value; } - public override void OnSizeChanged(EventArgs e) - { - base.OnSizeChanged(e); - if (isSizing) - return; - isSizing = true; - var size = Size; - if (Wrap != WrapMode.None && lastSize.Width != size.Width && !Control.IsHiddenOrHasHiddenAncestor) - { - // when wrapping we use the current size, if it changes we check if we need another layout pass - // this is needed when resizing a form/label so it can wrap correctly as GetNaturalSize() - // will use the old size first, and won't necessarily know the final size of the label. - lastSize = size; - InvalidateMeasure(); - } - isSizing = false; - } - protected MacLabel() { paragraphStyle = new NSMutableParagraphStyle(); @@ -343,12 +325,6 @@ protected virtual NSColor CurrentColor } } - public override void InvalidateMeasure() - { - base.InvalidateMeasure(); - naturalSizeInfinity = null; - } - public override void OnLoad(EventArgs e) { base.OnLoad(e);