Disentangle the rendering of editor hover and mouse context menu

Also prevent hover while mouse context menu is deployed
This commit is contained in:
Julia 2024-01-10 14:57:18 -05:00
parent 1c77104050
commit 997d1f0979
4 changed files with 8 additions and 6 deletions

View file

@ -1473,7 +1473,7 @@ impl CodeActionsMenu {
.collect() .collect()
}, },
) )
.elevation_1(cx) .elevation_2(cx)
.px_2() .px_2()
.py_1() .py_1()
.max_h(max_height) .max_h(max_height)

View file

@ -39,7 +39,8 @@ pub fn hover(editor: &mut Editor, _: &Hover, cx: &mut ViewContext<Editor>) {
/// depending on whether a point to hover over is provided. /// depending on whether a point to hover over is provided.
pub fn hover_at(editor: &mut Editor, point: Option<DisplayPoint>, cx: &mut ViewContext<Editor>) { pub fn hover_at(editor: &mut Editor, point: Option<DisplayPoint>, cx: &mut ViewContext<Editor>) {
if EditorSettings::get_global(cx).hover_popover_enabled { if EditorSettings::get_global(cx).hover_popover_enabled {
if let Some(point) = point { let has_context_menu = editor.mouse_context_menu.is_some();
if let (Some(point), false) = (point, has_context_menu) {
show_hover(editor, point, false, cx); show_hover(editor, point, false, cx);
} else { } else {
hide_hover(editor, cx); hide_hover(editor, cx);
@ -477,7 +478,7 @@ impl InfoPopover {
) -> AnyElement { ) -> AnyElement {
div() div()
.id("info_popover") .id("info_popover")
.elevation_2(cx) .elevation_1(cx)
.p_2() .p_2()
.overflow_y_scroll() .overflow_y_scroll()
.max_w(max_size.width) .max_w(max_size.width)
@ -547,6 +548,7 @@ impl DiagnosticPopover {
div() div()
.id("diagnostic") .id("diagnostic")
.overflow_y_scroll() .overflow_y_scroll()
.elevation_1(cx)
.px_2() .px_2()
.py_1() .py_1()
.bg(diagnostic_colors.background) .bg(diagnostic_colors.background)

View file

@ -233,7 +233,7 @@ impl ContextMenuItem {
impl Render for ContextMenu { impl Render for ContextMenu {
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoElement { fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoElement {
div().elevation_2(cx).flex().flex_row().child( div().elevation_3(cx).flex().flex_row().child(
v_stack() v_stack()
.min_w(px(200.)) .min_w(px(200.))
.track_focus(&self.focus_handle) .track_focus(&self.focus_handle)

View file

@ -42,12 +42,12 @@ impl RenderOnce for Popover {
fn render(self, cx: &mut WindowContext) -> impl IntoElement { fn render(self, cx: &mut WindowContext) -> impl IntoElement {
div() div()
.flex() .flex()
.elevation_2(cx)
.gap_1() .gap_1()
.child(v_stack().elevation_2(cx).px_1().children(self.children)) .child(v_stack().px_1().children(self.children))
.when_some(self.aside, |this, aside| { .when_some(self.aside, |this, aside| {
this.child( this.child(
v_stack() v_stack()
.elevation_2(cx)
.bg(cx.theme().colors().surface_background) .bg(cx.theme().colors().surface_background)
.px_1() .px_1()
.child(aside), .child(aside),