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

Fix not showing "picker_mode" in demo #2272

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

SamuMazzi
Copy link
Contributor

@SamuMazzi SamuMazzi commented Jan 31, 2024


name: Fix not showing "picker_mode" in demo
about: Fixing demo
title: Fix not showing "picker_mode" in demo


Description:
In the "Color Picker & Edit" section of the demo the option "picker_mode" wasn't shown, now it's visible. This has been done creating a dummy group just to create an ID where the _add_config_options down in the code can "attach" to.

Actually this opens the question on why this happens. The parameter before should work differently.
Should I open an issue about that?

Concerning Areas:
None

@v-ein
Copy link
Contributor

v-ein commented Jan 31, 2024

Did you mean the option "picker_mode", not "color_picker"?

@v-ein
Copy link
Contributor

v-ein commented Jan 31, 2024

As to why this happens:

  • Without the fix, _before_id points to the first child of a horizontal group.
  • Then _add_config_options inserts a table into that group, and puts all those checkboxes into the table. The table is inserted before the text label "picker_mode:" and becomes the first child of that group.
  • The table stretches to fill the window width. Since the group is horizontal, the rest of the group get rendered on the right side of the table, that is, outside of the window client area.

If horizontal scrollbar on the window was enabled, we'd see the scrollbar and would be able to scroll to the right and see the "picker_mode" option.

@v-ein
Copy link
Contributor

v-ein commented Jan 31, 2024

Another approach to fix it could be to insert the table before that horizontal group:

with dpg.group(horizontal=True) as _before_id:
    dpg.add_text("picker_mode:")

This doesn't require an extra empty group.

@SamuMazzi
Copy link
Contributor Author

Oh okay! Really thank you @v-ein for the explanation!
Also I think that your last piece of code is definetely a more elegant way of handle this problem, so I refactored it!

@SamuMazzi SamuMazzi changed the title Fix not showing "color_picker" in demo Fix not showing "picker_mode" in demo Jan 31, 2024
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.

None yet

2 participants