Skip to content

Commit

Permalink
Fix scoped in and mark experimental (#1990)
Browse files Browse the repository at this point in the history
  • Loading branch information
Soreepeong committed Aug 1, 2024
1 parent afe44e4 commit c721069
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ public ReadOnlySeString CompileAndCache(string text)
/// <returns>Interaction result of the rendered text.</returns>
public SeStringDrawResult CompileAndDrawWrapped(
string text,
in SeStringDrawParams drawParams = default,
scoped in SeStringDrawParams drawParams = default,
ImGuiId imGuiId = default,
ImGuiButtonFlags buttonFlags = ImGuiButtonFlags.MouseButtonDefault) =>
this.Draw(this.CompileAndCache(text).AsSpan(), drawParams, imGuiId, buttonFlags);
Expand All @@ -241,8 +241,8 @@ public SeStringDrawResult CompileAndDrawWrapped(
/// <param name="buttonFlags">Button flags to use on link interaction.</param>
/// <returns>Interaction result of the rendered text.</returns>
public SeStringDrawResult Draw(
in Utf8String utf8String,
in SeStringDrawParams drawParams = default,
scoped in Utf8String utf8String,
scoped in SeStringDrawParams drawParams = default,
ImGuiId imGuiId = default,
ImGuiButtonFlags buttonFlags = ImGuiButtonFlags.MouseButtonDefault) =>
this.Draw(utf8String.AsSpan(), drawParams, imGuiId, buttonFlags);
Expand All @@ -255,7 +255,7 @@ public SeStringDrawResult Draw(
/// <returns>Interaction result of the rendered text.</returns>
public SeStringDrawResult Draw(
ReadOnlySeStringSpan sss,
in SeStringDrawParams drawParams = default,
scoped in SeStringDrawParams drawParams = default,
ImGuiId imGuiId = default,
ImGuiButtonFlags buttonFlags = ImGuiButtonFlags.MouseButtonDefault)
{
Expand Down Expand Up @@ -889,7 +889,7 @@ private ref struct DrawState(
/// <param name="gfdEntry">GFD entry to determine the size.</param>
/// <param name="useHq">Whether to draw the HQ texture.</param>
/// <returns>Determined size of the GFD entry when drawn.</returns>
public readonly Vector2 CalculateGfdEntrySize(in GfdFile.GfdEntry gfdEntry, out bool useHq)
public readonly Vector2 CalculateGfdEntrySize(scoped in GfdFile.GfdEntry gfdEntry, out bool useHq)
{
useHq = this.Params.FontSize > 20;
var targetHeight = useHq ? this.Params.FontSize : 20;
Expand All @@ -911,7 +911,11 @@ public readonly void SetCurrentChannel(int channelIndex) =>
/// <param name="dyItalic">Transformation for <paramref name="g"/> that will push top and bottom pixels to
/// apply faux italicization.</param>
/// <param name="color">Color of the glyph.</param>
public readonly void Draw(Vector2 offset, in ImGuiHelpers.ImFontGlyphReal g, Vector2 dyItalic, uint color) =>
public readonly void Draw(
Vector2 offset,
scoped in ImGuiHelpers.ImFontGlyphReal g,
Vector2 dyItalic,
uint color) =>
this.Draw(
offset + new Vector2(
0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

namespace Dalamud.Interface.Internal.Windows.Data.Widgets;

#pragma warning disable SeStringRenderer

/// <summary>
/// Widget for displaying AtkArrayData.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

namespace Dalamud.Interface.Internal.Windows.Data.Widgets;

#pragma warning disable SeStringRenderer

/// <summary>
/// Widget for displaying Addon Data.
/// </summary>
Expand Down
27 changes: 4 additions & 23 deletions Dalamud/Interface/Utility/ImGuiHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -180,27 +180,6 @@ public static void ClickToCopyText(string text, string? textCopy = null)
if (ImGui.IsItemClicked()) ImGui.SetClipboardText($"{textCopy}");
}

/// <summary>Draws a SeString.</summary>
/// <param name="sss">SeString to draw.</param>
/// <param name="wrapWidth">Wrapping width. If a non-positive number is provided, then the remainder of the width
/// will be used.</param>
/// <remarks>This function is experimental. Report any issues to GitHub issues or to Discord #dalamud-dev channel.
/// The function definition is stable; only in the next API version a function may be removed.</remarks>
public static void SeStringWrapped(ReadOnlySpan<byte> sss, float wrapWidth = 0) =>
Service<SeStringRenderer>.Get().Draw(sss, new() { WrapWidth = wrapWidth > 0 ? wrapWidth : null });

/// <summary>Creates and caches a SeString from a text macro representation, and then draws it.</summary>
/// <param name="text">SeString text macro representation.
/// Newline characters will be normalized to <see cref="NewLinePayload"/>.</param>
/// <param name="wrapWidth">Wrapping width. If a non-positive number is provided, then the remainder of the width
/// will be used.</param>
/// <remarks>This function is experimental. Report any issues to GitHub issues or to Discord #dalamud-dev channel.
/// The function definition is stable; only in the next API version a function may be removed.</remarks>
public static void CompileSeStringWrapped(string text, float wrapWidth = 0) =>
Service<SeStringRenderer>.Get().CompileAndDrawWrapped(
text,
new() { WrapWidth = wrapWidth > 0 ? wrapWidth : null });

/// <summary>Draws a SeString.</summary>
/// <param name="sss">SeString to draw.</param>
/// <param name="style">Initial rendering style.</param>
Expand All @@ -209,9 +188,10 @@ public static void CompileSeStringWrapped(string text, float wrapWidth = 0) =>
/// <returns>Interaction result of the rendered text.</returns>
/// <remarks>This function is experimental. Report any issues to GitHub issues or to Discord #dalamud-dev channel.
/// The function definition is stable; only in the next API version a function may be removed.</remarks>
[Experimental("SeStringRenderer")]
public static SeStringDrawResult SeStringWrapped(
ReadOnlySpan<byte> sss,
in SeStringDrawParams style = default,
scoped in SeStringDrawParams style = default,
ImGuiId imGuiId = default,
ImGuiButtonFlags buttonFlags = ImGuiButtonFlags.MouseButtonDefault) =>
Service<SeStringRenderer>.Get().Draw(sss, style, imGuiId, buttonFlags);
Expand All @@ -225,9 +205,10 @@ public static SeStringDrawResult SeStringWrapped(
/// <returns>Interaction result of the rendered text.</returns>
/// <remarks>This function is experimental. Report any issues to GitHub issues or to Discord #dalamud-dev channel.
/// The function definition is stable; only in the next API version a function may be removed.</remarks>
[Experimental("SeStringRenderer")]
public static SeStringDrawResult CompileSeStringWrapped(
string text,
in SeStringDrawParams style,
scoped in SeStringDrawParams style,
ImGuiId imGuiId = default,
ImGuiButtonFlags buttonFlags = ImGuiButtonFlags.MouseButtonDefault) =>
Service<SeStringRenderer>.Get().CompileAndDrawWrapped(text, style, imGuiId, buttonFlags);
Expand Down

0 comments on commit c721069

Please sign in to comment.