-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #173 from Damon3000s/add-scoped-disabled
Add scoped disabled
- Loading branch information
Showing
2 changed files
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
namespace ktsu.ImGuiWidgets; | ||
|
||
using ImGuiNET; | ||
using ScopedAction; | ||
|
||
/// <summary> | ||
/// Represents a scoped disable action which will set Dear ImGui elements as functionally and visually disabled until | ||
/// the class is disposed. | ||
/// </summary> | ||
public class ScopedDisable : ScopedAction | ||
{ | ||
/// <summary> | ||
/// Note as per the Dear ImGui documentation: "Those can be nested, but it cannot | ||
/// be used to enable an already disabled section (a single BeginDisabled(true) | ||
/// in the stack is enough to keep everything disabled)" | ||
/// </summary> | ||
/// <param name="enabled">Should the elements within the scope be disabled</param> | ||
public ScopedDisable(bool enabled) | ||
{ | ||
ImGui.BeginDisabled(enabled); | ||
OnClose = ImGui.EndDisabled; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters