-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ScopedDisabled #88
Conversation
ImGui has an API that blocks interactions and visually differentiates disabled elements. While the API is technically Beta it has been around for a long time and is a big improvement over the pattern of "if (ImGui.Button(...) && buttonEnabled)"
/// <summary> | ||
/// Represents a scoped disabled action which will set ImGui elements as disabled until the class is disposed. | ||
/// </summary> | ||
public class ScopedDisabled : ScopedAction |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How should this interact with Theme.ColorDisabled ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And how to even use Theme.ColorDisabled
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're supposed to use ScopedThemeColor
and pass in the enabled state, if the state is dynamic.
Theme.Color
and Theme.ColorDisabled` are convenience for statically colored things (ie permanently disabled/enabled).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like this is maybe more of a ImGuiWidgets thing, like ScopedId
, decouple the behavior from the presentation. The user is free to use either or both.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that this should go in ImGuiWidgets. Migrated and made a PR ktsu-dev/ImGuiWidgets#173
I'm still curious to figure out why I can't call ColorDisabled, but maybe I'll talk to you abbbbbbbbbbbbbbbbbt next week directly.
Remove attempts to track multiple active ScopedDisabled usages. While ScopedDisabled(true) will override ScopedDisabled(false) before the initial ScopeDisabled has been disposed, it won't actually cause a problem aside from maybe not doing what was intended (and that is really a logical flow error anyway)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe move to ImGuiWidgets
Migrated from ImGuiStyler: ktsu-dev/ImGuiStyler#88
Closing as moved to ImGuiWidgets. |
ImGui has an API that blocks interactions and visually differentiates disabled elements. While the API is technically Beta it has been around for a long time and is a big improvement over the pattern of "if (ImGui.Button(...) && buttonEnabled)"