Refine naming of element-related types and traits

Co-Authored-By: Max Brunsfeld <max@zed.dev>
This commit is contained in:
Nathan Sobo 2023-04-21 13:04:03 -06:00
parent 03619dfa55
commit fe492eacbf
93 changed files with 661 additions and 656 deletions

View file

@ -3,7 +3,7 @@ use gpui::{
elements::*,
impl_internal_actions,
platform::{CursorStyle, MouseButton},
AppContext, Drawable, Element, Entity, View, ViewContext, ViewHandle, WeakModelHandle,
AnyElement, AppContext, Element, Entity, View, ViewContext, ViewHandle, WeakModelHandle,
WeakViewHandle,
};
use settings::Settings;
@ -42,11 +42,11 @@ impl View for TerminalButton {
"TerminalButton"
}
fn render(&mut self, cx: &mut ViewContext<Self>) -> Element<Self> {
fn render(&mut self, cx: &mut ViewContext<Self>) -> AnyElement<Self> {
let workspace = self.workspace.upgrade(cx);
let project = match workspace {
Some(workspace) => workspace.read(cx).project().read(cx),
None => return Empty::new().into_element(),
None => return Empty::new().into_any(),
};
let focused_view = cx.focused_view_id();
@ -79,7 +79,7 @@ impl View for TerminalButton {
.constrained()
.with_width(style.icon_size)
.aligned()
.into_named_element("terminals-icon"),
.into_any_named("terminals-icon"),
)
.with_children(has_terminals.then(|| {
Label::new(terminal_count.to_string(), style.label.text.clone())
@ -112,7 +112,7 @@ impl View for TerminalButton {
),
)
.with_child(ChildView::new(&self.popup_menu, cx).aligned().top().right())
.into_named_element("terminal button")
.into_any_named("terminal button")
}
}

View file

@ -10,7 +10,7 @@ use gpui::{
platform::{CursorStyle, MouseButton},
serde_json::json,
text_layout::{Line, RunStyle},
Drawable, Element, EventContext, FontCache, ModelContext, MouseRegion, Quad, SceneBuilder,
AnyElement, Element, EventContext, FontCache, ModelContext, MouseRegion, Quad, SceneBuilder,
SizeConstraint, TextLayoutCache, ViewContext, WeakModelHandle,
};
use itertools::Itertools;
@ -45,7 +45,7 @@ pub struct LayoutState {
size: TerminalSize,
mode: TermMode,
display_offset: usize,
hyperlink_tooltip: Option<Element<TerminalView>>,
hyperlink_tooltip: Option<AnyElement<TerminalView>>,
}
///Helper struct for converting data between alacritty's cursor points, and displayed cursor points
@ -551,7 +551,7 @@ impl TerminalElement {
}
}
impl Drawable<TerminalView> for TerminalElement {
impl Element<TerminalView> for TerminalElement {
type LayoutState = LayoutState;
type PaintState = ();
@ -603,7 +603,7 @@ impl Drawable<TerminalView> for TerminalElement {
.with_tooltip::<TerminalElement>(id, uri, None, tooltip_style, cx),
)
.with_position_mode(gpui::elements::OverlayPositionMode::Local)
.into_element();
.into_any();
tooltip.layout(
SizeConstraint::new(Vector2F::zero(), cx.window_size()),

View file

@ -18,7 +18,7 @@ use gpui::{
impl_actions, impl_internal_actions,
keymap_matcher::{KeymapContext, Keystroke},
platform::KeyDownEvent,
AnyViewHandle, AppContext, Drawable, Element, Entity, ModelHandle, Task, View, ViewContext,
AnyElement, AnyViewHandle, AppContext, Element, Entity, ModelHandle, Task, View, ViewContext,
ViewHandle, WeakViewHandle,
};
use project::{LocalWorktree, Project};
@ -387,7 +387,7 @@ impl View for TerminalView {
"Terminal"
}
fn render(&mut self, cx: &mut gpui::ViewContext<Self>) -> Element<Self> {
fn render(&mut self, cx: &mut gpui::ViewContext<Self>) -> AnyElement<Self> {
let terminal_handle = self.terminal.clone().downgrade();
let self_id = cx.view_id();
@ -406,7 +406,7 @@ impl View for TerminalView {
.contained(),
)
.with_child(ChildView::new(&self.context_menu, cx))
.into_element()
.into_any()
}
fn focus_in(&mut self, _: AnyViewHandle, cx: &mut ViewContext<Self>) {
@ -549,7 +549,7 @@ impl Item for TerminalView {
_detail: Option<usize>,
tab_theme: &theme::Tab,
cx: &gpui::AppContext,
) -> Element<T> {
) -> AnyElement<T> {
let title = self.terminal().read(cx).title();
Flex::row()
@ -563,7 +563,7 @@ impl Item for TerminalView {
.with_margin_right(tab_theme.spacing),
)
.with_child(Label::new(title, tab_theme.label.clone()).aligned())
.into_element()
.into_any()
}
fn clone_on_split(