feat: ImGuiHelpers.GetButtonSize()

This commit is contained in:
goat 2021-09-17 23:41:06 +02:00
parent 59ba3bdd07
commit b779ac5674
No known key found for this signature in database
GPG key ID: F18F057873895461
2 changed files with 9 additions and 4 deletions

View file

@ -105,6 +105,13 @@ namespace Dalamud.Interface
return colorPalette;
}
/// <summary>
/// Get the size of a button considering the default frame padding.
/// </summary>
/// <param name="text">Text in the button.</param>
/// <returns><see cref="Vector2"/> with the size of the button.</returns>
public static Vector2 GetButtonSize(string text) => ImGui.CalcTextSize(text) + (ImGui.GetStyle().FramePadding * 2);
/// <summary>
/// Get data needed for each new frame.
/// </summary>

View file

@ -201,8 +201,6 @@ namespace Dalamud.Interface.Internal.Windows
this.DownloadPluginIcons();
}
private static Vector2 GetButtonSize(string text) => ImGui.CalcTextSize(text) + (ImGui.GetStyle().FramePadding * 2);
private static string? GetPluginIconUrl(PluginManifest manifest, bool isThirdParty, bool isTesting)
{
if (isThirdParty)
@ -286,7 +284,7 @@ namespace Dalamud.Interface.Internal.Windows
var pluginManager = Service<PluginManager>.Get();
var windowSize = ImGui.GetWindowContentRegionMax();
var placeholderButtonSize = GetButtonSize("placeholder");
var placeholderButtonSize = ImGuiHelpers.GetButtonSize("placeholder");
ImGui.Separator();
@ -311,7 +309,7 @@ namespace Dalamud.Interface.Internal.Windows
}
var closeText = Locs.FooterButton_Close;
var closeButtonSize = GetButtonSize(closeText);
var closeButtonSize = ImGuiHelpers.GetButtonSize(closeText);
ImGui.SameLine(windowSize.X - closeButtonSize.X - 20);
if (ImGui.Button(closeText))