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

Ability to customize styles for Ctrl-Tab panel and other built-in ImGui windows #2312

Open
v-ein opened this issue Mar 29, 2024 · 1 comment
Labels
state: pending not addressed yet

Comments

@v-ein
Copy link
Contributor

v-ein commented Mar 29, 2024

Is your feature request related to a problem? Please describe.
DPG themes provide a nice mechanism to customize look & feel both on individual widgets and on the whole app. Unfortunately the themes are only applied when DPG itself renders widgets. There are things that Dear ImGui renders on its own, and at that moment even the theme passed in bind_theme is not applied.

This includes the window switching panel that appears when you press Ctrl-Tab (currently you need keyboard_navigation=True for this to work; #2275 will make this independent of keyboard_navigation). The window is not affected by bind_theme and may look significantly different from the rest of UI. It also includes the shadows and the frame this switching mechanism draws around the current window.

Other elements not affected by bind_theme are:

  • tool windows like show_style_editor - though for these, it might make sense to leave them unaffected? (like, the item registry window uses a hardcoded purple color that looks good in the default dark theme, but might be unreadable if the theme is changed to the light one).
  • show_imgui_demo() - for this one, it doesn't matter much whether we style it or not.
  • something else I missed?

So my primary concern is that Ctrl-Tab panel. It would be great to have bind_theme affect this panel but not tool windows; if tool windows can't be left with their own style, so be it, we can sacrifice them.

Within the Ctrl-Tab panel, the thing that mostly stands out is selection color - when your entire app uses blue for selected items, it's hard to see the dark-grey-on-black selection in that panel.

Describe the solution you'd like
The easiest (in terms of API) would be to have bind_theme modify ImGui styles globally and never pop its changes back. This, however, might need some changes in how themes apply their styles (change push/pop to direct assignment for the global theme).

Describe alternatives you've considered
None. Well, one could handle Ctrl-Tab on their own and render the switcher using DPG... but that doesn't sound sane.

Additional context
image

@v-ein v-ein added the state: pending not addressed yet label Mar 29, 2024
@v-ein
Copy link
Contributor Author

v-ein commented Jul 14, 2024

Found one more side effect of how the global theme works in DPG: when a window is docked, some colors come from ImGui style variables rather than from DPG themes. This issue was initially reported on Discord - see this thread.

Here's what it looks like:
docking-theme

Some UI elements for the docked windows, in particular, the tab bar, are rendered from within ImGui::NewFrame(), where the global theme has not applied its colors yet. Here's the call chain that finally draws the tab bar:

NewFrame -> DockContextNewFrameUpdateUndocking -> DockNodeUpdate -> DockNodeUpdateTabBar -> BeginTabBarEx

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

No branches or pull requests

1 participant