Fix flickering (#9012)

See https://zed.dev/channel/gpui-536

Fixes https://github.com/zed-industries/zed/issues/9010
Fixes https://github.com/zed-industries/zed/issues/8883
Fixes https://github.com/zed-industries/zed/issues/8640
Fixes https://github.com/zed-industries/zed/issues/8598
Fixes https://github.com/zed-industries/zed/issues/8579
Fixes https://github.com/zed-industries/zed/issues/8363
Fixes https://github.com/zed-industries/zed/issues/8207


### Problem

After transitioning Zed to GPUI 2, we started noticing that interacting
with the mouse on many UI elements would lead to a pretty annoying
flicker. The main issue with the old approach was that hover state was
calculated based on the previous frame. That is, when computing whether
a given element was hovered in the current frame, we would use
information about the same element in the previous frame.

However, inspecting the previous frame tells us very little about what
should be hovered in the current frame, as elements in the current frame
may have changed significantly.

### Solution

This pull request's main contribution is the introduction of a new
`after_layout` phase when redrawing the window. The key idea is that
we'll give every element a chance to register a hitbox (see
`ElementContext::insert_hitbox`) before painting anything. Then, during
the `paint` phase, elements can determine whether they're the topmost
and draw their hover state accordingly.

We are also removing the ability to give an arbitrary z-index to
elements. Instead, we will follow the much simpler painter's algorithm.
That is, an element that gets painted after will be drawn on top of an
element that got painted earlier. Elements can still escape their
current "stacking context" by using the new `ElementContext::defer_draw`
method (see `Overlay` for an example). Elements drawn using this method
will still be logically considered as being children of their original
parent (for keybinding, focus and cache invalidation purposes) but their
layout and paint passes will be deferred until the currently-drawn
element is done.

With these changes we also reworked geometry batching within the
`Scene`. The new approach uses an AABB tree to determine geometry
occlusion, which allows the GPU to render non-overlapping geometry in
parallel.

### Performance

Performance is slightly better than on `main` even though this new
approach is more correct and we're maintaining an extra data structure
(the AABB tree).


![before_after](https://github.com/zed-industries/zed/assets/482957/c8120b07-1dbd-4776-834a-d040e569a71e)

Release Notes:

- Fixed a bug that was causing popovers to flicker.

---------

Co-authored-by: Nathan Sobo <nathan@zed.dev>
Co-authored-by: Thorsten <thorsten@zed.dev>
This commit is contained in:
Antonio Scandurra 2024-03-11 10:45:57 +01:00 committed by GitHub
parent 9afd78b35e
commit 4700d33728
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
74 changed files with 6434 additions and 6301 deletions

View file

@ -4,8 +4,8 @@ use crate::{status_bar::StatusItemView, Workspace};
use gpui::{
div, px, Action, AnchorCorner, AnyView, AppContext, Axis, ClickEvent, Entity, EntityId,
EventEmitter, FocusHandle, FocusableView, IntoElement, KeyContext, MouseButton, ParentElement,
Render, SharedString, Styled, Subscription, View, ViewContext, VisualContext, WeakView,
WindowContext,
Render, SharedString, StyleRefinement, Styled, Subscription, View, ViewContext, VisualContext,
WeakView, WindowContext,
};
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
@ -563,8 +563,7 @@ impl Render for Dock {
cx.stop_propagation();
}
}))
.z_index(1)
.block_mouse();
.occlude();
match self.position() {
DockPosition::Left => {
@ -618,7 +617,12 @@ impl Render for Dock {
Axis::Horizontal => this.min_w(size).h_full(),
Axis::Vertical => this.min_h(size).w_full(),
})
.child(entry.panel.to_any().cached()),
.child(
entry
.panel
.to_any()
.cached(StyleRefinement::default().v_flex().size_full()),
),
)
.child(handle)
} else {

View file

@ -139,21 +139,15 @@ impl Render for ModalLayer {
return div();
};
div()
.absolute()
.size_full()
.top_0()
.left_0()
.z_index(169)
.child(
v_flex()
.h(px(0.0))
.top_20()
.flex()
.flex_col()
.items_center()
.track_focus(&active_modal.focus_handle)
.child(h_flex().child(active_modal.modal.view())),
)
div().absolute().size_full().top_0().left_0().child(
v_flex()
.h(px(0.0))
.top_20()
.flex()
.flex_col()
.items_center()
.track_focus(&active_modal.focus_handle)
.child(h_flex().child(active_modal.modal.view())),
)
}
}

View file

@ -1561,7 +1561,6 @@ impl Pane {
fn render_menu_overlay(menu: &View<ContextMenu>) -> Div {
div()
.absolute()
.z_index(1)
.bottom_0()
.right_0()
.size_0()
@ -1886,7 +1885,6 @@ impl Render for Pane {
.child(
// drag target
div()
.z_index(1)
.invisible()
.absolute()
.bg(theme::color_alpha(

View file

@ -1,239 +0,0 @@
use super::DraggedItem;
use crate::{Pane, SplitDirection, Workspace};
use gpui::{
color::Color,
elements::{Canvas, MouseEventHandler, ParentComponent, Stack},
geometry::{rect::RectF, vector::Vector2F},
platform::MouseButton,
scene::MouseUp,
AppContext, Element, EventContext, MouseState, Quad, ViewContext, WeakViewHandle,
};
use project2::ProjectEntryId;
pub fn dragged_item_receiver<Tag, D, F>(
pane: &Pane,
region_id: usize,
drop_index: usize,
allow_same_pane: bool,
split_margin: Option<f32>,
cx: &mut ViewContext<Pane>,
render_child: F,
) -> MouseEventHandler<Pane>
where
Tag: 'static,
D: Element<Pane>,
F: FnOnce(&mut MouseState, &mut ViewContext<Pane>) -> D,
{
let drag_and_drop = cx.global::<DragAndDrop<Workspace>>();
let drag_position = if (pane.can_drop)(drag_and_drop, cx) {
drag_and_drop
.currently_dragged::<DraggedItem>(cx.window())
.map(|(drag_position, _)| drag_position)
.or_else(|| {
drag_and_drop
.currently_dragged::<ProjectEntryId>(cx.window())
.map(|(drag_position, _)| drag_position)
})
} else {
None
};
let mut handler = MouseEventHandler::above::<Tag, _>(region_id, cx, |state, cx| {
// Observing hovered will cause a render when the mouse enters regardless
// of if mouse position was accessed before
let drag_position = if state.dragging() {
drag_position
} else {
None
};
Stack::new()
.with_child(render_child(state, cx))
.with_children(drag_position.map(|drag_position| {
Canvas::new(move |bounds, _, _, cx| {
if bounds.contains_point(drag_position) {
let overlay_region = split_margin
.and_then(|split_margin| {
drop_split_direction(drag_position, bounds, split_margin)
.map(|dir| (dir, split_margin))
})
.map(|(dir, margin)| dir.along_edge(bounds, margin))
.unwrap_or(bounds);
cx.scene().push_stacking_context(None, None);
let background = overlay_color(cx);
cx.scene().push_quad(Quad {
bounds: overlay_region,
background: Some(background),
border: Default::default(),
corner_radii: Default::default(),
});
cx.scene().pop_stacking_context();
}
})
}))
});
if drag_position.is_some() {
handler = handler
.on_up(MouseButton::Left, {
move |event, pane, cx| {
let workspace = pane.workspace.clone();
let pane = cx.weak_handle();
handle_dropped_item(
event,
workspace,
&pane,
drop_index,
allow_same_pane,
split_margin,
cx,
);
cx.notify();
}
})
.on_move(|_, _, cx| {
let drag_and_drop = cx.global::<DragAndDrop<Workspace>>();
if drag_and_drop
.currently_dragged::<DraggedItem>(cx.window())
.is_some()
|| drag_and_drop
.currently_dragged::<ProjectEntryId>(cx.window())
.is_some()
{
cx.notify();
} else {
cx.propagate_event();
}
})
}
handler
}
pub fn handle_dropped_item<V: 'static>(
event: MouseUp,
workspace: WeakViewHandle<Workspace>,
pane: &WeakViewHandle<Pane>,
index: usize,
allow_same_pane: bool,
split_margin: Option<f32>,
cx: &mut EventContext<V>,
) {
enum Action {
Move(WeakViewHandle<Pane>, usize),
Open(ProjectEntryId),
}
let drag_and_drop = cx.global::<DragAndDrop<Workspace>>();
let action = if let Some((_, dragged_item)) =
drag_and_drop.currently_dragged::<DraggedItem>(cx.window())
{
Action::Move(dragged_item.pane.clone(), dragged_item.handle.id())
} else if let Some((_, project_entry)) =
drag_and_drop.currently_dragged::<ProjectEntryId>(cx.window())
{
Action::Open(*project_entry)
} else {
cx.propagate_event();
return;
};
if let Some(split_direction) =
split_margin.and_then(|margin| drop_split_direction(event.position, event.region, margin))
{
let pane_to_split = pane.clone();
match action {
Action::Move(from, item_id_to_move) => {
cx.window_context().defer(move |cx| {
if let Some(workspace) = workspace.upgrade(cx) {
workspace.update(cx, |workspace, cx| {
workspace.split_pane_with_item(
pane_to_split,
split_direction,
from,
item_id_to_move,
cx,
);
})
}
});
}
Action::Open(project_entry) => {
cx.window_context().defer(move |cx| {
if let Some(workspace) = workspace.upgrade(cx) {
workspace.update(cx, |workspace, cx| {
if let Some(task) = workspace.split_pane_with_project_entry(
pane_to_split,
split_direction,
project_entry,
cx,
) {
task.detach_and_log_err(cx);
}
})
}
});
}
};
} else {
match action {
Action::Move(from, item_id) => {
if pane != &from || allow_same_pane {
let pane = pane.clone();
cx.window_context().defer(move |cx| {
if let Some(((workspace, from), to)) = workspace
.upgrade(cx)
.zip(from.upgrade(cx))
.zip(pane.upgrade(cx))
{
workspace.update(cx, |workspace, cx| {
workspace.move_item(from, to, item_id, index, cx);
})
}
});
} else {
cx.propagate_event();
}
}
Action::Open(project_entry) => {
let pane = pane.clone();
cx.window_context().defer(move |cx| {
if let Some(workspace) = workspace.upgrade(cx) {
workspace.update(cx, |workspace, cx| {
if let Some(path) =
workspace.project.read(cx).path_for_entry(project_entry, cx)
{
workspace
.open_path(path, Some(pane), true, cx)
.detach_and_log_err(cx);
}
});
}
});
}
}
}
}
fn drop_split_direction(
position: Vector2F,
region: RectF,
split_margin: f32,
) -> Option<SplitDirection> {
let mut min_direction = None;
let mut min_distance = split_margin;
for direction in SplitDirection::all() {
let edge_distance = (direction.edge(region) - direction.axis().component(position)).abs();
if edge_distance < min_distance {
min_direction = Some(direction);
min_distance = edge_distance;
}
}
min_direction
}
fn overlay_color(cx: &AppContext) -> Color {
theme2::current(cx).workspace.drop_target_overlay_color
}

View file

@ -4,7 +4,7 @@ use call::{ActiveCall, ParticipantLocation};
use collections::HashMap;
use gpui::{
point, size, AnyView, AnyWeakView, Axis, Bounds, IntoElement, Model, MouseButton, Pixels,
Point, View, ViewContext,
Point, StyleRefinement, View, ViewContext,
};
use parking_lot::Mutex;
use project::Project;
@ -239,7 +239,10 @@ impl Member {
.relative()
.flex_1()
.size_full()
.child(AnyView::from(pane.clone()).cached())
.child(
AnyView::from(pane.clone())
.cached(StyleRefinement::default().v_flex().size_full()),
)
.when_some(leader_border, |this, color| {
this.child(
div()
@ -260,7 +263,6 @@ impl Member {
.right_3()
.elevation_2(cx)
.p_1()
.z_index(1)
.child(status_box)
.when_some(
leader_join_data,
@ -588,13 +590,15 @@ impl SplitDirection {
mod element {
use std::mem;
use std::{cell::RefCell, iter, rc::Rc, sync::Arc};
use gpui::{
px, relative, Along, AnyElement, Axis, Bounds, CursorStyle, Element, IntoElement,
MouseDownEvent, MouseMoveEvent, MouseUpEvent, ParentElement, Pixels, Point, Size, Style,
WeakView, WindowContext,
px, relative, Along, AnyElement, Axis, Bounds, Element, IntoElement, MouseDownEvent,
MouseMoveEvent, MouseUpEvent, ParentElement, Pixels, Point, Size, Style, WeakView,
WindowContext,
};
use gpui::{CursorStyle, Hitbox};
use parking_lot::Mutex;
use settings::Settings;
use smallvec::SmallVec;
@ -637,6 +641,22 @@ mod element {
workspace: WeakView<Workspace>,
}
pub struct PaneAxisLayout {
dragged_handle: Rc<RefCell<Option<usize>>>,
children: Vec<PaneAxisChildLayout>,
}
struct PaneAxisChildLayout {
bounds: Bounds<Pixels>,
element: AnyElement,
handle: Option<PaneAxisHandleLayout>,
}
struct PaneAxisHandleLayout {
hitbox: Hitbox,
divider_bounds: Bounds<Pixels>,
}
impl PaneAxisElement {
pub fn with_active_pane(mut self, active_pane_ix: Option<usize>) -> Self {
self.active_pane_ix = active_pane_ix;
@ -733,16 +753,11 @@ mod element {
}
#[allow(clippy::too_many_arguments)]
fn push_handle(
flexes: Arc<Mutex<Vec<f32>>>,
dragged_handle: Rc<RefCell<Option<usize>>>,
fn layout_handle(
axis: Axis,
ix: usize,
pane_bounds: Bounds<Pixels>,
axis_bounds: Bounds<Pixels>,
workspace: WeakView<Workspace>,
cx: &mut ElementContext,
) {
) -> PaneAxisHandleLayout {
let handle_bounds = Bounds {
origin: pane_bounds.origin.apply_along(axis, |origin| {
origin + pane_bounds.size.along(axis) - px(HANDLE_HITBOX_SIZE / 2.)
@ -758,99 +773,53 @@ mod element {
size: pane_bounds.size.apply_along(axis, |_| px(DIVIDER_SIZE)),
};
cx.with_z_index(3, |cx| {
if handle_bounds.contains(&cx.mouse_position()) {
let stacking_order = cx.stacking_order().clone();
let cursor_style = match axis {
Axis::Vertical => CursorStyle::ResizeUpDown,
Axis::Horizontal => CursorStyle::ResizeLeftRight,
};
cx.set_cursor_style(cursor_style, stacking_order);
}
cx.add_opaque_layer(handle_bounds);
cx.paint_quad(gpui::fill(divider_bounds, cx.theme().colors().border));
cx.on_mouse_event({
let dragged_handle = dragged_handle.clone();
let flexes = flexes.clone();
let workspace = workspace.clone();
move |e: &MouseDownEvent, phase, cx| {
if phase.bubble() && handle_bounds.contains(&e.position) {
dragged_handle.replace(Some(ix));
if e.click_count >= 2 {
let mut borrow = flexes.lock();
*borrow = vec![1.; borrow.len()];
workspace
.update(cx, |this, cx| this.schedule_serialize(cx))
.log_err();
cx.refresh();
}
cx.stop_propagation();
}
}
});
cx.on_mouse_event({
let workspace = workspace.clone();
move |e: &MouseMoveEvent, phase, cx| {
let dragged_handle = dragged_handle.borrow();
if phase.bubble() && *dragged_handle == Some(ix) {
Self::compute_resize(
&flexes,
e,
ix,
axis,
pane_bounds.origin,
axis_bounds.size,
workspace.clone(),
cx,
)
}
}
});
});
PaneAxisHandleLayout {
hitbox: cx.insert_hitbox(handle_bounds, true),
divider_bounds,
}
}
}
impl IntoElement for PaneAxisElement {
type Element = Self;
fn element_id(&self) -> Option<ui::prelude::ElementId> {
Some(self.basis.into())
}
fn into_element(self) -> Self::Element {
self
}
}
impl Element for PaneAxisElement {
type State = Rc<RefCell<Option<usize>>>;
type BeforeLayout = ();
type AfterLayout = PaneAxisLayout;
fn request_layout(
fn before_layout(
&mut self,
state: Option<Self::State>,
cx: &mut ui::prelude::ElementContext,
) -> (gpui::LayoutId, Self::State) {
) -> (gpui::LayoutId, Self::BeforeLayout) {
let mut style = Style::default();
style.flex_grow = 1.;
style.flex_shrink = 1.;
style.flex_basis = relative(0.).into();
style.size.width = relative(1.).into();
style.size.height = relative(1.).into();
let layout_id = cx.request_layout(&style, None);
let dragged_pane = state.unwrap_or_else(|| Rc::new(RefCell::new(None)));
(layout_id, dragged_pane)
(cx.request_layout(&style, None), ())
}
fn paint(
fn after_layout(
&mut self,
bounds: gpui::Bounds<ui::prelude::Pixels>,
state: &mut Self::State,
cx: &mut ui::prelude::ElementContext,
) {
bounds: Bounds<Pixels>,
_state: &mut Self::BeforeLayout,
cx: &mut ElementContext,
) -> PaneAxisLayout {
let dragged_handle = cx.with_element_state::<Rc<RefCell<Option<usize>>>, _>(
Some(self.basis.into()),
|state, _cx| {
let state = state
.unwrap()
.unwrap_or_else(|| Rc::new(RefCell::new(None)));
(state.clone(), Some(state))
},
);
let flexes = self.flexes.lock().clone();
let len = self.children.len();
debug_assert!(flexes.len() == len);
@ -875,7 +844,11 @@ mod element {
let mut bounding_boxes = self.bounding_boxes.lock();
bounding_boxes.clear();
for (ix, child) in self.children.iter_mut().enumerate() {
let mut layout = PaneAxisLayout {
dragged_handle: dragged_handle.clone(),
children: Vec::new(),
};
for (ix, mut child) in mem::take(&mut self.children).into_iter().enumerate() {
let child_flex = active_pane_magnification
.map(|magnification| {
if self.active_pane_ix == Some(ix) {
@ -896,40 +869,105 @@ mod element {
size: child_size,
};
bounding_boxes.push(Some(child_bounds));
cx.with_z_index(0, |cx| {
child.draw(origin, child_size.into(), cx);
});
child.layout(origin, child_size.into(), cx);
origin = origin.apply_along(self.axis, |val| val + child_size.along(self.axis));
layout.children.push(PaneAxisChildLayout {
bounds: child_bounds,
element: child,
handle: None,
})
}
for (ix, child_layout) in layout.children.iter_mut().enumerate() {
if active_pane_magnification.is_none() {
cx.with_z_index(1, |cx| {
if ix < len - 1 {
Self::push_handle(
self.flexes.clone(),
state.clone(),
self.axis,
ix,
child_bounds,
bounds,
self.workspace.clone(),
cx,
);
if ix < len - 1 {
child_layout.handle =
Some(Self::layout_handle(self.axis, child_layout.bounds, cx));
}
}
}
layout
}
fn paint(
&mut self,
bounds: gpui::Bounds<ui::prelude::Pixels>,
_: &mut Self::BeforeLayout,
layout: &mut Self::AfterLayout,
cx: &mut ui::prelude::ElementContext,
) {
for child in &mut layout.children {
child.element.paint(cx);
}
for (ix, child) in &mut layout.children.iter_mut().enumerate() {
if let Some(handle) = child.handle.as_mut() {
let cursor_style = match self.axis {
Axis::Vertical => CursorStyle::ResizeUpDown,
Axis::Horizontal => CursorStyle::ResizeLeftRight,
};
cx.set_cursor_style(cursor_style, &handle.hitbox);
cx.paint_quad(gpui::fill(
handle.divider_bounds,
cx.theme().colors().border,
));
cx.on_mouse_event({
let dragged_handle = layout.dragged_handle.clone();
let flexes = self.flexes.clone();
let workspace = self.workspace.clone();
let handle_hitbox = handle.hitbox.clone();
move |e: &MouseDownEvent, phase, cx| {
if phase.bubble() && handle_hitbox.is_hovered(cx) {
dragged_handle.replace(Some(ix));
if e.click_count >= 2 {
let mut borrow = flexes.lock();
*borrow = vec![1.; borrow.len()];
workspace
.update(cx, |this, cx| this.schedule_serialize(cx))
.log_err();
cx.refresh();
}
cx.stop_propagation();
}
}
});
cx.on_mouse_event({
let workspace = self.workspace.clone();
let dragged_handle = layout.dragged_handle.clone();
let flexes = self.flexes.clone();
let child_bounds = child.bounds;
let axis = self.axis;
move |e: &MouseMoveEvent, phase, cx| {
let dragged_handle = dragged_handle.borrow();
if phase.bubble() && *dragged_handle == Some(ix) {
Self::compute_resize(
&flexes,
e,
ix,
axis,
child_bounds.origin,
bounds.size,
workspace.clone(),
cx,
)
}
}
});
}
origin = origin.apply_along(self.axis, |val| val + child_size.along(self.axis));
}
cx.with_z_index(1, |cx| {
cx.on_mouse_event({
let state = state.clone();
move |_: &MouseUpEvent, phase, _cx| {
if phase.bubble() {
state.replace(None);
}
cx.on_mouse_event({
let dragged_handle = layout.dragged_handle.clone();
move |_: &MouseUpEvent, phase, _cx| {
if phase.bubble() {
dragged_handle.replace(None);
}
});
})
}
});
}
}

View file

@ -2756,7 +2756,6 @@ impl Workspace {
Some(
div()
.absolute()
.z_index(100)
.right_3()
.bottom_3()
.w_112()
@ -3832,18 +3831,15 @@ impl Render for Workspace {
.border_t()
.border_b()
.border_color(colors.border)
.child(
canvas({
let this = cx.view().clone();
move |bounds, cx| {
this.update(cx, |this, _cx| {
this.bounds = *bounds;
})
}
})
.child({
let this = cx.view().clone();
canvas(
move |bounds, cx| this.update(cx, |this, _cx| this.bounds = bounds),
|_, _, _| {},
)
.absolute()
.size_full(),
)
.size_full()
})
.on_drag_move(
cx.listener(|workspace, e: &DragMoveEvent<DraggedDock>, cx| {
match e.drag(cx).0 {
@ -3868,7 +3864,6 @@ impl Render for Workspace {
}
}),
)
.child(self.modal_layer.clone())
.child(
div()
.flex()
@ -3917,11 +3912,11 @@ impl Render for Workspace {
},
)),
)
.children(self.render_notifications(cx))
.child(self.modal_layer.clone())
.children(self.zoomed.as_ref().and_then(|view| {
let zoomed_view = view.upgrade()?;
let div = div()
.z_index(1)
.occlude()
.absolute()
.overflow_hidden()
.border_color(colors.border)
@ -3936,7 +3931,8 @@ impl Render for Workspace {
Some(DockPosition::Bottom) => div.top_2().border_t(),
None => div.top_2().bottom_2().left_2().right_2().border(),
})
})),
}))
.children(self.render_notifications(cx)),
)
.child(self.status_bar.clone())
.children(if self.project.read(cx).is_disconnected() {
@ -4662,13 +4658,10 @@ pub fn titlebar_height(cx: &mut WindowContext) -> Pixels {
struct DisconnectedOverlay;
impl Element for DisconnectedOverlay {
type State = AnyElement;
type BeforeLayout = AnyElement;
type AfterLayout = ();
fn request_layout(
&mut self,
_: Option<Self::State>,
cx: &mut ElementContext,
) -> (LayoutId, Self::State) {
fn before_layout(&mut self, cx: &mut ElementContext) -> (LayoutId, Self::BeforeLayout) {
let mut background = cx.theme().colors().elevated_surface_background;
background.fade_out(0.2);
let mut overlay = div()
@ -4686,29 +4679,33 @@ impl Element for DisconnectedOverlay {
"Your connection to the remote project has been lost.",
))
.into_any();
(overlay.request_layout(cx), overlay)
(overlay.before_layout(cx), overlay)
}
fn after_layout(
&mut self,
bounds: Bounds<Pixels>,
overlay: &mut Self::BeforeLayout,
cx: &mut ElementContext,
) {
cx.insert_hitbox(bounds, true);
overlay.after_layout(cx);
}
fn paint(
&mut self,
bounds: Bounds<Pixels>,
overlay: &mut Self::State,
_: Bounds<Pixels>,
overlay: &mut Self::BeforeLayout,
_: &mut Self::AfterLayout,
cx: &mut ElementContext,
) {
cx.with_z_index(u16::MAX, |cx| {
cx.add_opaque_layer(bounds);
overlay.paint(cx);
})
overlay.paint(cx)
}
}
impl IntoElement for DisconnectedOverlay {
type Element = Self;
fn element_id(&self) -> Option<ui::prelude::ElementId> {
None
}
fn into_element(self) -> Self::Element {
self
}