WIP
This commit is contained in:
parent
adc355a1e6
commit
0673606de8
11 changed files with 39 additions and 35 deletions
|
@ -9376,7 +9376,7 @@ impl FocusableView for Editor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Render for Editor {
|
impl Render<Self> for Editor {
|
||||||
type Element = EditorElement;
|
type Element = EditorElement;
|
||||||
|
|
||||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
||||||
|
|
|
@ -21,7 +21,7 @@ use gpui::{
|
||||||
div, point, px, relative, size, transparent_black, Action, AnyElement, AvailableSpace,
|
div, point, px, relative, size, transparent_black, Action, AnyElement, AvailableSpace,
|
||||||
BorrowWindow, Bounds, Component, ContentMask, Corners, DispatchPhase, Edges, Element,
|
BorrowWindow, Bounds, Component, ContentMask, Corners, DispatchPhase, Edges, Element,
|
||||||
ElementId, ElementInputHandler, Entity, EntityId, Hsla, InteractiveElement, LineLayout,
|
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,
|
ScrollWheelEvent, ShapedLine, SharedString, Size, StatefulInteractiveElement, Style, Styled,
|
||||||
TextRun, TextStyle, View, ViewContext, WindowContext, WrappedLine,
|
TextRun, TextStyle, View, ViewContext, WindowContext, WrappedLine,
|
||||||
};
|
};
|
||||||
|
@ -2466,9 +2466,11 @@ impl Element<Editor> for EditorElement {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Component<Editor> for EditorElement {
|
impl RenderOnce<Editor> for EditorElement {
|
||||||
fn render(self) -> AnyElement<Editor> {
|
type Element = Self;
|
||||||
AnyElement::new(self)
|
|
||||||
|
fn render_once(self) -> Self::Element {
|
||||||
|
self
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -59,7 +59,7 @@ struct TestView {
|
||||||
story: AnyView,
|
story: AnyView,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Render for TestView {
|
impl Render<Self> for TestView {
|
||||||
type Element = Div<Self>;
|
type Element = Div<Self>;
|
||||||
|
|
||||||
fn render(&mut self, _cx: &mut ViewContext<Self>) -> Self::Element {
|
fn render(&mut self, _cx: &mut ViewContext<Self>) -> Self::Element {
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
use crate::{status_bar::StatusItemView, Axis, Workspace};
|
use crate::{status_bar::StatusItemView, Axis, Workspace};
|
||||||
use gpui::{
|
use gpui::{
|
||||||
div, px, Action, AnchorCorner, AnyView, AppContext, Component, Div, Entity, EntityId,
|
div, px, Action, AnchorCorner, AnyView, AppContext, Component, Div, Entity, EntityId,
|
||||||
EventEmitter, FocusHandle, FocusableView, ParentElement, Render, SharedString, Styled,
|
EventEmitter, FocusHandle, FocusableView, ParentElement, Render, RenderOnce, SharedString,
|
||||||
Subscription, View, ViewContext, VisualContext, WeakView, WindowContext,
|
Styled, Subscription, View, ViewContext, VisualContext, WeakView, WindowContext,
|
||||||
};
|
};
|
||||||
use schemars::JsonSchema;
|
use schemars::JsonSchema;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
@ -426,7 +426,7 @@ impl Dock {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Render for Dock {
|
impl Render<Self> for Dock {
|
||||||
type Element = Div<Self>;
|
type Element = Div<Self>;
|
||||||
|
|
||||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
||||||
|
@ -612,7 +612,7 @@ impl PanelButtons {
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// here be kittens
|
// here be kittens
|
||||||
impl Render for PanelButtons {
|
impl Render<Self> for PanelButtons {
|
||||||
type Element = Div<Self>;
|
type Element = Div<Self>;
|
||||||
|
|
||||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
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>;
|
type Element = Div<Self>;
|
||||||
|
|
||||||
fn render(&mut self, _cx: &mut ViewContext<Self>) -> Self::Element {
|
fn render(&mut self, _cx: &mut ViewContext<Self>) -> Self::Element {
|
||||||
|
|
|
@ -71,7 +71,7 @@ impl ModalLayer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Render for ModalLayer {
|
impl Render<Self> for ModalLayer {
|
||||||
type Element = Div<Self>;
|
type Element = Div<Self>;
|
||||||
|
|
||||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
||||||
|
|
|
@ -13,7 +13,7 @@ pub enum NotificationEvent {
|
||||||
Dismiss,
|
Dismiss,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait Notification: EventEmitter<NotificationEvent> + Render {}
|
pub trait Notification: EventEmitter<NotificationEvent> + Render<Self> {}
|
||||||
|
|
||||||
pub trait NotificationHandle: Send {
|
pub trait NotificationHandle: Send {
|
||||||
fn id(&self) -> EntityId;
|
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>;
|
type Element = Div<Self>;
|
||||||
|
|
||||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
||||||
|
|
|
@ -593,7 +593,7 @@ impl Pane {
|
||||||
self.items.iter()
|
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
|
self.items
|
||||||
.iter()
|
.iter()
|
||||||
.filter_map(|item| item.to_any().downcast().ok())
|
.filter_map(|item| item.to_any().downcast().ok())
|
||||||
|
@ -1343,7 +1343,7 @@ impl Pane {
|
||||||
item: &Box<dyn ItemHandle>,
|
item: &Box<dyn ItemHandle>,
|
||||||
detail: usize,
|
detail: usize,
|
||||||
cx: &mut ViewContext<'_, Pane>,
|
cx: &mut ViewContext<'_, Pane>,
|
||||||
) -> impl Component<Self> {
|
) -> impl RenderOnce<Self> {
|
||||||
let label = item.tab_content(Some(detail), cx);
|
let label = item.tab_content(Some(detail), cx);
|
||||||
let close_icon = || {
|
let close_icon = || {
|
||||||
let id = item.item_id();
|
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()
|
div()
|
||||||
.group("tab_bar")
|
.group("tab_bar")
|
||||||
.id("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>>;
|
type Element = Focusable<Self, Div<Self>>;
|
||||||
|
|
||||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
||||||
|
@ -2949,7 +2949,7 @@ struct DraggedTab {
|
||||||
title: String,
|
title: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Render for DraggedTab {
|
impl Render<Self> for DraggedTab {
|
||||||
type Element = Div<Self>;
|
type Element = Div<Self>;
|
||||||
|
|
||||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
||||||
|
|
|
@ -6,7 +6,10 @@ use db2::sqlez::{
|
||||||
bindable::{Bind, Column, StaticColumnCount},
|
bindable::{Bind, Column, StaticColumnCount},
|
||||||
statement::Statement,
|
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 parking_lot::Mutex;
|
||||||
use project2::Project;
|
use project2::Project;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
@ -130,7 +133,7 @@ impl PaneGroup {
|
||||||
zoomed: Option<&AnyWeakView>,
|
zoomed: Option<&AnyWeakView>,
|
||||||
app_state: &Arc<AppState>,
|
app_state: &Arc<AppState>,
|
||||||
cx: &mut ViewContext<Workspace>,
|
cx: &mut ViewContext<Workspace>,
|
||||||
) -> impl Component<Workspace> {
|
) -> impl RenderOnce<Workspace> {
|
||||||
self.root.render(
|
self.root.render(
|
||||||
project,
|
project,
|
||||||
0,
|
0,
|
||||||
|
@ -202,7 +205,7 @@ impl Member {
|
||||||
zoomed: Option<&AnyWeakView>,
|
zoomed: Option<&AnyWeakView>,
|
||||||
app_state: &Arc<AppState>,
|
app_state: &Arc<AppState>,
|
||||||
cx: &mut ViewContext<Workspace>,
|
cx: &mut ViewContext<Workspace>,
|
||||||
) -> impl Component<Workspace> {
|
) -> impl RenderOnce<Workspace> {
|
||||||
match self {
|
match self {
|
||||||
Member::Pane(pane) => {
|
Member::Pane(pane) => {
|
||||||
// todo!()
|
// todo!()
|
||||||
|
@ -212,7 +215,7 @@ impl Member {
|
||||||
// Some(pane)
|
// Some(pane)
|
||||||
// };
|
// };
|
||||||
|
|
||||||
div().size_full().child(pane.clone()).render()
|
div().size_full().child(pane.clone())
|
||||||
|
|
||||||
// Stack::new()
|
// Stack::new()
|
||||||
// .with_child(pane_element.contained().with_border(leader_border))
|
// .with_child(pane_element.contained().with_border(leader_border))
|
||||||
|
@ -559,7 +562,7 @@ impl PaneAxis {
|
||||||
zoomed: Option<&AnyWeakView>,
|
zoomed: Option<&AnyWeakView>,
|
||||||
app_state: &Arc<AppState>,
|
app_state: &Arc<AppState>,
|
||||||
cx: &mut ViewContext<Workspace>,
|
cx: &mut ViewContext<Workspace>,
|
||||||
) -> AnyElement<Workspace> {
|
) -> Div<Workspace> {
|
||||||
debug_assert!(self.members.len() == self.flexes.lock().len());
|
debug_assert!(self.members.len() == self.flexes.lock().len());
|
||||||
|
|
||||||
div()
|
div()
|
||||||
|
@ -582,11 +585,10 @@ impl PaneAxis {
|
||||||
app_state,
|
app_state,
|
||||||
cx,
|
cx,
|
||||||
)
|
)
|
||||||
.render(),
|
.render_into_any(),
|
||||||
Member::Pane(pane) => pane.clone().render(),
|
Member::Pane(pane) => pane.clone().render_into_any(),
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
.render()
|
|
||||||
|
|
||||||
// let mut pane_axis = PaneAxisElement::new(
|
// let mut pane_axis = PaneAxisElement::new(
|
||||||
// self.axis,
|
// self.axis,
|
||||||
|
|
|
@ -2,14 +2,14 @@ use std::any::TypeId;
|
||||||
|
|
||||||
use crate::{ItemHandle, Pane};
|
use crate::{ItemHandle, Pane};
|
||||||
use gpui::{
|
use gpui::{
|
||||||
div, AnyView, Component, Div, ParentElement, Render, Styled, Subscription, View,
|
div, AnyView, Component, Div, ParentElement, Render, RenderOnce, Styled, Subscription, View,
|
||||||
ViewContext, WindowContext,
|
ViewContext, WindowContext,
|
||||||
};
|
};
|
||||||
use theme2::ActiveTheme;
|
use theme2::ActiveTheme;
|
||||||
use ui::h_stack;
|
use ui::h_stack;
|
||||||
use util::ResultExt;
|
use util::ResultExt;
|
||||||
|
|
||||||
pub trait StatusItemView: Render {
|
pub trait StatusItemView: Render<Self> {
|
||||||
fn set_active_pane_item(
|
fn set_active_pane_item(
|
||||||
&mut self,
|
&mut self,
|
||||||
active_pane_item: Option<&dyn crate::ItemHandle>,
|
active_pane_item: Option<&dyn crate::ItemHandle>,
|
||||||
|
@ -34,7 +34,7 @@ pub struct StatusBar {
|
||||||
_observe_active_pane: Subscription,
|
_observe_active_pane: Subscription,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Render for StatusBar {
|
impl Render<Self> for StatusBar {
|
||||||
type Element = Div<Self>;
|
type Element = Div<Self>;
|
||||||
|
|
||||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
||||||
|
@ -53,14 +53,14 @@ impl Render for StatusBar {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl 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()
|
h_stack()
|
||||||
.items_center()
|
.items_center()
|
||||||
.gap_1()
|
.gap_1()
|
||||||
.children(self.left_items.iter().map(|item| item.to_any()))
|
.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()
|
h_stack()
|
||||||
.items_center()
|
.items_center()
|
||||||
.gap_2()
|
.gap_2()
|
||||||
|
|
|
@ -7,7 +7,7 @@ pub enum ToolbarItemEvent {
|
||||||
ChangeLocation(ToolbarItemLocation),
|
ChangeLocation(ToolbarItemLocation),
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait ToolbarItemView: Render + EventEmitter<ToolbarItemEvent> {
|
pub trait ToolbarItemView: Render<Self> + EventEmitter<ToolbarItemEvent> {
|
||||||
fn set_active_pane_item(
|
fn set_active_pane_item(
|
||||||
&mut self,
|
&mut self,
|
||||||
active_pane_item: Option<&dyn crate::ItemHandle>,
|
active_pane_item: Option<&dyn crate::ItemHandle>,
|
||||||
|
@ -51,7 +51,7 @@ pub struct Toolbar {
|
||||||
items: Vec<(Box<dyn ToolbarItemViewHandle>, ToolbarItemLocation)>,
|
items: Vec<(Box<dyn ToolbarItemViewHandle>, ToolbarItemLocation)>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Render for Toolbar {
|
impl Render<Self> for Toolbar {
|
||||||
type Element = Div<Self>;
|
type Element = Div<Self>;
|
||||||
|
|
||||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
||||||
|
|
|
@ -3592,7 +3592,7 @@ impl FocusableView for Workspace {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Render for Workspace {
|
impl Render<Self> for Workspace {
|
||||||
type Element = Div<Self>;
|
type Element = Div<Self>;
|
||||||
|
|
||||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue