This commit is contained in:
Nathan Sobo 2023-04-12 12:10:43 -06:00
parent 40896352ff
commit a25f962185
90 changed files with 587 additions and 501 deletions

View file

@ -9,7 +9,7 @@ use gpui::{
geometry::vector::Vector2F,
impl_internal_actions,
platform::{CursorStyle, MouseButton},
AppContext, Border, Element, ElementBox, SizeConstraint, ViewContext, ViewHandle,
AppContext, Border, Drawable, Element, SizeConstraint, ViewContext, ViewHandle,
};
use settings::{DockAnchor, Settings};
use theme::Theme;
@ -315,7 +315,7 @@ impl Dock {
theme: &Theme,
anchor: DockAnchor,
cx: &mut ViewContext<Workspace>,
) -> Option<ElementBox<Workspace>> {
) -> Option<Element<Workspace>> {
let style = &theme.workspace.dock;
self.position

View file

@ -2,7 +2,7 @@ use gpui::{
elements::{Empty, MouseEventHandler, Svg},
platform::CursorStyle,
platform::MouseButton,
Element, ElementBox, Entity, View, ViewContext, ViewHandle, WeakViewHandle,
Drawable, Element, Entity, View, ViewContext, ViewHandle, WeakViewHandle,
};
use settings::Settings;
@ -34,7 +34,7 @@ impl View for ToggleDockButton {
"Dock Toggle"
}
fn render(&mut self, cx: &mut gpui::ViewContext<Self>) -> ElementBox<Self> {
fn render(&mut self, cx: &mut gpui::ViewContext<Self>) -> Element<Self> {
let workspace = self.workspace.upgrade(cx);
if workspace.is_none() {

View file

@ -15,8 +15,8 @@ use std::{
use anyhow::Result;
use client::{proto, Client};
use gpui::{
AnyViewHandle, AppContext, ElementBox, ModelHandle, Task, View, ViewContext, ViewHandle,
WeakViewHandle,
AnyViewHandle, AppContext, Element, ModelHandle, RenderedView, Task, View, ViewContext,
ViewHandle, WeakViewHandle,
};
use project::{Project, ProjectEntryId, ProjectPath};
use settings::{Autosave, Settings};
@ -52,7 +52,7 @@ pub trait Item: View {
detail: Option<usize>,
style: &theme::Tab,
cx: &AppContext,
) -> ElementBox<Pane>;
) -> Element<Pane>;
fn for_each_project_item(&self, _: &AppContext, _: &mut dyn FnMut(usize, &dyn project::Item)) {}
fn is_singleton(&self, _cx: &AppContext) -> bool {
false
@ -134,7 +134,7 @@ pub trait Item: View {
ToolbarItemLocation::Hidden
}
fn breadcrumbs(&self, _theme: &Theme, _cx: &AppContext) -> Option<Vec<ElementBox<Pane>>> {
fn breadcrumbs(&self, _theme: &Theme, _cx: &AppContext) -> Option<Vec<Box<dyn RenderedView>>> {
None
}
@ -172,7 +172,7 @@ pub trait ItemHandle: 'static + fmt::Debug {
detail: Option<usize>,
style: &theme::Tab,
cx: &AppContext,
) -> ElementBox<Pane>;
) -> Element<Pane>;
fn project_path(&self, cx: &AppContext) -> Option<ProjectPath>;
fn project_entry_ids(&self, cx: &AppContext) -> SmallVec<[ProjectEntryId; 3]>;
fn project_item_model_ids(&self, cx: &AppContext) -> SmallVec<[usize; 3]>;
@ -221,7 +221,7 @@ pub trait ItemHandle: 'static + fmt::Debug {
) -> gpui::Subscription;
fn to_searchable_item_handle(&self, cx: &AppContext) -> Option<Box<dyn SearchableItemHandle>>;
fn breadcrumb_location(&self, cx: &AppContext) -> ToolbarItemLocation;
fn breadcrumbs(&self, theme: &Theme, cx: &AppContext) -> Option<Vec<ElementBox<Pane>>>;
fn breadcrumbs(&self, theme: &Theme, cx: &AppContext) -> Option<Vec<Box<dyn RenderedView>>>;
fn serialized_item_kind(&self) -> Option<&'static str>;
fn show_toolbar(&self, cx: &AppContext) -> bool;
}
@ -265,7 +265,7 @@ impl<T: Item> ItemHandle for ViewHandle<T> {
detail: Option<usize>,
style: &theme::Tab,
cx: &AppContext,
) -> ElementBox<Pane> {
) -> Element<Pane> {
self.read(cx).tab_content(detail, style, cx)
}
@ -591,7 +591,7 @@ impl<T: Item> ItemHandle for ViewHandle<T> {
self.read(cx).breadcrumb_location()
}
fn breadcrumbs(&self, theme: &Theme, cx: &AppContext) -> Option<Vec<ElementBox<Pane>>> {
fn breadcrumbs(&self, theme: &Theme, cx: &AppContext) -> Option<Vec<Box<dyn RenderedView>>> {
self.read(cx).breadcrumbs(theme, cx)
}
@ -748,7 +748,7 @@ pub(crate) mod test {
use super::{Item, ItemEvent};
use crate::{sidebar::SidebarItem, ItemId, ItemNavHistory, Pane, Workspace, WorkspaceId};
use gpui::{
elements::Empty, AppContext, Element, ElementBox, Entity, ModelHandle, Task, View,
elements::Empty, AppContext, Drawable, Element, Entity, ModelHandle, Task, View,
ViewContext, ViewHandle, WeakViewHandle,
};
use project::{Project, ProjectEntryId, ProjectPath, WorktreeId};
@ -907,7 +907,7 @@ pub(crate) mod test {
"TestItem"
}
fn render(&mut self, _: &mut ViewContext<Self>) -> ElementBox<Self> {
fn render(&mut self, _: &mut ViewContext<Self>) -> Element<Self> {
Empty::new().boxed()
}
}
@ -925,7 +925,7 @@ pub(crate) mod test {
detail: Option<usize>,
_: &theme::Tab,
_: &AppContext,
) -> ElementBox<Pane> {
) -> Element<Pane> {
self.tab_detail.set(detail);
Empty::new().boxed()
}

View file

@ -140,7 +140,7 @@ pub mod simple_message_notification {
elements::{Flex, MouseEventHandler, Padding, ParentElement, Svg, Text},
impl_actions,
platform::{CursorStyle, MouseButton},
Action, AppContext, Element, Entity, View, ViewContext,
Action, AppContext, Drawable, Entity, View, ViewContext,
};
use menu::Cancel;
use serde::Deserialize;
@ -229,7 +229,7 @@ pub mod simple_message_notification {
"MessageNotification"
}
fn render(&mut self, cx: &mut gpui::ViewContext<Self>) -> gpui::ElementBox<Self> {
fn render(&mut self, cx: &mut gpui::ViewContext<Self>) -> gpui::Element<Self> {
let theme = cx.global::<Settings>().theme.clone();
let theme = &theme.simple_message_notification;

View file

@ -1220,7 +1220,7 @@ impl Pane {
});
}
fn render_tabs(&mut self, cx: &mut ViewContext<Self>) -> impl Element<Self> {
fn render_tabs(&mut self, cx: &mut ViewContext<Self>) -> impl Drawable<Self> {
let theme = cx.global::<Settings>().theme.clone();
let pane = cx.handle().downgrade();
@ -1384,7 +1384,7 @@ impl Pane {
hovered: bool,
tab_style: &theme::Tab,
cx: &mut ViewContext<Self>,
) -> ElementBox<Self> {
) -> Element<Self> {
let title = item.tab_content(detail, &tab_style, cx);
let mut container = tab_style.container.clone();
if first {
@ -1483,7 +1483,7 @@ impl Pane {
&mut self,
theme: &Theme,
cx: &mut ViewContext<Self>,
) -> ElementBox<Self> {
) -> Element<Self> {
Flex::row()
// New menu
.with_child(render_tab_bar_button(
@ -1536,7 +1536,7 @@ impl Pane {
&mut self,
theme: &Theme,
_cx: &mut ViewContext<Self>,
) -> ElementBox<Self> {
) -> Element<Self> {
let background = theme.workspace.background;
Empty::new()
.contained()
@ -1554,7 +1554,7 @@ impl View for Pane {
"Pane"
}
fn render(&mut self, cx: &mut ViewContext<Self>) -> ElementBox<Self> {
fn render(&mut self, cx: &mut ViewContext<Self>) -> Element<Self> {
let this = cx.handle().downgrade();
enum MouseNavigationHandler {}
@ -1719,7 +1719,7 @@ fn render_tab_bar_button<A: Action + Clone>(
cx: &mut ViewContext<Pane>,
action: A,
context_menu: Option<ViewHandle<ContextMenu>>,
) -> ElementBox<Pane> {
) -> Element<Pane> {
enum TabBarButton {}
Stack::new()
@ -1853,11 +1853,11 @@ impl NavHistory {
pub struct PaneBackdrop<V: View> {
child_view: usize,
child: ElementBox<V>,
child: Element<V>,
}
impl<V: View> PaneBackdrop<V> {
pub fn new(pane_item_view: usize, child: ElementBox<V>) -> Self {
pub fn new(pane_item_view: usize, child: Element<V>) -> Self {
PaneBackdrop {
child,
child_view: pane_item_view,
@ -1865,7 +1865,7 @@ impl<V: View> PaneBackdrop<V> {
}
}
impl<V: View> Element<V> for PaneBackdrop<V> {
impl<V: View> Drawable<V> for PaneBackdrop<V> {
type LayoutState = ();
type PaintState = ();

View file

@ -5,7 +5,7 @@ use gpui::{
geometry::{rect::RectF, vector::Vector2F},
platform::MouseButton,
scene::MouseUp,
AppContext, Element, ElementBox, EventContext, MouseState, Quad, View, ViewContext,
AppContext, Drawable, Element, EventContext, MouseState, Quad, View, ViewContext,
WeakViewHandle,
};
use project::ProjectEntryId;
@ -28,7 +28,7 @@ pub fn dragged_item_receiver<Tag, F>(
) -> MouseEventHandler<Tag, Pane>
where
Tag: 'static,
F: FnOnce(&mut MouseState, &mut ViewContext<Pane>) -> ElementBox<Pane>,
F: FnOnce(&mut MouseState, &mut ViewContext<Pane>) -> Element<Pane>,
{
MouseEventHandler::<Tag, _>::above(region_id, cx, |state, cx| {
// Observing hovered will cause a render when the mouse enters regardless

View file

@ -71,7 +71,7 @@ impl PaneGroup {
active_call: Option<&ModelHandle<ActiveCall>>,
active_pane: &ViewHandle<Pane>,
cx: &mut ViewContext<Workspace>,
) -> ElementBox<Workspace> {
) -> Element<Workspace> {
self.root.render(
project,
theme,
@ -132,7 +132,7 @@ impl Member {
active_call: Option<&ModelHandle<ActiveCall>>,
active_pane: &ViewHandle<Pane>,
cx: &mut ViewContext<Workspace>,
) -> ElementBox<Workspace> {
) -> Element<Workspace> {
enum FollowIntoExternalProject {}
match self {
@ -367,7 +367,7 @@ impl PaneAxis {
active_call: Option<&ModelHandle<ActiveCall>>,
active_pane: &ViewHandle<Pane>,
cx: &mut ViewContext<Workspace>,
) -> ElementBox<Workspace> {
) -> Element<Workspace> {
let last_member_ix = self.members.len() - 1;
Flex::new(self.axis)
.with_children(self.members.iter().enumerate().map(|(ix, member)| {

View file

@ -64,7 +64,7 @@ impl View for SharedScreen {
"SharedScreen"
}
fn render(&mut self, cx: &mut ViewContext<Self>) -> ElementBox<Self> {
fn render(&mut self, cx: &mut ViewContext<Self>) -> Element<Self> {
enum Focus {}
let frame = self.frame.clone();
@ -103,7 +103,7 @@ impl Item for SharedScreen {
_: Option<usize>,
style: &theme::Tab,
_: &AppContext,
) -> gpui::ElementBox<Pane> {
) -> gpui::Element<Pane> {
Flex::row()
.with_child(
Svg::new("icons/disable_screen_sharing_12.svg")

View file

@ -188,7 +188,7 @@ impl View for Sidebar {
"Sidebar"
}
fn render(&mut self, cx: &mut ViewContext<Self>) -> ElementBox<Self> {
fn render(&mut self, cx: &mut ViewContext<Self>) -> Element<Self> {
if let Some(active_item) = self.active_item() {
enum ResizeHandleTag {}
let style = &cx.global::<Settings>().theme.workspace.sidebar;
@ -225,7 +225,7 @@ impl View for SidebarButtons {
"SidebarToggleButton"
}
fn render(&mut self, cx: &mut ViewContext<Self>) -> ElementBox<Self> {
fn render(&mut self, cx: &mut ViewContext<Self>) -> Element<Self> {
let theme = &cx.global::<Settings>().theme;
let tooltip_style = theme.tooltip.clone();
let theme = &theme.workspace.status_bar.sidebar_buttons;

View file

@ -8,7 +8,7 @@ use gpui::{
vector::{vec2f, Vector2F},
},
json::{json, ToJson},
AnyViewHandle, AppContext, ElementBox, Entity, SceneBuilder, SizeConstraint, Subscription,
AnyViewHandle, AppContext, Element, Entity, SceneBuilder, SizeConstraint, Subscription,
View, ViewContext, ViewHandle,
};
use settings::Settings;
@ -42,7 +42,7 @@ impl View for StatusBar {
"StatusBar"
}
fn render(&mut self, cx: &mut ViewContext<Self>) -> ElementBox<Self> {
fn render(&mut self, cx: &mut ViewContext<Self>) -> Element<Self> {
let theme = &cx.global::<Settings>().theme.workspace.status_bar;
StatusBarElement {
@ -139,11 +139,11 @@ impl From<&dyn StatusItemViewHandle> for AnyViewHandle {
}
struct StatusBarElement {
left: ElementBox<StatusBar>,
right: ElementBox<StatusBar>,
left: Element<StatusBar>,
right: Element<StatusBar>,
}
impl Element<StatusBar> for StatusBarElement {
impl Drawable<StatusBar> for StatusBarElement {
type LayoutState = ();
type PaintState = ();

View file

@ -1,7 +1,7 @@
use crate::{ItemHandle, Pane};
use gpui::{
elements::*, platform::CursorStyle, platform::MouseButton, Action, AnyViewHandle, AppContext,
ElementBox, Entity, View, ViewContext, ViewHandle, WeakViewHandle,
Element, Entity, View, ViewContext, ViewHandle, WeakViewHandle,
};
use settings::Settings;
@ -59,7 +59,7 @@ impl View for Toolbar {
"Toolbar"
}
fn render(&mut self, cx: &mut ViewContext<Self>) -> ElementBox<Self> {
fn render(&mut self, cx: &mut ViewContext<Self>) -> Element<Self> {
let theme = &cx.global::<Settings>().theme.workspace.toolbar;
let mut primary_left_items = Vec::new();
@ -169,7 +169,7 @@ fn nav_button<A: Action + Clone>(
tooltip_action: A,
action_name: &str,
cx: &mut ViewContext<Toolbar>,
) -> ElementBox<Toolbar> {
) -> Element<Toolbar> {
MouseEventHandler::<A, _>::new(0, cx, |state, _| {
let style = if enabled {
style.style_for(state, false)

View file

@ -2054,7 +2054,7 @@ impl Workspace {
self.leader_state.followers.contains(&peer_id)
}
fn render_titlebar(&self, theme: &Theme, cx: &mut ViewContext<Self>) -> ElementBox<Self> {
fn render_titlebar(&self, theme: &Theme, cx: &mut ViewContext<Self>) -> Element<Self> {
// TODO: There should be a better system in place for this
// (https://github.com/zed-industries/zed/issues/1290)
let is_fullscreen = cx.window_is_fullscreen();
@ -2157,7 +2157,7 @@ impl Workspace {
fn render_disconnected_overlay(
&self,
cx: &mut ViewContext<Workspace>,
) -> Option<ElementBox<Workspace>> {
) -> Option<Element<Workspace>> {
if self.project.read(cx).is_read_only() {
enum DisconnectedOverlay {}
Some(
@ -2185,7 +2185,7 @@ impl Workspace {
&self,
theme: &theme::Workspace,
cx: &AppContext,
) -> Option<ElementBox<Workspace>> {
) -> Option<Element<Workspace>> {
if self.notifications.is_empty() {
None
} else {
@ -2813,7 +2813,7 @@ impl View for Workspace {
"Workspace"
}
fn render(&mut self, cx: &mut ViewContext<Self>) -> ElementBox<Self> {
fn render(&mut self, cx: &mut ViewContext<Self>) -> Element<Self> {
let theme = cx.global::<Settings>().theme.clone();
Stack::new()
.with_child(