Menu State rect now uses menu frame rect instead of contents rect, as their position goes out of bounds. (#2886)
This commit is contained in:
parent
33aa4d698f
commit
77df9cb982
|
|
@ -147,21 +147,22 @@ pub(crate) fn menu_ui<'c, R>(
|
||||||
.fixed_pos(pos)
|
.fixed_pos(pos)
|
||||||
.interactable(true)
|
.interactable(true)
|
||||||
.drag_bounds(ctx.screen_rect());
|
.drag_bounds(ctx.screen_rect());
|
||||||
let inner_response = area.show(ctx, |ui| {
|
|
||||||
|
area.show(ctx, |ui| {
|
||||||
set_menu_style(ui.style_mut());
|
set_menu_style(ui.style_mut());
|
||||||
|
|
||||||
Frame::menu(ui.style())
|
let frame = Frame::menu(ui.style()).show(ui, |ui| {
|
||||||
.show(ui, |ui| {
|
const DEFAULT_MENU_WIDTH: f32 = 150.0; // TODO(emilk): add to ui.spacing
|
||||||
const DEFAULT_MENU_WIDTH: f32 = 150.0; // TODO(emilk): add to ui.spacing
|
ui.set_max_width(DEFAULT_MENU_WIDTH);
|
||||||
ui.set_max_width(DEFAULT_MENU_WIDTH);
|
ui.set_menu_state(Some(menu_state_arc.clone()));
|
||||||
ui.set_menu_state(Some(menu_state_arc.clone()));
|
ui.with_layout(Layout::top_down_justified(Align::LEFT), add_contents)
|
||||||
ui.with_layout(Layout::top_down_justified(Align::LEFT), add_contents)
|
.inner
|
||||||
.inner
|
});
|
||||||
})
|
|
||||||
.inner
|
menu_state_arc.write().rect = frame.response.rect;
|
||||||
});
|
|
||||||
menu_state_arc.write().rect = inner_response.response.rect;
|
frame.inner
|
||||||
inner_response
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Build a top level menu with a button.
|
/// Build a top level menu with a button.
|
||||||
|
|
@ -293,8 +294,7 @@ impl MenuRoot {
|
||||||
if self.id == response.id {
|
if self.id == response.id {
|
||||||
let inner_response =
|
let inner_response =
|
||||||
MenuState::show(&response.ctx, &self.menu_state, self.id, add_contents);
|
MenuState::show(&response.ctx, &self.menu_state, self.id, add_contents);
|
||||||
let mut menu_state = self.menu_state.write();
|
let menu_state = self.menu_state.read();
|
||||||
menu_state.rect = inner_response.response.rect;
|
|
||||||
|
|
||||||
if menu_state.response.is_close() {
|
if menu_state.response.is_close() {
|
||||||
return (MenuResponse::Close, Some(inner_response));
|
return (MenuResponse::Close, Some(inner_response));
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue