mirror of
https://github.com/Ottermandias/Glamourer.git
synced 2025-12-12 18:27:24 +01:00
Improve tri-state checkboxes.
This commit is contained in:
parent
2afa5734f7
commit
f55d25b088
3 changed files with 30 additions and 20 deletions
|
|
@ -25,6 +25,9 @@ public enum ColorId
|
|||
QuickDesignButton,
|
||||
QuickDesignFrame,
|
||||
QuickDesignBg,
|
||||
TriStateCheck,
|
||||
TriStateCross,
|
||||
TriStateNeutral,
|
||||
}
|
||||
|
||||
public static class Colors
|
||||
|
|
@ -55,6 +58,9 @@ public static class Colors
|
|||
ColorId.QuickDesignButton => (0x900A0A0A, "Quick Design Bar Button Background", "The color of button frames in the quick design bar." ),
|
||||
ColorId.QuickDesignFrame => (0x90383838, "Quick Design Bar Combo Background", "The color of the combo background in the quick design bar." ),
|
||||
ColorId.QuickDesignBg => (0x00F0F0F0, "Quick Design Bar Window Background", "The color of the window background in the quick design bar." ),
|
||||
ColorId.TriStateCheck => (0xFF00D000, "Checkmark in Tri-State Checkboxes", "The color of the checkmark indicating positive change in tri-state checkboxes." ),
|
||||
ColorId.TriStateCross => (0xFF0000D0, "Cross in Tri-State Checkboxes", "The color of the cross indicating negative change in tri-state checkboxes." ),
|
||||
ColorId.TriStateNeutral => (0xFFD0D0D0, "Dot in Tri-State Checkboxes", "The color of the dot indicating no change in tri-state checkboxes" ),
|
||||
_ => (0x00000000, string.Empty, string.Empty ),
|
||||
// @formatter:on
|
||||
};
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ using Glamourer.Unlocks;
|
|||
using ImGuiNET;
|
||||
using Lumina.Misc;
|
||||
using OtterGui;
|
||||
using OtterGui.Classes;
|
||||
using OtterGui.Raii;
|
||||
using Penumbra.GameData.Enums;
|
||||
using Penumbra.GameData.Structs;
|
||||
|
|
@ -71,15 +72,26 @@ public static class UiHelpers
|
|||
}
|
||||
|
||||
public static DataChange DrawMetaToggle(string label, bool currentValue, bool currentApply, out bool newValue,
|
||||
out bool newApply,
|
||||
bool locked)
|
||||
out bool newApply, bool locked)
|
||||
{
|
||||
var flags = currentApply ? currentValue ? 3 : 0 : 2;
|
||||
bool ret;
|
||||
var flags = (sbyte)(currentApply ? currentValue ? 1 : -1 : 0);
|
||||
using var style = ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, ImGui.GetStyle().ItemInnerSpacing);
|
||||
using (var disabled = ImRaii.Disabled(locked))
|
||||
{
|
||||
ret = ImGui.CheckboxFlags("##" + label, ref flags, 3);
|
||||
if (new TristateCheckbox(ColorId.TriStateCross.Value(), ColorId.TriStateCheck.Value(), ColorId.TriStateNeutral.Value()).Draw("##" + label, flags, out flags))
|
||||
{
|
||||
(newValue, newApply) = flags switch
|
||||
{
|
||||
-1 => (false, true),
|
||||
0 => (true, false),
|
||||
_ => (true, true),
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
newValue = currentValue;
|
||||
newApply = currentApply;
|
||||
}
|
||||
}
|
||||
|
||||
ImGuiUtil.HoverTooltip($"This attribute will be {(currentApply ? currentValue ? "enabled." : "disabled." : "kept as is.")}");
|
||||
|
|
@ -87,21 +99,13 @@ public static class UiHelpers
|
|||
ImGui.SameLine();
|
||||
ImGui.TextUnformatted(label);
|
||||
|
||||
if (ret)
|
||||
return (currentApply != newApply, currentValue != newValue) switch
|
||||
{
|
||||
(newValue, newApply, var change) = (currentValue, currentApply) switch
|
||||
{
|
||||
(false, false) => (false, true, DataChange.ApplyItem),
|
||||
(false, true) => (true, true, DataChange.Item),
|
||||
(true, false) => (false, false, DataChange.Item), // Should not happen
|
||||
(true, true) => (false, false, DataChange.Item | DataChange.ApplyItem),
|
||||
};
|
||||
return change;
|
||||
}
|
||||
|
||||
newValue = currentValue;
|
||||
newApply = currentApply;
|
||||
return DataChange.None;
|
||||
(true, true) => DataChange.ApplyItem | DataChange.Item,
|
||||
(true, false) => DataChange.ApplyItem,
|
||||
(false, true) => DataChange.Item,
|
||||
_ => DataChange.None,
|
||||
};
|
||||
}
|
||||
|
||||
public static (EquipFlag, CustomizeFlag) ConvertKeysToFlags()
|
||||
|
|
|
|||
2
OtterGui
2
OtterGui
|
|
@ -1 +1 @@
|
|||
Subproject commit b09bbcc276363bc994d90b641871e6280898b6e5
|
||||
Subproject commit f55733a96fdc9f82c9bbf8272ca6366079aa8e32
|
||||
Loading…
Add table
Add a link
Reference in a new issue