Browse Source

FormattedText.Measure() -> FormattedText.Bounds.

Changed `FormattedText.Measure` method to a `Bounds` property.
pull/2344/head
Steven Kirk 8 years ago
parent
commit
4a91003981
  1. 2
      src/Avalonia.Controls/Presenters/TextPresenter.cs
  2. 2
      src/Avalonia.Controls/TextBlock.cs
  3. 12
      src/Avalonia.Visuals/Media/FormattedText.cs
  4. 2
      src/Avalonia.Visuals/Rendering/RendererBase.cs

2
src/Avalonia.Controls/Presenters/TextPresenter.cs

@ -275,7 +275,7 @@ namespace Avalonia.Controls.Presenters
Typeface = new Typeface(FontFamily, FontSize, FontStyle, FontWeight), Typeface = new Typeface(FontFamily, FontSize, FontStyle, FontWeight),
TextAlignment = TextAlignment, TextAlignment = TextAlignment,
Constraint = availableSize, Constraint = availableSize,
}.Measure().Size; }.Bounds.Size;
} }
} }

2
src/Avalonia.Controls/TextBlock.cs

@ -396,7 +396,7 @@ namespace Avalonia.Controls
FormattedText.Constraint = Size.Infinity; FormattedText.Constraint = Size.Infinity;
} }
return FormattedText.Measure().Size; return FormattedText.Bounds.Size;
} }
return new Size(); return new Size();

12
src/Avalonia.Visuals/Media/FormattedText.cs

@ -37,6 +37,12 @@ namespace Avalonia.Media
_platform = platform; _platform = platform;
} }
/// <summary>
/// Gets the bounds of the text within the <see cref="Constraint"/>.
/// </summary>
/// <returns>The bounds of the text.</returns>
public Rect Bounds => PlatformImpl.Bounds;
/// <summary> /// <summary>
/// Gets or sets the constraint of the text. /// Gets or sets the constraint of the text.
/// </summary> /// </summary>
@ -158,12 +164,6 @@ namespace Avalonia.Media
return PlatformImpl.HitTestTextRange(index, length); return PlatformImpl.HitTestTextRange(index, length);
} }
/// <summary>
/// Gets the bounds of the text, taking <see cref="Constraint"/> into account.
/// </summary>
/// <returns>The bounds of the text.</returns>
public Rect Measure() => PlatformImpl.Bounds;
private void Set<T>(ref T field, T value) private void Set<T>(ref T field, T value)
{ {
field = value; field = value;

2
src/Avalonia.Visuals/Rendering/RendererBase.cs

@ -45,7 +45,7 @@ namespace Avalonia.Rendering
_fpsText.Text = string.Format("FPS: {0:000}", _fps); _fpsText.Text = string.Format("FPS: {0:000}", _fps);
} }
var size = _fpsText.Measure(); var size = _fpsText.Bounds.Size;
var rect = new Rect(clientRect.Right - size.Width, 0, size.Width, size.Height); var rect = new Rect(clientRect.Right - size.Width, 0, size.Width, size.Height);
context.Transform = Matrix.Identity; context.Transform = Matrix.Identity;

Loading…
Cancel
Save