This commit is contained in:
Nathan Sobo 2023-11-18 20:22:43 -07:00
parent adc355a1e6
commit 0673606de8
11 changed files with 39 additions and 35 deletions

View file

@ -9376,7 +9376,7 @@ impl FocusableView for Editor {
}
}
impl Render for Editor {
impl Render<Self> for Editor {
type Element = EditorElement;
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {

View file

@ -21,7 +21,7 @@ use gpui::{
div, point, px, relative, size, transparent_black, Action, AnyElement, AvailableSpace,
BorrowWindow, Bounds, Component, ContentMask, Corners, DispatchPhase, Edges, Element,
ElementId, ElementInputHandler, Entity, EntityId, Hsla, InteractiveElement, LineLayout,
MouseButton, MouseDownEvent, MouseMoveEvent, MouseUpEvent, ParentElement, Pixels,
MouseButton, MouseDownEvent, MouseMoveEvent, MouseUpEvent, ParentElement, Pixels, RenderOnce,
ScrollWheelEvent, ShapedLine, SharedString, Size, StatefulInteractiveElement, Style, Styled,
TextRun, TextStyle, View, ViewContext, WindowContext, WrappedLine,
};
@ -2466,9 +2466,11 @@ impl Element<Editor> for EditorElement {
}
}
impl Component<Editor> for EditorElement {
fn render(self) -> AnyElement<Editor> {
AnyElement::new(self)
impl RenderOnce<Editor> for EditorElement {
type Element = Self;
fn render_once(self) -> Self::Element {
self
}
}

View file

@ -59,7 +59,7 @@ struct TestView {
story: AnyView,
}
impl Render for TestView {
impl Render<Self> for TestView {
type Element = Div<Self>;
fn render(&mut self, _cx: &mut ViewContext<Self>) -> Self::Element {

View file

@ -1,8 +1,8 @@
use crate::{status_bar::StatusItemView, Axis, Workspace};
use gpui::{
div, px, Action, AnchorCorner, AnyView, AppContext, Component, Div, Entity, EntityId,
EventEmitter, FocusHandle, FocusableView, ParentElement, Render, SharedString, Styled,
Subscription, View, ViewContext, VisualContext, WeakView, WindowContext,
EventEmitter, FocusHandle, FocusableView, ParentElement, Render, RenderOnce, SharedString,
Styled, Subscription, View, ViewContext, VisualContext, WeakView, WindowContext,
};
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
@ -426,7 +426,7 @@ impl Dock {
}
}
impl Render for Dock {
impl Render<Self> for Dock {
type Element = Div<Self>;
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
@ -612,7 +612,7 @@ impl PanelButtons {
// }
// here be kittens
impl Render for PanelButtons {
impl Render<Self> for PanelButtons {
type Element = Div<Self>;
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
@ -706,7 +706,7 @@ pub mod test {
}
}
impl Render for TestPanel {
impl Render<Self> for TestPanel {
type Element = Div<Self>;
fn render(&mut self, _cx: &mut ViewContext<Self>) -> Self::Element {

View file

@ -71,7 +71,7 @@ impl ModalLayer {
}
}
impl Render for ModalLayer {
impl Render<Self> for ModalLayer {
type Element = Div<Self>;
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {

View file

@ -13,7 +13,7 @@ pub enum NotificationEvent {
Dismiss,
}
pub trait Notification: EventEmitter<NotificationEvent> + Render {}
pub trait Notification: EventEmitter<NotificationEvent> + Render<Self> {}
pub trait NotificationHandle: Send {
fn id(&self) -> EntityId;
@ -251,7 +251,7 @@ pub mod simple_message_notification {
// }
}
impl Render for MessageNotification {
impl Render<Self> for MessageNotification {
type Element = Div<Self>;
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {

View file

@ -593,7 +593,7 @@ impl Pane {
self.items.iter()
}
pub fn items_of_type<T: Render>(&self) -> impl '_ + Iterator<Item = View<T>> {
pub fn items_of_type<T: Render<T>>(&self) -> impl '_ + Iterator<Item = View<T>> {
self.items
.iter()
.filter_map(|item| item.to_any().downcast().ok())
@ -1343,7 +1343,7 @@ impl Pane {
item: &Box<dyn ItemHandle>,
detail: usize,
cx: &mut ViewContext<'_, Pane>,
) -> impl Component<Self> {
) -> impl RenderOnce<Self> {
let label = item.tab_content(Some(detail), cx);
let close_icon = || {
let id = item.item_id();
@ -1436,7 +1436,7 @@ impl Pane {
)
}
fn render_tab_bar(&mut self, cx: &mut ViewContext<'_, Pane>) -> impl Component<Self> {
fn render_tab_bar(&mut self, cx: &mut ViewContext<'_, Pane>) -> impl RenderOnce<Self> {
div()
.group("tab_bar")
.id("tab_bar")
@ -1895,7 +1895,7 @@ impl FocusableView for Pane {
}
}
impl Render for Pane {
impl Render<Self> for Pane {
type Element = Focusable<Self, Div<Self>>;
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
@ -2949,7 +2949,7 @@ struct DraggedTab {
title: String,
}
impl Render for DraggedTab {
impl Render<Self> for DraggedTab {
type Element = Div<Self>;
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {

View file

@ -6,7 +6,10 @@ use db2::sqlez::{
bindable::{Bind, Column, StaticColumnCount},
statement::Statement,
};
use gpui::{point, size, AnyElement, AnyWeakView, Bounds, Model, Pixels, Point, View, ViewContext};
use gpui::{
point, size, AnyElement, AnyWeakView, Bounds, Div, Model, Pixels, Point, RenderOnce, View,
ViewContext,
};
use parking_lot::Mutex;
use project2::Project;
use serde::Deserialize;
@ -130,7 +133,7 @@ impl PaneGroup {
zoomed: Option<&AnyWeakView>,
app_state: &Arc<AppState>,
cx: &mut ViewContext<Workspace>,
) -> impl Component<Workspace> {
) -> impl RenderOnce<Workspace> {
self.root.render(
project,
0,
@ -202,7 +205,7 @@ impl Member {
zoomed: Option<&AnyWeakView>,
app_state: &Arc<AppState>,
cx: &mut ViewContext<Workspace>,
) -> impl Component<Workspace> {
) -> impl RenderOnce<Workspace> {
match self {
Member::Pane(pane) => {
// todo!()
@ -212,7 +215,7 @@ impl Member {
// Some(pane)
// };
div().size_full().child(pane.clone()).render()
div().size_full().child(pane.clone())
// Stack::new()
// .with_child(pane_element.contained().with_border(leader_border))
@ -559,7 +562,7 @@ impl PaneAxis {
zoomed: Option<&AnyWeakView>,
app_state: &Arc<AppState>,
cx: &mut ViewContext<Workspace>,
) -> AnyElement<Workspace> {
) -> Div<Workspace> {
debug_assert!(self.members.len() == self.flexes.lock().len());
div()
@ -582,11 +585,10 @@ impl PaneAxis {
app_state,
cx,
)
.render(),
Member::Pane(pane) => pane.clone().render(),
.render_into_any(),
Member::Pane(pane) => pane.clone().render_into_any(),
}
}))
.render()
// let mut pane_axis = PaneAxisElement::new(
// self.axis,

View file

@ -2,14 +2,14 @@ use std::any::TypeId;
use crate::{ItemHandle, Pane};
use gpui::{
div, AnyView, Component, Div, ParentElement, Render, Styled, Subscription, View,
div, AnyView, Component, Div, ParentElement, Render, RenderOnce, Styled, Subscription, View,
ViewContext, WindowContext,
};
use theme2::ActiveTheme;
use ui::h_stack;
use util::ResultExt;
pub trait StatusItemView: Render {
pub trait StatusItemView: Render<Self> {
fn set_active_pane_item(
&mut self,
active_pane_item: Option<&dyn crate::ItemHandle>,
@ -34,7 +34,7 @@ pub struct StatusBar {
_observe_active_pane: Subscription,
}
impl Render for StatusBar {
impl Render<Self> for StatusBar {
type Element = Div<Self>;
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
@ -53,14 +53,14 @@ impl Render for StatusBar {
}
impl StatusBar {
fn render_left_tools(&self, cx: &mut ViewContext<Self>) -> impl Component<Self> {
fn render_left_tools(&self, cx: &mut ViewContext<Self>) -> impl RenderOnce<Self> {
h_stack()
.items_center()
.gap_1()
.children(self.left_items.iter().map(|item| item.to_any()))
}
fn render_right_tools(&self, cx: &mut ViewContext<Self>) -> impl Component<Self> {
fn render_right_tools(&self, cx: &mut ViewContext<Self>) -> impl RenderOnce<Self> {
h_stack()
.items_center()
.gap_2()

View file

@ -7,7 +7,7 @@ pub enum ToolbarItemEvent {
ChangeLocation(ToolbarItemLocation),
}
pub trait ToolbarItemView: Render + EventEmitter<ToolbarItemEvent> {
pub trait ToolbarItemView: Render<Self> + EventEmitter<ToolbarItemEvent> {
fn set_active_pane_item(
&mut self,
active_pane_item: Option<&dyn crate::ItemHandle>,
@ -51,7 +51,7 @@ pub struct Toolbar {
items: Vec<(Box<dyn ToolbarItemViewHandle>, ToolbarItemLocation)>,
}
impl Render for Toolbar {
impl Render<Self> for Toolbar {
type Element = Div<Self>;
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {

View file

@ -3592,7 +3592,7 @@ impl FocusableView for Workspace {
}
}
impl Render for Workspace {
impl Render<Self> for Workspace {
type Element = Div<Self>;
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {