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 panel drag leaking through overlay #10035

Merged
merged 3 commits into from
Apr 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions crates/collab_ui/src/collab_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2773,6 +2773,7 @@ impl Render for CollabPanel {
.anchor(gpui::AnchorCorner::TopLeft)
.child(menu.clone()),
)
.with_priority(1)
}))
}
}
Expand Down
13 changes: 8 additions & 5 deletions crates/collab_ui/src/collab_panel/channel_modal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -408,11 +408,14 @@ impl PickerDelegate for ChannelModalDelegate {
.when(is_me, |el| el.child(Label::new("You").color(Color::Muted)))
.children(
if let (Some((menu, _)), true) = (&self.context_menu, selected) {
Some(deferred(
anchored()
.anchor(gpui::AnchorCorner::TopRight)
.child(menu.clone()),
))
Some(
deferred(
anchored()
.anchor(gpui::AnchorCorner::TopRight)
.child(menu.clone()),
)
.with_priority(1),
)
} else {
None
},
Expand Down
1 change: 1 addition & 0 deletions crates/editor/src/element.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1812,6 +1812,7 @@ impl EditorElement {
.anchor(AnchorCorner::TopLeft)
.snap_to_window(),
)
.with_priority(1)
.into_any();

element.layout(gpui::Point::default(), AvailableSpace::min_size(), cx);
Expand Down
10 changes: 10 additions & 0 deletions crates/gpui/src/elements/deferred.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@ pub struct Deferred {
priority: usize,
}

impl Deferred {
/// Sets the `priority` value of the `deferred` element, which
/// determines the drawing order relative to other deferred elements,
/// with higher values being drawn on top.
pub fn with_priority(mut self, priority: usize) -> Self {
self.priority = priority;
self
}
}

impl Element for Deferred {
type BeforeLayout = ();
type AfterLayout = ();
Expand Down
1 change: 1 addition & 0 deletions crates/project_panel/src/project_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1590,6 +1590,7 @@ impl Render for ProjectPanel {
.anchor(gpui::AnchorCorner::TopLeft)
.child(menu.clone()),
)
.with_priority(1)
}))
} else {
v_flex()
Expand Down
1 change: 1 addition & 0 deletions crates/terminal_view/src/terminal_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,7 @@ impl Render for TerminalView {
.anchor(gpui::AnchorCorner::TopLeft)
.child(menu.clone()),
)
.with_priority(1)
}))
}
}
Expand Down
5 changes: 3 additions & 2 deletions crates/ui/src/components/popover_menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,9 @@ impl<M: ManagedView> Element for PopoverMenu<M> {
this.resolved_attach().corner(child_bounds) + this.resolved_offset(cx),
);
}
let mut element =
deferred(anchored.child(div().occlude().child(menu.clone()))).into_any();
let mut element = deferred(anchored.child(div().occlude().child(menu.clone())))
.with_priority(1)
.into_any();

menu_layout_id = Some(element.before_layout(cx));
element
Expand Down
5 changes: 3 additions & 2 deletions crates/ui/src/components/right_click_menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,9 @@ impl<M: ManagedView> Element for RightClickMenu<M> {
}
anchored = anchored.position(*element_state.position.borrow());

let mut element =
deferred(anchored.child(div().occlude().child(menu.clone()))).into_any();
let mut element = deferred(anchored.child(div().occlude().child(menu.clone())))
.with_priority(1)
.into_any();

menu_layout_id = Some(element.before_layout(cx));
element
Expand Down
12 changes: 5 additions & 7 deletions crates/workspace/src/pane.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1562,16 +1562,14 @@ impl Pane {
}

fn render_menu_overlay(menu: &View<ContextMenu>) -> Div {
div()
.absolute()
.bottom_0()
.right_0()
.size_0()
.child(deferred(
div().absolute().bottom_0().right_0().size_0().child(
deferred(
anchored()
.anchor(AnchorCorner::TopRight)
.child(menu.clone()),
))
)
.with_priority(1),
)
}

pub fn set_zoomed(&mut self, zoomed: bool, cx: &mut ViewContext<Self>) {
Expand Down
Loading