From b779ac56745f3fb4164c9cdb55b4d8eae7033726 Mon Sep 17 00:00:00 2001
From: goat <16760685+goaaats@users.noreply.github.com>
Date: Fri, 17 Sep 2021 23:41:06 +0200
Subject: [PATCH] feat: ImGuiHelpers.GetButtonSize()
---
Dalamud/Interface/ImGuiHelpers.cs | 7 +++++++
.../Interface/Internal/Windows/PluginInstallerWindow.cs | 6 ++----
2 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/Dalamud/Interface/ImGuiHelpers.cs b/Dalamud/Interface/ImGuiHelpers.cs
index 52c9802f9..f138cdf40 100644
--- a/Dalamud/Interface/ImGuiHelpers.cs
+++ b/Dalamud/Interface/ImGuiHelpers.cs
@@ -105,6 +105,13 @@ namespace Dalamud.Interface
return colorPalette;
}
+ ///
+ /// Get the size of a button considering the default frame padding.
+ ///
+ /// Text in the button.
+ /// with the size of the button.
+ public static Vector2 GetButtonSize(string text) => ImGui.CalcTextSize(text) + (ImGui.GetStyle().FramePadding * 2);
+
///
/// Get data needed for each new frame.
///
diff --git a/Dalamud/Interface/Internal/Windows/PluginInstallerWindow.cs b/Dalamud/Interface/Internal/Windows/PluginInstallerWindow.cs
index 7318badbe..c7fc934a1 100644
--- a/Dalamud/Interface/Internal/Windows/PluginInstallerWindow.cs
+++ b/Dalamud/Interface/Internal/Windows/PluginInstallerWindow.cs
@@ -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.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))