Merge remote-tracking branch 'upstream/master'
# Conflicts: # iced
This commit is contained in:
commit
173d6ebd32
9 changed files with 105 additions and 108 deletions
|
|
@ -634,6 +634,7 @@ where
|
|||
return;
|
||||
}
|
||||
shell.capture_event();
|
||||
shell.request_redraw();
|
||||
#[cfg(wayland_platform)]
|
||||
if matches!(WINDOWING_SYSTEM.get(), Some(WindowingSystem::Wayland)) {
|
||||
self.create_popup(layout, view_cursor, renderer, shell, viewport, my_state);
|
||||
|
|
|
|||
|
|
@ -650,12 +650,13 @@ impl<'b, Message: Clone + 'static> Menu<'b, Message> {
|
|||
state.pressed = false;
|
||||
|
||||
// process close condition
|
||||
if state
|
||||
.view_cursor
|
||||
.position()
|
||||
.unwrap_or_default()
|
||||
.distance(view_cursor.position().unwrap_or_default())
|
||||
< 2.0
|
||||
if state.open
|
||||
&& state
|
||||
.view_cursor
|
||||
.position()
|
||||
.unwrap_or_default()
|
||||
.distance(view_cursor.position().unwrap_or_default())
|
||||
< 2.0
|
||||
{
|
||||
let is_inside = state.menu_states[..=if self.is_overlay {
|
||||
state.active_root.len().saturating_sub(1)
|
||||
|
|
@ -1428,47 +1429,48 @@ where
|
|||
state.view_cursor = view_cursor;
|
||||
|
||||
// * remove invalid menus
|
||||
if state.open {
|
||||
let mut prev_bounds = std::iter::once(menu.bar_bounds)
|
||||
.chain(
|
||||
if menu.is_overlay {
|
||||
state.menu_states[..state.menu_states.len().saturating_sub(1)].iter()
|
||||
} else {
|
||||
state.menu_states[..menu.depth].iter()
|
||||
}
|
||||
.map(|s| s.menu_bounds.children_bounds),
|
||||
)
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
let mut prev_bounds = std::iter::once(menu.bar_bounds)
|
||||
.chain(
|
||||
if menu.is_overlay {
|
||||
state.menu_states[..state.menu_states.len().saturating_sub(1)].iter()
|
||||
} else {
|
||||
state.menu_states[..menu.depth].iter()
|
||||
if menu.is_overlay && menu.close_condition.leave {
|
||||
for i in (0..state.menu_states.len()).rev() {
|
||||
let mb = &state.menu_states[i].menu_bounds;
|
||||
|
||||
if mb.parent_bounds.contains(overlay_cursor)
|
||||
|| menu.is_overlay && mb.children_bounds.contains(overlay_cursor)
|
||||
|| mb.offset_bounds.contains(overlay_cursor)
|
||||
|| (mb.check_bounds.contains(overlay_cursor)
|
||||
&& prev_bounds.iter().all(|pvb| !pvb.contains(overlay_cursor)))
|
||||
{
|
||||
break;
|
||||
}
|
||||
prev_bounds.pop();
|
||||
state.active_root.pop();
|
||||
state.menu_states.pop();
|
||||
}
|
||||
.map(|s| s.menu_bounds.children_bounds),
|
||||
)
|
||||
.collect::<Vec<_>>();
|
||||
} else if menu.is_overlay {
|
||||
for i in (0..state.menu_states.len()).rev() {
|
||||
let mb = &state.menu_states[i].menu_bounds;
|
||||
|
||||
if menu.is_overlay && menu.close_condition.leave {
|
||||
for i in (0..state.menu_states.len()).rev() {
|
||||
let mb = &state.menu_states[i].menu_bounds;
|
||||
|
||||
if mb.parent_bounds.contains(overlay_cursor)
|
||||
|| menu.is_overlay && mb.children_bounds.contains(overlay_cursor)
|
||||
|| mb.offset_bounds.contains(overlay_cursor)
|
||||
|| (mb.check_bounds.contains(overlay_cursor)
|
||||
&& prev_bounds.iter().all(|pvb| !pvb.contains(overlay_cursor)))
|
||||
{
|
||||
break;
|
||||
if mb.parent_bounds.contains(overlay_cursor)
|
||||
|| mb.children_bounds.contains(overlay_cursor)
|
||||
|| prev_bounds.iter().all(|pvb| !pvb.contains(overlay_cursor))
|
||||
{
|
||||
break;
|
||||
}
|
||||
prev_bounds.pop();
|
||||
state.active_root.pop();
|
||||
state.menu_states.pop();
|
||||
}
|
||||
prev_bounds.pop();
|
||||
state.active_root.pop();
|
||||
state.menu_states.pop();
|
||||
}
|
||||
} else if menu.is_overlay {
|
||||
for i in (0..state.menu_states.len()).rev() {
|
||||
let mb = &state.menu_states[i].menu_bounds;
|
||||
|
||||
if mb.parent_bounds.contains(overlay_cursor)
|
||||
|| mb.children_bounds.contains(overlay_cursor)
|
||||
|| prev_bounds.iter().all(|pvb| !pvb.contains(overlay_cursor))
|
||||
{
|
||||
break;
|
||||
}
|
||||
prev_bounds.pop();
|
||||
state.active_root.pop();
|
||||
state.menu_states.pop();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ pub enum Position {
|
|||
#[default]
|
||||
Center,
|
||||
Bottom,
|
||||
Top,
|
||||
Point(Point),
|
||||
}
|
||||
|
||||
|
|
@ -259,6 +260,7 @@ where
|
|||
Position::Point(relative) => {
|
||||
bounds.position() + Vector::new(relative.x, relative.y)
|
||||
}
|
||||
Position::Top => Point::new(bounds.x + bounds.width / 2.0, bounds.y),
|
||||
};
|
||||
|
||||
// Round position to prevent rendering issues
|
||||
|
|
@ -353,6 +355,12 @@ where
|
|||
position.x = (position.x - width / 2.0).clamp(0.0, bounds.width - width);
|
||||
position.y = (position.y - height / 2.0).clamp(0.0, bounds.height - height);
|
||||
}
|
||||
Position::Top => {
|
||||
let width = node.size().width;
|
||||
let height = node.size().height;
|
||||
position.x = (position.x - width / 2.0).clamp(0.0, bounds.width - width);
|
||||
position.y = (position.y - height).clamp(0.0, bounds.height - height);
|
||||
}
|
||||
Position::Bottom => {
|
||||
// Position is set to the center bottom of the widget
|
||||
let width = node.size().width;
|
||||
|
|
|
|||
|
|
@ -1925,6 +1925,7 @@ where
|
|||
..
|
||||
}) = event
|
||||
{
|
||||
shell.request_redraw();
|
||||
state.focused_visible = true;
|
||||
return if *modifiers == keyboard::Modifiers::SHIFT {
|
||||
self.focus_previous(state, shell);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue