Return impl IntoElement from Render::render trait

This commit is contained in:
Nathan Sobo
2024-01-02 10:09:05 -07:00
parent 0f33775a91
commit 1b5c8b2b4a
84 changed files with 550 additions and 110 deletions
+3 -3
View File
@@ -505,7 +505,7 @@ impl Dock {
}
impl Render for Dock {
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl Element {
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoElement {
if let Some(entry) = self.visible_entry() {
let size = entry.panel.size(cx);
@@ -592,7 +592,7 @@ impl PanelButtons {
}
impl Render for PanelButtons {
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl Element {
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoElement {
// todo!()
let dock = self.dock.read(cx);
let active_index = dock.active_panel_index;
@@ -713,7 +713,7 @@ pub mod test {
}
impl Render for TestPanel {
fn render(&mut self, _cx: &mut ViewContext<Self>) -> impl Element {
fn render(&mut self, _cx: &mut ViewContext<Self>) -> impl IntoElement {
div()
}
}
+2 -2
View File
@@ -760,7 +760,7 @@ pub mod test {
use super::{Item, ItemEvent};
use crate::{ItemId, ItemNavHistory, Pane, Workspace, WorkspaceId};
use gpui::{
AnyElement, AppContext, Context as _, Element, EntityId, EventEmitter, FocusableView,
AnyElement, AppContext, Context as _, EntityId, EventEmitter, FocusableView,
InteractiveElement, IntoElement, Model, Render, SharedString, Task, View, ViewContext,
VisualContext, WeakView,
};
@@ -910,7 +910,7 @@ pub mod test {
}
impl Render for TestItem {
fn render(&mut self, _: &mut ViewContext<Self>) -> impl Element {
fn render(&mut self, _: &mut ViewContext<Self>) -> impl IntoElement {
gpui::div().track_focus(&self.focus_handle)
}
}
+1 -1
View File
@@ -104,7 +104,7 @@ impl ModalLayer {
}
impl Render for ModalLayer {
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl Element {
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoElement {
let Some(active_modal) = &self.active_modal else {
return div();
};
+1 -1
View File
@@ -219,7 +219,7 @@ pub mod simple_message_notification {
}
impl Render for MessageNotification {
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl Element {
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoElement {
v_stack()
.elevation_3(cx)
.p_4()
+2 -2
View File
@@ -1867,7 +1867,7 @@ impl FocusableView for Pane {
}
impl Render for Pane {
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl Element {
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoElement {
v_stack()
.key_context("Pane")
.track_focus(&self.focus_handle)
@@ -2746,7 +2746,7 @@ mod tests {
}
impl Render for DraggedTab {
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl Element {
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoElement {
let ui_font = ThemeSettings::get_global(cx).ui_font.family.clone();
let item = &self.pane.read(cx).items[self.ix];
let label = item.tab_content(Some(self.detail), false, cx);
+1 -1
View File
@@ -66,7 +66,7 @@ impl FocusableView for SharedScreen {
}
}
impl Render for SharedScreen {
fn render(&mut self, _: &mut ViewContext<Self>) -> impl Element {
fn render(&mut self, _: &mut ViewContext<Self>) -> impl IntoElement {
div().track_focus(&self.focus).size_full().children(
self.frame
.as_ref()
+1 -1
View File
@@ -33,7 +33,7 @@ pub struct StatusBar {
}
impl Render for StatusBar {
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl Element {
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoElement {
div()
.py_0p5()
.px_1()
+1 -1
View File
@@ -93,7 +93,7 @@ impl Toolbar {
}
impl Render for Toolbar {
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl Element {
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoElement {
if !self.has_any_visible_items() {
return div();
}
+1 -1
View File
@@ -3487,7 +3487,7 @@ impl FocusableView for Workspace {
struct DraggedDock(DockPosition);
impl Render for Workspace {
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl Element {
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoElement {
let mut context = KeyContext::default();
context.add("Workspace");