Skip to content

Commit

Permalink
imgui button helper
Browse files Browse the repository at this point in the history
  • Loading branch information
saint11 committed Oct 1, 2024
1 parent e2f8f74 commit 8108ad5
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/Murder.Editor/Utilities/Gui/ImGuiHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,28 @@ public static void HelpTooltip(string description)
ImGui.EndTooltip();
}
}
public static bool PressedButtton(string label, ref bool pressed, bool reverse = false)
{
bool wasPressed = (pressed && !reverse) || (!pressed && reverse);
if (wasPressed)
{
ImGui.PushStyleColor(ImGuiCol.Button, Game.Profile.Theme.BgFaded);
}

bool down = false;
if (ImGui.Button(label))
{
pressed = !pressed;
down = true;
}

if (wasPressed)
{
ImGui.PopStyleColor(1);
}

return down;
}
public static bool SelectedButton(string label, Vector4? color = default)
{
color ??= Game.Profile.Theme.BgFaded;
Expand Down

0 comments on commit 8108ad5

Please sign in to comment.