8000 Make the background in `SidePanel` fill the available space by birktj · Pull Request #1263 · emilk/egui · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Make the background in SidePanel fill the available space #1263

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

birktj
Copy link
@birktj birktj commented Feb 18, 2022

This is a small hack to fix #1262. It works by measuring the the size of the content in the panel with ui.min_rect(), before finally using ui.allocate_space(ui.available_size()) to force the frame to fill all the available space. Since be measured the size of the content before the space allocation this should not aff 8000 ect how much space the panel occupies in subsequent frames.

@birktj birktj force-pushed the panel-auto-shrink-tweak branch from ba6b40e to 2d23455 Compare February 20, 2022 11:26
@birktj
Copy link
Author
birktj commented Feb 20, 2022

Rebased on top of current master and fixed compilation errors

let mut rect = ui.min_rect();
rect.min -= Vec2::new(frame.margin.left, frame.margin.top);
rect.max += Vec2::new(frame.margin.right, frame.margin.bottom);
ui.allocate_space(ui.available_size());
Copy link
Owner

Choose a reason for hiding this comment

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

How does this work for left panels? Don't they just take up the entire width of the screen?

Copy link
Author

Choose a reason for hiding this comment

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

Good question. It seems to work fine and I think this is because the panel_ui given to the SidePanel has a its max_width set to the width of the panel, which initially is default_width and then ui.min_rect().width() for subsequent frames. I am not too familiar with the inner workings of the layout engine, but it seems to be this rect only grows if contents overflow somehow?

See Side::set_rect_width, the definition of panel_rect and panel_ui.

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.

Glitch with auto-shrinking side panel
2 participants
0