gpui: Rework overlay element (#9911)
There was a problem using deferred draws with `overlay` and tooltips at the same time. The `overlay` element was removed and was split up into two separate elements - `deferred` - `anchored` - Mimics the `overlay` behavior but does not render its children as deferred `tooltip_container` does not defer its drawing anymore and only uses `anchored`. /cc @as-cii Release Notes: - Fixed tooltip for the recent projects popover not showing anymore --------- Co-authored-by: Antonio <antonio@zed.dev>
This commit is contained in:
parent
49144d94bf
commit
77f1cc95b8
12 changed files with 144 additions and 136 deletions
|
@ -20,13 +20,14 @@ use anyhow::Result;
|
|||
use collections::{BTreeMap, HashMap};
|
||||
use git::{blame::BlameEntry, diff::DiffHunkStatus, Oid};
|
||||
use gpui::{
|
||||
div, fill, outline, overlay, point, px, quad, relative, size, svg, transparent_black, Action,
|
||||
AnchorCorner, AnyElement, AnyView, AvailableSpace, Bounds, ClipboardItem, ContentMask, Corners,
|
||||
CursorStyle, DispatchPhase, Edges, Element, ElementContext, ElementInputHandler, Entity,
|
||||
Hitbox, Hsla, InteractiveElement, IntoElement, ModifiersChangedEvent, MouseButton,
|
||||
MouseDownEvent, MouseMoveEvent, MouseUpEvent, ParentElement, Pixels, ScrollDelta,
|
||||
ScrollWheelEvent, ShapedLine, SharedString, Size, Stateful, StatefulInteractiveElement, Style,
|
||||
Styled, TextRun, TextStyle, TextStyleRefinement, View, ViewContext, WindowContext,
|
||||
anchored, deferred, div, fill, outline, point, px, quad, relative, size, svg,
|
||||
transparent_black, Action, AnchorCorner, AnyElement, AnyView, AvailableSpace, Bounds,
|
||||
ClipboardItem, ContentMask, Corners, CursorStyle, DispatchPhase, Edges, Element,
|
||||
ElementContext, ElementInputHandler, Entity, Hitbox, Hsla, InteractiveElement, IntoElement,
|
||||
ModifiersChangedEvent, MouseButton, MouseDownEvent, MouseMoveEvent, MouseUpEvent,
|
||||
ParentElement, Pixels, ScrollDelta, ScrollWheelEvent, ShapedLine, SharedString, Size, Stateful,
|
||||
StatefulInteractiveElement, Style, Styled, TextRun, TextStyle, TextStyleRefinement, View,
|
||||
ViewContext, WindowContext,
|
||||
};
|
||||
use itertools::Itertools;
|
||||
use language::language_settings::ShowWhitespaceSetting;
|
||||
|
@ -1804,12 +1805,15 @@ impl EditorElement {
|
|||
|
||||
fn layout_mouse_context_menu(&self, cx: &mut ElementContext) -> Option<AnyElement> {
|
||||
let mouse_context_menu = self.editor.read(cx).mouse_context_menu.as_ref()?;
|
||||
let mut element = overlay()
|
||||
.position(mouse_context_menu.position)
|
||||
.child(mouse_context_menu.context_menu.clone())
|
||||
.anchor(AnchorCorner::TopLeft)
|
||||
.snap_to_window()
|
||||
.into_any();
|
||||
let mut element = deferred(
|
||||
anchored()
|
||||
.position(mouse_context_menu.position)
|
||||
.child(mouse_context_menu.context_menu.clone())
|
||||
.anchor(AnchorCorner::TopLeft)
|
||||
.snap_to_window(),
|
||||
)
|
||||
.into_any();
|
||||
|
||||
element.layout(gpui::Point::default(), AvailableSpace::min_size(), cx);
|
||||
Some(element)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue