mirror of
https://github.com/goatcorp/Dalamud.git
synced 2026-01-02 22:03:41 +01:00
Update UIDebug2, ImGuiComponents, ImGuiHelpers (#2081)
* Update ImGuiComponents & ImGuiHelpers Took some helper functions created for `UiDebug2`, and incorporated them into `ImGuiComponents` / `ImGuiHelpers` instead - `IconButton()` (and its various overloads) now includes an optional size parameter - `IconButtonSelect()` has been added, allowing a row or grid of IconButtons to serve as a radio-like input - `HelpMarker()` now includes an optional color parameter - `ClickToCopyText()` now includes an optional color parameter, and includes the `FontAwesome.Copy` icon in the tooltip. - Implemented ImRaii in these files These changes are intended not to break any existing calls in plugins or within Dalamud itself. * Fix ambiguous overloads * UiDebug2 Updates - Fixed XY coordinate display - Added AtkValue table to AddonTree display - Restored old behaviour wherein the Addon display initially only shows the Root node and a collapsed node list - The above should also fix the Element Selector / Search behaviour, allowing it to scroll correctly to the searched node - Now displays field offsets for any node/component whose pointer exists in the addon struct - Tidied up node tree headers by removing memory addresses (they're still readable in the opened tree, of course)
This commit is contained in:
parent
94f16ac16e
commit
ee63f60877
18 changed files with 649 additions and 278 deletions
|
|
@ -1,5 +1,7 @@
|
|||
using System.Numerics;
|
||||
|
||||
using Dalamud.Interface.Utility.Raii;
|
||||
|
||||
using ImGuiNET;
|
||||
|
||||
namespace Dalamud.Interface.Components;
|
||||
|
|
@ -21,17 +23,16 @@ public static partial class ImGuiComponents
|
|||
/// <returns>Indicator if button is clicked.</returns>
|
||||
public static bool DisabledButton(FontAwesomeIcon icon, int? id = null, Vector4? defaultColor = null, Vector4? activeColor = null, Vector4? hoveredColor = null, float alphaMult = .5f)
|
||||
{
|
||||
ImGui.PushFont(UiBuilder.IconFont);
|
||||
using (ImRaii.PushFont(UiBuilder.IconFont))
|
||||
{
|
||||
var text = icon.ToIconString();
|
||||
if (id.HasValue)
|
||||
{
|
||||
text = $"{text}##{id}";
|
||||
}
|
||||
|
||||
var text = icon.ToIconString();
|
||||
if (id.HasValue)
|
||||
text = $"{text}##{id}";
|
||||
|
||||
var button = DisabledButton(text, defaultColor, activeColor, hoveredColor, alphaMult);
|
||||
|
||||
ImGui.PopFont();
|
||||
|
||||
return button;
|
||||
return DisabledButton(text, defaultColor, activeColor, hoveredColor, alphaMult);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -45,31 +46,28 @@ public static partial class ImGuiComponents
|
|||
/// <returns>Indicator if button is clicked.</returns>
|
||||
public static bool DisabledButton(string labelWithId, Vector4? defaultColor = null, Vector4? activeColor = null, Vector4? hoveredColor = null, float alphaMult = .5f)
|
||||
{
|
||||
using var col = new ImRaii.Color();
|
||||
|
||||
if (defaultColor.HasValue)
|
||||
ImGui.PushStyleColor(ImGuiCol.Button, defaultColor.Value);
|
||||
{
|
||||
col.Push(ImGuiCol.Button, defaultColor.Value);
|
||||
}
|
||||
|
||||
if (activeColor.HasValue)
|
||||
ImGui.PushStyleColor(ImGuiCol.ButtonActive, activeColor.Value);
|
||||
{
|
||||
col.Push(ImGuiCol.ButtonActive, activeColor.Value);
|
||||
}
|
||||
|
||||
if (hoveredColor.HasValue)
|
||||
ImGui.PushStyleColor(ImGuiCol.ButtonHovered, hoveredColor.Value);
|
||||
{
|
||||
col.Push(ImGuiCol.ButtonHovered, hoveredColor.Value);
|
||||
}
|
||||
|
||||
var style = ImGui.GetStyle();
|
||||
ImGui.PushStyleVar(ImGuiStyleVar.Alpha, style.Alpha * alphaMult);
|
||||
|
||||
var button = ImGui.Button(labelWithId);
|
||||
|
||||
ImGui.PopStyleVar();
|
||||
|
||||
if (defaultColor.HasValue)
|
||||
ImGui.PopStyleColor();
|
||||
|
||||
if (activeColor.HasValue)
|
||||
ImGui.PopStyleColor();
|
||||
|
||||
if (hoveredColor.HasValue)
|
||||
ImGui.PopStyleColor();
|
||||
|
||||
return button;
|
||||
using (ImRaii.PushStyle(ImGuiStyleVar.Alpha, style.Alpha * alphaMult))
|
||||
{
|
||||
return ImGui.Button(labelWithId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue