Reorganize element-related traits
This commit is contained in:
parent
ca1d9dd0e5
commit
c23f17ee0b
42 changed files with 190 additions and 265 deletions
|
@ -5,8 +5,8 @@ use crate::{prelude::*, v_stack, List};
|
|||
use crate::{ListItem, ListSeparator, ListSubHeader};
|
||||
use gpui::{
|
||||
overlay, px, Action, AnchorCorner, AnyElement, AppContext, Bounds, ClickEvent, DispatchPhase,
|
||||
Div, EventEmitter, FocusHandle, FocusableView, LayoutId, ManagedView, Manager, MouseButton,
|
||||
MouseDownEvent, Pixels, Point, Render, RenderOnce, View, VisualContext,
|
||||
Div, EventEmitter, FocusHandle, FocusableView, IntoElement, LayoutId, ManagedView, Manager,
|
||||
MouseButton, MouseDownEvent, Pixels, Point, Render, View, VisualContext,
|
||||
};
|
||||
|
||||
pub enum ContextMenuItem {
|
||||
|
@ -105,9 +105,9 @@ impl Render for ContextMenu {
|
|||
.child(
|
||||
List::new().children(self.items.iter().map(|item| match item {
|
||||
ContextMenuItem::Separator(separator) => {
|
||||
separator.clone().render_into_any()
|
||||
separator.clone().into_any_element()
|
||||
}
|
||||
ContextMenuItem::Header(header) => header.clone().render_into_any(),
|
||||
ContextMenuItem::Header(header) => header.clone().into_any_element(),
|
||||
ContextMenuItem::Entry(entry, callback) => {
|
||||
let callback = callback.clone();
|
||||
let dismiss = cx.listener(|_, _, cx| cx.emit(Manager::Dismiss));
|
||||
|
@ -118,7 +118,7 @@ impl Render for ContextMenu {
|
|||
callback(event, cx);
|
||||
dismiss(event, cx)
|
||||
})
|
||||
.render_into_any()
|
||||
.into_any_element()
|
||||
}
|
||||
})),
|
||||
),
|
||||
|
@ -140,8 +140,8 @@ impl<M: ManagedView> MenuHandle<M> {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn child<R: RenderOnce>(mut self, f: impl FnOnce(bool) -> R + 'static) -> Self {
|
||||
self.child_builder = Some(Box::new(|b| f(b).render_once().into_any()));
|
||||
pub fn child<R: IntoElement>(mut self, f: impl FnOnce(bool) -> R + 'static) -> Self {
|
||||
self.child_builder = Some(Box::new(|b| f(b).into_element().into_any()));
|
||||
self
|
||||
}
|
||||
|
||||
|
@ -286,14 +286,14 @@ impl<M: ManagedView> Element for MenuHandle<M> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<M: ManagedView> RenderOnce for MenuHandle<M> {
|
||||
impl<M: ManagedView> IntoElement for MenuHandle<M> {
|
||||
type Element = Self;
|
||||
|
||||
fn element_id(&self) -> Option<gpui::ElementId> {
|
||||
Some(self.id.clone())
|
||||
}
|
||||
|
||||
fn render_once(self) -> Self::Element {
|
||||
fn into_element(self) -> Self::Element {
|
||||
self
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue