mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-13 12:14:16 +01:00
* 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)
72 lines
2.5 KiB
C#
72 lines
2.5 KiB
C#
using System.Numerics;
|
|
|
|
using Dalamud.Interface.Utility;
|
|
using Dalamud.Interface.Utility.Raii;
|
|
|
|
using ImGuiNET;
|
|
|
|
namespace Dalamud.Interface.Components;
|
|
|
|
/// <summary>
|
|
/// Class containing various methods providing ImGui components.
|
|
/// </summary>
|
|
public static partial class ImGuiComponents
|
|
{
|
|
/// <summary>
|
|
/// ColorPicker with palette.
|
|
/// </summary>
|
|
/// <param name="id">Id for the color picker.</param>
|
|
/// <param name="description">The description of the color picker.</param>
|
|
/// <param name="originalColor">The current color.</param>
|
|
/// <returns>Selected color.</returns>
|
|
public static Vector4 ColorPickerWithPalette(int id, string description, Vector4 originalColor)
|
|
{
|
|
const ImGuiColorEditFlags flags = ImGuiColorEditFlags.NoSidePreview | ImGuiColorEditFlags.NoSmallPreview;
|
|
return ColorPickerWithPalette(id, description, originalColor, flags);
|
|
}
|
|
|
|
/// <summary>
|
|
/// ColorPicker with palette with color picker options.
|
|
/// </summary>
|
|
/// <param name="id">Id for the color picker.</param>
|
|
/// <param name="description">The description of the color picker.</param>
|
|
/// <param name="originalColor">The current color.</param>
|
|
/// <param name="flags">Flags to customize color picker.</param>
|
|
/// <returns>Selected color.</returns>
|
|
public static Vector4 ColorPickerWithPalette(int id, string description, Vector4 originalColor, ImGuiColorEditFlags flags)
|
|
{
|
|
var existingColor = originalColor;
|
|
var selectedColor = originalColor;
|
|
var colorPalette = ImGuiHelpers.DefaultColorPalette(36);
|
|
if (ImGui.ColorButton($"{description}###ColorPickerButton{id}", originalColor))
|
|
{
|
|
ImGui.OpenPopup($"###ColorPickerPopup{id}");
|
|
}
|
|
|
|
using var popup = ImRaii.Popup($"###ColorPickerPopup{id}");
|
|
|
|
if (popup)
|
|
{
|
|
if (ImGui.ColorPicker4($"###ColorPicker{id}", ref existingColor, flags))
|
|
{
|
|
selectedColor = existingColor;
|
|
}
|
|
|
|
for (var i = 0; i < 4; i++)
|
|
{
|
|
ImGui.Spacing();
|
|
for (var j = i * 9; j < (i * 9) + 9; j++)
|
|
{
|
|
if (ImGui.ColorButton($"###ColorPickerSwatch{id}{i}{j}", colorPalette[j]))
|
|
{
|
|
selectedColor = colorPalette[j];
|
|
}
|
|
|
|
ImGui.SameLine();
|
|
}
|
|
}
|
|
}
|
|
|
|
return selectedColor;
|
|
}
|
|
}
|