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

Option to bring absolutely positioned) button to front? #2300

Open
giogina opened this issue Mar 15, 2024 · 3 comments
Open

Option to bring absolutely positioned) button to front? #2300

giogina opened this issue Mar 15, 2024 · 3 comments
Labels
state: pending not addressed yet

Comments

@giogina
Copy link

giogina commented Mar 15, 2024

Is your feature request related to a problem? Please describe.
I have this button with an absolute position set. No matter when I create it - even as the very first or last thing in my main window - it ends up behind another item (if it's relevant - a plot within a child window within a table), so that it's not clickable.

Describe the solution you'd like
I would like this button to hover above all other items and be clickable. Either through a z ordering option, or maybe items with absolute position should by default be above other items.

Describe alternatives you've considered
Tried all orders of item creation, none worked. Layers are for draw items only, right?

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

v-ein commented Mar 15, 2024

Unfortunately the immediate GUI paradigm doesn't work well with Z ordering.

Here's an explanation on item overlapping that I gave some time ago on Discord. It might explain why you're having troubles with the abs-positioned button. We can try to make it work for you if you attach a piece of code and a screenshot of what you're getting and what you want to get.

(the text below is a copy-paste from a Discord thread)


Personally I don't see any problems with that. You can overlap most widgets in DPG, provided that you understand how ImGui works... That is,

  1. For regular widgets, the widget being rendered first swallows events that it can handle. E.g. if you overlap two buttons, the first to render will handle the clicks and hovers.

  2. The widgets are rendered one atop another, that is, for two buttons, the one that visually stays at top is the second one, not the first. That's why you normally don't want to overlap buttons: the first gets all events, the second is most visible (remember the background is often translucent so we still see the first button), and the overall result is weird. But for some other widgets it works pretty well.

  3. Windows isolate event handling so if you put a window on top of something, even with transparent background, the window (or its children) will get the events. Applies to child_window, too.

  4. Things might become weird in tables because tables are rendered in a non-trivial way, but most of the time it all goes as usual.

To overlap widgets, use pos=(x, y), OR if you're brave enough you can try to use a table with no_clip=True.

@giogina
Copy link
Author

giogina commented Mar 15, 2024

Thank you! Just leaving the screenshot here for now, as I won't have time to extract the relevant code sections until Monday. It's this small caret button on the top left corner (right under the import data tab), meant to expand a panel back out, so not taking up extra space is kinda the whole point of it (although currently I'm circumventing the problem by using a spacer next to the plot normally while the button is there).

floaty button screenshot

Btw, the plot functionality is amazing, never had a plot this interactive!

@v-ein
Copy link
Contributor

v-ein commented Mar 19, 2024

Try to put the caret button into its own child_window and see if it works for you. If the plot overlaps it, try to create the button (and the child window) after the plot, not before.

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

2 participants