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

Define available_rect per Area #551

Closed
mankinskin opened this issue Jul 7, 2021 · 1 comment
Closed

Define available_rect per Area #551

mankinskin opened this issue Jul 7, 2021 · 1 comment

Comments

@mankinskin
Copy link
Contributor

mankinskin commented Jul 7, 2021

I recently ran into an issue when implementing context menus #543 . The context menu is an Area rendered in a Foreground layer, and it can generally be placed anywhere on the screen, even on top of panels.

The problem was that egui treats all Areas as Windows and all windows are constrained to an available_rect, which is the screen space minus the panels (except for the CentralPanel, which effectively takes up the available_rect). This caused the context menu to not recognize hovers or clicks on anything except the central panel, because it had been constrained to the available_rect:

if let Some(bounds) = drag_bounds {
state.pos = ctx.constrain_window_rect_to_area(state.rect(), bounds).min;
} else {
state.pos = ctx.constrain_window_rect(state.rect()).min;
}

In this part of the code the position of the context menu Area was constrained out of the panel that had been clicked on, so that the rect used to detect hovers was off-placed.

To circumvent this I turned this code off for immovable Areas, but in general it should be possible to drag windows over panels if that is desired. This seems to be what the drag bounds are for already, but they seem to default to the available_rect. Maybe this should be changed to default to the whole screen area, and there should be a shortcut for the bounds of the background rect.

@mankinskin mankinskin changed the title Define available_rect per Window Define available_rect per Area Jul 7, 2021
@mankinskin
Copy link
Contributor Author

Setting area.drag_bounds(Rect::EVERYTHING) fixes this.

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

No branches or pull requests

1 participant