Skip to content
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

Closed

Conversation

Damon3000s
Copy link
Contributor

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)"

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
Copy link
Contributor Author

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 ?

Copy link
Contributor Author

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

Copy link
Contributor

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).

Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

No matter what I try, I haven't been able to get Theme.ColorDisabled working.

Copy link
Contributor Author

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)
Copy link
Contributor

@matt-edmondson matt-edmondson left a 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

Damon3000s added a commit to Damon3000s/ImGuiWidgets that referenced this pull request Jan 31, 2025
@matt-edmondson
Copy link
Contributor

Closing as moved to ImGuiWidgets.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants