Return impl IntoElement in Render and RenderOnce traits (#3839)

- Returning `IntoElement` because it's more universal than `Element` and
allows us to easily return components.
- Using `impl IntoElement` in `RenderOnce` for consistency, which
requires `Component` to allocate an `AnyElement`. We use a bump
allocated arena anyway for these, and my benchmark doesn't show an
impact.


![frame-time-histogram](https://github.com/zed-industries/zed/assets/1789/d3889cca-9ebc-4d72-aa68-34a5be3bad3c)

In this histogram, frames-0 is this PR, frames-1 is main.

Release Notes:

- N/A
This commit is contained in:
Nathan Sobo 2024-01-03 10:37:26 -07:00 committed by GitHub
commit 5f8417249c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
117 changed files with 631 additions and 292 deletions

View file

@ -304,7 +304,7 @@ impl ActivityIndicator {
impl EventEmitter<Event> for ActivityIndicator {} impl EventEmitter<Event> for ActivityIndicator {}
impl Render for ActivityIndicator { impl Render for ActivityIndicator {
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl Element { fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoElement {
let content = self.content_to_render(cx); let content = self.content_to_render(cx);
let mut result = h_stack() let mut result = h_stack()

View file

@ -1101,7 +1101,7 @@ fn build_api_key_editor(cx: &mut ViewContext<AssistantPanel>) -> View<Editor> {
} }
impl Render for AssistantPanel { impl Render for AssistantPanel {
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl Element { fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoElement {
if let Some(api_key_editor) = self.api_key_editor.clone() { if let Some(api_key_editor) = self.api_key_editor.clone() {
v_stack() v_stack()
.on_action(cx.listener(AssistantPanel::save_credentials)) .on_action(cx.listener(AssistantPanel::save_credentials))

View file

@ -1,5 +1,5 @@
use gpui::{ use gpui::{
div, DismissEvent, Element, EventEmitter, InteractiveElement, ParentElement, Render, div, DismissEvent, EventEmitter, InteractiveElement, IntoElement, ParentElement, Render,
SemanticVersion, StatefulInteractiveElement, Styled, ViewContext, SemanticVersion, StatefulInteractiveElement, Styled, ViewContext,
}; };
use menu::Cancel; use menu::Cancel;
@ -13,7 +13,7 @@ pub struct UpdateNotification {
impl EventEmitter<DismissEvent> for UpdateNotification {} impl EventEmitter<DismissEvent> for UpdateNotification {}
impl Render for UpdateNotification { impl Render for UpdateNotification {
fn render(&mut self, cx: &mut gpui::ViewContext<Self>) -> impl Element { fn render(&mut self, cx: &mut gpui::ViewContext<Self>) -> impl IntoElement {
let app_name = cx.global::<ReleaseChannel>().display_name(); let app_name = cx.global::<ReleaseChannel>().display_name();
v_stack() v_stack()

View file

@ -30,7 +30,7 @@ impl Breadcrumbs {
impl EventEmitter<ToolbarItemEvent> for Breadcrumbs {} impl EventEmitter<ToolbarItemEvent> for Breadcrumbs {}
impl Render for Breadcrumbs { impl Render for Breadcrumbs {
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl Element { fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoElement {
let element = h_stack().text_ui(); let element = h_stack().text_ui();
let Some(active_item) = self.active_item.as_ref() else { let Some(active_item) = self.active_item.as_ref() else {
return element; return element;

View file

@ -222,7 +222,7 @@ impl ChannelView {
impl EventEmitter<EditorEvent> for ChannelView {} impl EventEmitter<EditorEvent> for ChannelView {}
impl Render for ChannelView { impl Render for ChannelView {
fn render(&mut self, _cx: &mut ViewContext<Self>) -> impl Element { fn render(&mut self, _cx: &mut ViewContext<Self>) -> impl IntoElement {
self.editor.clone() self.editor.clone()
} }
} }

View file

@ -549,7 +549,7 @@ impl ChatPanel {
impl EventEmitter<Event> for ChatPanel {} impl EventEmitter<Event> for ChatPanel {}
impl Render for ChatPanel { impl Render for ChatPanel {
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl Element { fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoElement {
div() div()
.full() .full()
.child(if self.client.user_id().is_some() { .child(if self.client.user_id().is_some() {

View file

@ -3,7 +3,7 @@ use client::UserId;
use collections::HashMap; use collections::HashMap;
use editor::{AnchorRangeExt, Editor}; use editor::{AnchorRangeExt, Editor};
use gpui::{ use gpui::{
AsyncWindowContext, Element, FocusableView, Model, Render, SharedString, Task, View, AsyncWindowContext, FocusableView, IntoElement, Model, Render, SharedString, Task, View,
ViewContext, WeakView, ViewContext, WeakView,
}; };
use language::{language_settings::SoftWrap, Buffer, BufferSnapshot, LanguageRegistry}; use language::{language_settings::SoftWrap, Buffer, BufferSnapshot, LanguageRegistry};
@ -196,7 +196,7 @@ impl MessageEditor {
} }
impl Render for MessageEditor { impl Render for MessageEditor {
fn render(&mut self, _cx: &mut ViewContext<Self>) -> impl Element { fn render(&mut self, _cx: &mut ViewContext<Self>) -> impl IntoElement {
self.editor.to_any() self.editor.to_any()
} }
} }

View file

@ -2323,7 +2323,7 @@ fn render_tree_branch(is_last: bool, cx: &mut WindowContext) -> impl IntoElement
} }
impl Render for CollabPanel { impl Render for CollabPanel {
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl Element { fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoElement {
v_stack() v_stack()
.key_context("CollabPanel") .key_context("CollabPanel")
.on_action(cx.listener(CollabPanel::cancel)) .on_action(cx.listener(CollabPanel::cancel))

View file

@ -142,7 +142,7 @@ impl FocusableView for ChannelModal {
} }
impl Render for ChannelModal { impl Render for ChannelModal {
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl Element { fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoElement {
let channel_store = self.channel_store.read(cx); let channel_store = self.channel_store.read(cx);
let Some(channel) = channel_store.channel_for_id(self.channel_id) else { let Some(channel) = channel_store.channel_for_id(self.channel_id) else {
return div(); return div();

View file

@ -35,7 +35,7 @@ impl ContactFinder {
} }
impl Render for ContactFinder { impl Render for ContactFinder {
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl Element { fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoElement {
v_stack() v_stack()
.elevation_3(cx) .elevation_3(cx)
.child( .child(

View file

@ -56,7 +56,7 @@ pub struct CollabTitlebarItem {
} }
impl Render for CollabTitlebarItem { impl Render for CollabTitlebarItem {
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl Element { fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoElement {
let room = ActiveCall::global(cx).read(cx).room().cloned(); let room = ActiveCall::global(cx).read(cx).room().cloned();
let current_user = self.user_store.read(cx).current_user(); let current_user = self.user_store.read(cx).current_user();
let client = self.client.clone(); let client = self.client.clone();

View file

@ -1,5 +1,5 @@
use gpui::{ use gpui::{
div, AnyElement, Div, ElementId, IntoElement, ParentElement, RenderOnce, Styled, WindowContext, div, AnyElement, ElementId, IntoElement, ParentElement, RenderOnce, Styled, WindowContext,
}; };
use smallvec::SmallVec; use smallvec::SmallVec;
@ -9,9 +9,7 @@ pub struct FacePile {
} }
impl RenderOnce for FacePile { impl RenderOnce for FacePile {
type Output = Div; fn render(self, _: &mut WindowContext) -> impl IntoElement {
fn render(self, _: &mut WindowContext) -> Self::Output {
let player_count = self.faces.len(); let player_count = self.faces.len();
let player_list = self.faces.into_iter().enumerate().map(|(ix, player)| { let player_list = self.faces.into_iter().enumerate().map(|(ix, player)| {
let isnt_last = ix < player_count - 1; let isnt_last = ix < player_count - 1;

View file

@ -540,7 +540,7 @@ impl NotificationPanel {
} }
impl Render for NotificationPanel { impl Render for NotificationPanel {
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl Element { fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoElement {
v_stack() v_stack()
.size_full() .size_full()
.child( .child(
@ -708,7 +708,7 @@ impl NotificationToast {
} }
impl Render for NotificationToast { impl Render for NotificationToast {
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl Element { fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoElement {
let user = self.actor.clone(); let user = self.actor.clone();
h_stack() h_stack()

View file

@ -117,7 +117,7 @@ impl IncomingCallNotification {
} }
impl Render for IncomingCallNotification { impl Render for IncomingCallNotification {
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl Element { fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoElement {
// TODO: Is there a better place for us to initialize the font? // TODO: Is there a better place for us to initialize the font?
let (ui_font, ui_font_size) = { let (ui_font, ui_font_size) = {
let theme_settings = ThemeSettings::get_global(cx); let theme_settings = ThemeSettings::get_global(cx);

View file

@ -118,7 +118,7 @@ impl ProjectSharedNotification {
} }
impl Render for ProjectSharedNotification { impl Render for ProjectSharedNotification {
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl Element { fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoElement {
// TODO: Is there a better place for us to initialize the font? // TODO: Is there a better place for us to initialize the font?
let (ui_font, ui_font_size) = { let (ui_font, ui_font_size) = {
let theme_settings = ThemeSettings::get_global(cx); let theme_settings = ThemeSettings::get_global(cx);

View file

@ -83,7 +83,7 @@ impl FocusableView for CommandPalette {
} }
impl Render for CommandPalette { impl Render for CommandPalette {
fn render(&mut self, _cx: &mut ViewContext<Self>) -> impl Element { fn render(&mut self, _cx: &mut ViewContext<Self>) -> impl IntoElement {
v_stack().w(rems(34.)).child(self.picker.clone()) v_stack().w(rems(34.)).child(self.picker.clone())
} }
} }

View file

@ -181,7 +181,7 @@ impl CopilotCodeVerification {
} }
impl Render for CopilotCodeVerification { impl Render for CopilotCodeVerification {
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl Element { fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoElement {
let prompt = match &self.status { let prompt = match &self.status {
Status::SigningIn { Status::SigningIn {
prompt: Some(prompt), prompt: Some(prompt),

View file

@ -3,7 +3,7 @@ use copilot::{Copilot, SignOut, Status};
use editor::{scroll::autoscroll::Autoscroll, Editor}; use editor::{scroll::autoscroll::Autoscroll, Editor};
use fs::Fs; use fs::Fs;
use gpui::{ use gpui::{
div, Action, AnchorCorner, AppContext, AsyncWindowContext, Element, Entity, ParentElement, div, Action, AnchorCorner, AppContext, AsyncWindowContext, Entity, IntoElement, ParentElement,
Render, Subscription, View, ViewContext, WeakView, WindowContext, Render, Subscription, View, ViewContext, WeakView, WindowContext,
}; };
use language::{ use language::{
@ -34,7 +34,7 @@ pub struct CopilotButton {
} }
impl Render for CopilotButton { impl Render for CopilotButton {
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl Element { fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoElement {
let all_language_settings = all_language_settings(None, cx); let all_language_settings = all_language_settings(None, cx);
if !all_language_settings.copilot.feature_enabled { if !all_language_settings.copilot.feature_enabled {
return div(); return div();

View file

@ -21,7 +21,7 @@ pub struct DiagnosticIndicator {
} }
impl Render for DiagnosticIndicator { impl Render for DiagnosticIndicator {
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl Element { fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoElement {
let diagnostic_indicator = match (self.summary.error_count, self.summary.warning_count) { let diagnostic_indicator = match (self.summary.error_count, self.summary.warning_count) {
(0, 0) => h_stack().child( (0, 0) => h_stack().child(
IconElement::new(Icon::Check) IconElement::new(Icon::Check)

View file

@ -9,7 +9,7 @@ pub struct ToolbarControls {
} }
impl Render for ToolbarControls { impl Render for ToolbarControls {
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl Element { fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoElement {
let include_warnings = self let include_warnings = self
.editor .editor
.as_ref() .as_ref()

View file

@ -9287,7 +9287,7 @@ impl FocusableView for Editor {
} }
impl Render for Editor { impl Render for Editor {
fn render<'a>(&mut self, cx: &mut ViewContext<'a, Self>) -> impl 'static + Element { fn render<'a>(&mut self, cx: &mut ViewContext<'a, Self>) -> impl IntoElement {
let settings = ThemeSettings::get_global(cx); let settings = ThemeSettings::get_global(cx);
let text_style = match self.mode { let text_style = match self.mode {
EditorMode::SingleLine | EditorMode::AutoHeight { .. } => TextStyle { EditorMode::SingleLine | EditorMode::AutoHeight { .. } => TextStyle {

View file

@ -1193,7 +1193,7 @@ impl CursorPosition {
} }
impl Render for CursorPosition { impl Render for CursorPosition {
fn render(&mut self, _: &mut ViewContext<Self>) -> impl Element { fn render(&mut self, _: &mut ViewContext<Self>) -> impl IntoElement {
div().when_some(self.position, |el, position| { div().when_some(self.position, |el, position| {
let mut text = format!( let mut text = format!(
"{}{FILE_ROW_COLUMN_DELIMITER}{}", "{}{FILE_ROW_COLUMN_DELIMITER}{}",

View file

@ -17,7 +17,7 @@ impl DeployFeedbackButton {
} }
impl Render for DeployFeedbackButton { impl Render for DeployFeedbackButton {
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl Element { fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoElement {
let is_open = self let is_open = self
.workspace .workspace
.upgrade() .upgrade()

View file

@ -396,7 +396,7 @@ impl FeedbackModal {
} }
impl Render for FeedbackModal { impl Render for FeedbackModal {
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl Element { fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoElement {
self.update_submission_state(cx); self.update_submission_state(cx);
let submit_button_text = if self.awaiting_submission() { let submit_button_text = if self.awaiting_submission() {

View file

@ -118,7 +118,7 @@ impl FocusableView for FileFinder {
} }
} }
impl Render for FileFinder { impl Render for FileFinder {
fn render(&mut self, _cx: &mut ViewContext<Self>) -> impl Element { fn render(&mut self, _cx: &mut ViewContext<Self>) -> impl IntoElement {
v_stack().w(rems(34.)).child(self.picker.clone()) v_stack().w(rems(34.)).child(self.picker.clone())
} }
} }

View file

@ -152,7 +152,7 @@ impl GoToLine {
} }
impl Render for GoToLine { impl Render for GoToLine {
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl Element { fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoElement {
div() div()
.elevation_2(cx) .elevation_2(cx)
.key_context("GoToLine") .key_context("GoToLine")

View file

@ -1,7 +1,7 @@
use crate::{ use crate::{
div, Action, AnyView, AnyWindowHandle, AppCell, AppContext, AsyncAppContext, div, Action, AnyView, AnyWindowHandle, AppCell, AppContext, AsyncAppContext,
BackgroundExecutor, Bounds, ClipboardItem, Context, Element, Entity, EventEmitter, BackgroundExecutor, Bounds, ClipboardItem, Context, Entity, EventEmitter, ForegroundExecutor,
ForegroundExecutor, InputEvent, KeyDownEvent, Keystroke, Model, ModelContext, Pixels, Platform, InputEvent, IntoElement, KeyDownEvent, Keystroke, Model, ModelContext, Pixels, Platform,
PlatformWindow, Point, Render, Result, Size, Task, TestDispatcher, TestPlatform, TestWindow, PlatformWindow, Point, Render, Result, Size, Task, TestDispatcher, TestPlatform, TestWindow,
TestWindowHandlers, TextSystem, View, ViewContext, VisualContext, WindowBounds, WindowContext, TestWindowHandlers, TextSystem, View, ViewContext, VisualContext, WindowBounds, WindowContext,
WindowHandle, WindowOptions, WindowHandle, WindowOptions,
@ -731,7 +731,7 @@ impl AnyWindowHandle {
pub struct EmptyView {} pub struct EmptyView {}
impl Render for EmptyView { impl Render for EmptyView {
fn render(&mut self, _cx: &mut crate::ViewContext<Self>) -> impl Element { fn render(&mut self, _cx: &mut crate::ViewContext<Self>) -> impl IntoElement {
div() div()
} }
} }

View file

@ -6,6 +6,10 @@ use derive_more::{Deref, DerefMut};
pub(crate) use smallvec::SmallVec; pub(crate) use smallvec::SmallVec;
use std::{any::Any, fmt::Debug}; use std::{any::Any, fmt::Debug};
/// Implemented by types that participate in laying out and painting the contents of a window.
/// Elements form a tree and are laid out according to web-based layout rules.
/// Rather than calling methods on implementers of this trait directly, you'll usually call `into_any` to convert them into an AnyElement, which manages state internally.
/// You can create custom elements by implementing this trait.
pub trait Element: 'static + IntoElement { pub trait Element: 'static + IntoElement {
type State: 'static; type State: 'static;
@ -107,15 +111,13 @@ pub trait IntoElement: Sized {
} }
pub trait Render: 'static + Sized { pub trait Render: 'static + Sized {
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl Element; fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoElement;
} }
/// You can derive [IntoElement] on any type that implements this trait. /// You can derive [IntoElement] on any type that implements this trait.
/// It is used to allow views to be expressed in terms of abstract data. /// It is used to allow views to be expressed in terms of abstract data.
pub trait RenderOnce: 'static { pub trait RenderOnce: 'static {
type Output: IntoElement; fn render(self, cx: &mut WindowContext) -> impl IntoElement;
fn render(self, cx: &mut WindowContext) -> Self::Output;
} }
pub trait ParentElement { pub trait ParentElement {
@ -139,62 +141,29 @@ pub trait ParentElement {
} }
} }
pub struct Component<C> { pub struct Component<C: RenderOnce>(Option<C>);
component: Option<C>,
}
pub struct ComponentState<C: RenderOnce> { impl<C: RenderOnce> Component<C> {
rendered_element: Option<<C::Output as IntoElement>::Element>,
rendered_element_state: Option<<<C::Output as IntoElement>::Element as Element>::State>,
}
impl<C> Component<C> {
pub fn new(component: C) -> Self { pub fn new(component: C) -> Self {
Component { Component(Some(component))
component: Some(component),
}
} }
} }
impl<C: RenderOnce> Element for Component<C> { impl<C: RenderOnce> Element for Component<C> {
type State = ComponentState<C>; type State = AnyElement;
fn request_layout( fn request_layout(
&mut self, &mut self,
state: Option<Self::State>, _: Option<Self::State>,
cx: &mut WindowContext, cx: &mut WindowContext,
) -> (LayoutId, Self::State) { ) -> (LayoutId, Self::State) {
let mut element = self.component.take().unwrap().render(cx).into_element(); let mut element = self.0.take().unwrap().render(cx).into_any_element();
if let Some(element_id) = element.element_id() { let layout_id = element.request_layout(cx);
let layout_id = (layout_id, element)
cx.with_element_state(element_id, |state, cx| element.request_layout(state, cx));
let state = ComponentState {
rendered_element: Some(element),
rendered_element_state: None,
};
(layout_id, state)
} else {
let (layout_id, state) =
element.request_layout(state.and_then(|s| s.rendered_element_state), cx);
let state = ComponentState {
rendered_element: Some(element),
rendered_element_state: Some(state),
};
(layout_id, state)
}
} }
fn paint(&mut self, bounds: Bounds<Pixels>, state: &mut Self::State, cx: &mut WindowContext) { fn paint(&mut self, _: Bounds<Pixels>, element: &mut Self::State, cx: &mut WindowContext) {
let mut element = state.rendered_element.take().unwrap(); element.paint(cx)
if let Some(element_id) = element.element_id() {
cx.with_element_state(element_id, |element_state, cx| {
let mut element_state = element_state.unwrap();
element.paint(bounds, &mut element_state, cx);
((), element_state)
});
} else {
element.paint(bounds, state.rendered_element_state.as_mut().unwrap(), cx);
}
} }
} }
@ -216,7 +185,7 @@ pub struct GlobalElementId(SmallVec<[ElementId; 32]>);
trait ElementObject { trait ElementObject {
fn element_id(&self) -> Option<ElementId>; fn element_id(&self) -> Option<ElementId>;
fn layout(&mut self, cx: &mut WindowContext) -> LayoutId; fn request_layout(&mut self, cx: &mut WindowContext) -> LayoutId;
fn paint(&mut self, cx: &mut WindowContext); fn paint(&mut self, cx: &mut WindowContext);
@ -391,7 +360,7 @@ where
self.as_ref().unwrap().element_id() self.as_ref().unwrap().element_id()
} }
fn layout(&mut self, cx: &mut WindowContext) -> LayoutId { fn request_layout(&mut self, cx: &mut WindowContext) -> LayoutId {
DrawableElement::request_layout(self.as_mut().unwrap(), cx) DrawableElement::request_layout(self.as_mut().unwrap(), cx)
} }
@ -431,8 +400,8 @@ impl AnyElement {
AnyElement(element) AnyElement(element)
} }
pub fn layout(&mut self, cx: &mut WindowContext) -> LayoutId { pub fn request_layout(&mut self, cx: &mut WindowContext) -> LayoutId {
self.0.layout(cx) self.0.request_layout(cx)
} }
pub fn paint(&mut self, cx: &mut WindowContext) { pub fn paint(&mut self, cx: &mut WindowContext) {
@ -471,7 +440,7 @@ impl Element for AnyElement {
_: Option<Self::State>, _: Option<Self::State>,
cx: &mut WindowContext, cx: &mut WindowContext,
) -> (LayoutId, Self::State) { ) -> (LayoutId, Self::State) {
let layout_id = self.layout(cx); let layout_id = self.request_layout(cx);
(layout_id, ()) (layout_id, ())
} }

View file

@ -781,7 +781,7 @@ impl Element for Div {
child_layout_ids = self child_layout_ids = self
.children .children
.iter_mut() .iter_mut()
.map(|child| child.layout(cx)) .map(|child| child.request_layout(cx))
.collect::<SmallVec<_>>(); .collect::<SmallVec<_>>();
cx.request_layout(&style, child_layout_ids.iter().copied()) cx.request_layout(&style, child_layout_ids.iter().copied())
}) })

View file

@ -68,7 +68,7 @@ impl Element for Overlay {
let child_layout_ids = self let child_layout_ids = self
.children .children
.iter_mut() .iter_mut()
.map(|child| child.layout(cx)) .map(|child| child.request_layout(cx))
.collect::<SmallVec<_>>(); .collect::<SmallVec<_>>();
let overlay_style = Style { let overlay_style = Style {

View file

@ -205,7 +205,7 @@ impl ExternalPaths {
} }
impl Render for ExternalPaths { impl Render for ExternalPaths {
fn render(&mut self, _: &mut ViewContext<Self>) -> impl Element { fn render(&mut self, _: &mut ViewContext<Self>) -> impl IntoElement {
div() // Intentionally left empty because the platform will render icons for the dragged files div() // Intentionally left empty because the platform will render icons for the dragged files
} }
} }

View file

@ -87,7 +87,7 @@ impl<V: Render> Element for View<V> {
cx: &mut WindowContext, cx: &mut WindowContext,
) -> (LayoutId, Self::State) { ) -> (LayoutId, Self::State) {
let mut element = self.update(cx, |view, cx| view.render(cx).into_any_element()); let mut element = self.update(cx, |view, cx| view.render(cx).into_any_element());
let layout_id = element.layout(cx); let layout_id = element.request_layout(cx);
(layout_id, Some(element)) (layout_id, Some(element))
} }
@ -321,7 +321,7 @@ mod any_view {
) -> (LayoutId, AnyElement) { ) -> (LayoutId, AnyElement) {
let view = view.clone().downcast::<V>().unwrap(); let view = view.clone().downcast::<V>().unwrap();
let mut element = view.update(cx, |view, cx| view.render(cx).into_any_element()); let mut element = view.update(cx, |view, cx| view.render(cx).into_any_element());
let layout_id = element.layout(cx); let layout_id = element.request_layout(cx);
(layout_id, element) (layout_id, element)
} }

View file

@ -1,7 +1,5 @@
use editor::Editor; use editor::Editor;
use gpui::{ use gpui::{div, IntoElement, ParentElement, Render, Subscription, View, ViewContext, WeakView};
div, Element, IntoElement, ParentElement, Render, Subscription, View, ViewContext, WeakView,
};
use std::sync::Arc; use std::sync::Arc;
use ui::{Button, ButtonCommon, Clickable, LabelSize, Tooltip}; use ui::{Button, ButtonCommon, Clickable, LabelSize, Tooltip};
use workspace::{item::ItemHandle, StatusItemView, Workspace}; use workspace::{item::ItemHandle, StatusItemView, Workspace};
@ -38,7 +36,7 @@ impl ActiveBufferLanguage {
} }
impl Render for ActiveBufferLanguage { impl Render for ActiveBufferLanguage {
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl Element { fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoElement {
div().when_some(self.active_language.as_ref(), |el, active_language| { div().when_some(self.active_language.as_ref(), |el, active_language| {
let active_language_text = if let Some(active_language_text) = active_language { let active_language_text = if let Some(active_language_text) = active_language {
active_language_text.to_string() active_language_text.to_string()

View file

@ -67,7 +67,7 @@ impl LanguageSelector {
} }
impl Render for LanguageSelector { impl Render for LanguageSelector {
fn render(&mut self, _cx: &mut ViewContext<Self>) -> impl Element { fn render(&mut self, _cx: &mut ViewContext<Self>) -> impl IntoElement {
v_stack().w(rems(34.)).child(self.picker.clone()) v_stack().w(rems(34.)).child(self.picker.clone())
} }
} }

View file

@ -2,9 +2,9 @@ use collections::{HashMap, VecDeque};
use editor::{Editor, EditorEvent, MoveToEnd}; use editor::{Editor, EditorEvent, MoveToEnd};
use futures::{channel::mpsc, StreamExt}; use futures::{channel::mpsc, StreamExt};
use gpui::{ use gpui::{
actions, div, AnchorCorner, AnyElement, AppContext, Context, Element, EventEmitter, actions, div, AnchorCorner, AnyElement, AppContext, Context, EventEmitter, FocusHandle,
FocusHandle, FocusableView, IntoElement, Model, ModelContext, ParentElement, Render, Styled, FocusableView, IntoElement, Model, ModelContext, ParentElement, Render, Styled, Subscription,
Subscription, View, ViewContext, VisualContext, WeakModel, WindowContext, View, ViewContext, VisualContext, WeakModel, WindowContext,
}; };
use language::{LanguageServerId, LanguageServerName}; use language::{LanguageServerId, LanguageServerName};
use lsp::IoKind; use lsp::IoKind;
@ -595,9 +595,9 @@ fn log_contents(lines: &VecDeque<String>) -> String {
} }
impl Render for LspLogView { impl Render for LspLogView {
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl Element { fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoElement {
self.editor self.editor
.update(cx, |editor, cx| editor.render(cx).into_any()) .update(cx, |editor, cx| editor.render(cx).into_any_element())
} }
} }
@ -708,7 +708,7 @@ impl ToolbarItemView for LspLogToolbarItemView {
} }
impl Render for LspLogToolbarItemView { impl Render for LspLogToolbarItemView {
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl Element { fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoElement {
let Some(log_view) = self.log_view.clone() else { let Some(log_view) = self.log_view.clone() else {
return div(); return div();
}; };

View file

@ -1,6 +1,6 @@
use editor::{scroll::autoscroll::Autoscroll, Anchor, Editor, ExcerptId}; use editor::{scroll::autoscroll::Autoscroll, Anchor, Editor, ExcerptId};
use gpui::{ use gpui::{
actions, canvas, div, rems, uniform_list, AnyElement, AppContext, AvailableSpace, Div, Element, actions, canvas, div, rems, uniform_list, AnyElement, AppContext, AvailableSpace, Div,
EventEmitter, FocusHandle, FocusableView, Hsla, InteractiveElement, IntoElement, Model, EventEmitter, FocusHandle, FocusableView, Hsla, InteractiveElement, IntoElement, Model,
MouseButton, MouseDownEvent, MouseMoveEvent, ParentElement, Pixels, Render, Styled, MouseButton, MouseDownEvent, MouseMoveEvent, ParentElement, Pixels, Render, Styled,
UniformListScrollHandle, View, ViewContext, VisualContext, WeakView, WindowContext, UniformListScrollHandle, View, ViewContext, VisualContext, WeakView, WindowContext,
@ -305,7 +305,7 @@ impl SyntaxTreeView {
} }
impl Render for SyntaxTreeView { impl Render for SyntaxTreeView {
fn render(&mut self, cx: &mut gpui::ViewContext<'_, Self>) -> impl Element { fn render(&mut self, cx: &mut gpui::ViewContext<'_, Self>) -> impl IntoElement {
let settings = ThemeSettings::get_global(cx); let settings = ThemeSettings::get_global(cx);
let line_height = cx let line_height = cx
.text_style() .text_style()
@ -505,7 +505,7 @@ fn format_node_range(node: Node) -> String {
} }
impl Render for SyntaxTreeToolbarItemView { impl Render for SyntaxTreeToolbarItemView {
fn render(&mut self, cx: &mut ViewContext<'_, Self>) -> impl Element { fn render(&mut self, cx: &mut ViewContext<'_, Self>) -> impl IntoElement {
self.render_menu(cx) self.render_menu(cx)
.unwrap_or_else(|| popover_menu("Empty Syntax Tree")) .unwrap_or_else(|| popover_menu("Empty Syntax Tree"))
} }

View file

@ -57,7 +57,7 @@ impl EventEmitter<DismissEvent> for OutlineView {}
impl ModalView for OutlineView {} impl ModalView for OutlineView {}
impl Render for OutlineView { impl Render for OutlineView {
fn render(&mut self, _cx: &mut ViewContext<Self>) -> impl Element { fn render(&mut self, _cx: &mut ViewContext<Self>) -> impl IntoElement {
v_stack().w(rems(34.)).child(self.picker.clone()) v_stack().w(rems(34.)).child(self.picker.clone())
} }
} }

View file

@ -235,7 +235,7 @@ impl<D: PickerDelegate> EventEmitter<DismissEvent> for Picker<D> {}
impl<D: PickerDelegate> ModalView for Picker<D> {} impl<D: PickerDelegate> ModalView for Picker<D> {}
impl<D: PickerDelegate> Render for Picker<D> { impl<D: PickerDelegate> Render for Picker<D> {
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl Element { fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoElement {
let picker_editor = h_stack() let picker_editor = h_stack()
.overflow_hidden() .overflow_hidden()
.flex_none() .flex_none()

View file

@ -1480,7 +1480,7 @@ impl ProjectPanel {
} }
impl Render for ProjectPanel { impl Render for ProjectPanel {
fn render(&mut self, cx: &mut gpui::ViewContext<Self>) -> impl Element { fn render(&mut self, cx: &mut gpui::ViewContext<Self>) -> impl IntoElement {
let has_worktree = self.visible_entries.len() != 0; let has_worktree = self.visible_entries.len() != 0;
if has_worktree { if has_worktree {

View file

@ -36,7 +36,7 @@ impl QuickActionBar {
} }
impl Render for QuickActionBar { impl Render for QuickActionBar {
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl Element { fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoElement {
let Some(editor) = self.active_editor() else { let Some(editor) = self.active_editor() else {
return div().id("empty quick action bar"); return div().id("empty quick action bar");
}; };
@ -136,9 +136,7 @@ impl QuickActionBarButton {
} }
impl RenderOnce for QuickActionBarButton { impl RenderOnce for QuickActionBarButton {
type Output = IconButton; fn render(self, _: &mut WindowContext) -> impl IntoElement {
fn render(self, _: &mut WindowContext) -> Self::Output {
let tooltip = self.tooltip.clone(); let tooltip = self.tooltip.clone();
let action = self.action.boxed_clone(); let action = self.action.boxed_clone();

View file

@ -43,9 +43,7 @@ impl HighlightedText {
} }
impl RenderOnce for HighlightedText { impl RenderOnce for HighlightedText {
type Output = HighlightedLabel; fn render(self, _cx: &mut WindowContext) -> impl IntoElement {
fn render(self, _cx: &mut WindowContext) -> Self::Output {
HighlightedLabel::new(self.text, self.highlight_positions) HighlightedLabel::new(self.text, self.highlight_positions)
} }
} }

View file

@ -103,7 +103,7 @@ impl FocusableView for RecentProjects {
} }
impl Render for RecentProjects { impl Render for RecentProjects {
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl Element { fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoElement {
v_stack() v_stack()
.w(rems(self.rem_width)) .w(rems(self.rem_width))
.child(self.picker.clone()) .child(self.picker.clone())

View file

@ -101,7 +101,7 @@ impl BufferSearchBar {
impl EventEmitter<Event> for BufferSearchBar {} impl EventEmitter<Event> for BufferSearchBar {}
impl EventEmitter<workspace::ToolbarItemEvent> for BufferSearchBar {} impl EventEmitter<workspace::ToolbarItemEvent> for BufferSearchBar {}
impl Render for BufferSearchBar { impl Render for BufferSearchBar {
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl Element { fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoElement {
if self.dismissed { if self.dismissed {
return div(); return div();
} }

View file

@ -279,7 +279,7 @@ pub enum ViewEvent {
impl EventEmitter<ViewEvent> for ProjectSearchView {} impl EventEmitter<ViewEvent> for ProjectSearchView {}
impl Render for ProjectSearchView { impl Render for ProjectSearchView {
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl Element { fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoElement {
if self.has_matches() { if self.has_matches() {
div() div()
.flex_1() .flex_1()
@ -1548,7 +1548,7 @@ impl ProjectSearchBar {
} }
impl Render for ProjectSearchBar { impl Render for ProjectSearchBar {
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl Element { fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoElement {
let Some(search) = self.active_project_search.clone() else { let Some(search) = self.active_project_search.clone() else {
return div(); return div();
}; };

View file

@ -1,6 +1,5 @@
use gpui::{ use gpui::{
div, hsla, prelude::*, px, rems, AnyElement, Div, ElementId, Hsla, SharedString, Stateful, div, hsla, prelude::*, px, rems, AnyElement, Div, ElementId, Hsla, SharedString, WindowContext,
WindowContext,
}; };
use itertools::Itertools; use itertools::Itertools;
use smallvec::SmallVec; use smallvec::SmallVec;
@ -74,9 +73,7 @@ impl ParentElement for StoryContainer {
} }
impl RenderOnce for StoryContainer { impl RenderOnce for StoryContainer {
type Output = Stateful<Div>; fn render(self, _cx: &mut WindowContext) -> impl IntoElement {
fn render(self, _cx: &mut WindowContext) -> Self::Output {
div() div()
.size_full() .size_full()
.flex() .flex()
@ -294,9 +291,7 @@ impl StoryItem {
} }
impl RenderOnce for StoryItem { impl RenderOnce for StoryItem {
type Output = Div; fn render(self, _cx: &mut WindowContext) -> impl IntoElement {
fn render(self, _cx: &mut WindowContext) -> Self::Output {
div() div()
.my_2() .my_2()
.flex() .flex()
@ -358,9 +353,7 @@ impl StorySection {
} }
impl RenderOnce for StorySection { impl RenderOnce for StorySection {
type Output = Div; fn render(self, _cx: &mut WindowContext) -> impl IntoElement {
fn render(self, _cx: &mut WindowContext) -> Self::Output {
let children: SmallVec<[AnyElement; 2]> = SmallVec::from_iter(Itertools::intersperse_with( let children: SmallVec<[AnyElement; 2]> = SmallVec::from_iter(Itertools::intersperse_with(
self.children.into_iter(), self.children.into_iter(),
|| Story::divider().into_any_element(), || Story::divider().into_any_element(),

View file

@ -1,6 +1,6 @@
use editor::Editor; use editor::Editor;
use gpui::{ use gpui::{
div, white, Element, KeyBinding, ParentElement, Render, Styled, View, ViewContext, div, white, IntoElement, KeyBinding, ParentElement, Render, Styled, View, ViewContext,
VisualContext, WindowContext, VisualContext, WindowContext,
}; };
@ -22,7 +22,7 @@ impl AutoHeightEditorStory {
} }
impl Render for AutoHeightEditorStory { impl Render for AutoHeightEditorStory {
fn render(&mut self, _cx: &mut ViewContext<Self>) -> impl Element { fn render(&mut self, _cx: &mut ViewContext<Self>) -> impl IntoElement {
div() div()
.size_full() .size_full()
.bg(white()) .bg(white())

View file

@ -5,7 +5,7 @@ use ui::prelude::*;
pub struct CursorStory; pub struct CursorStory;
impl Render for CursorStory { impl Render for CursorStory {
fn render(&mut self, _cx: &mut ViewContext<Self>) -> impl Element { fn render(&mut self, _cx: &mut ViewContext<Self>) -> impl IntoElement {
let all_cursors: [(&str, Box<dyn Fn(Stateful<Div>) -> Stateful<Div>>); 19] = [ let all_cursors: [(&str, Box<dyn Fn(Stateful<Div>) -> Stateful<Div>>); 19] = [
( (
"cursor_default", "cursor_default",

View file

@ -56,7 +56,7 @@ impl FocusStory {
} }
impl Render for FocusStory { impl Render for FocusStory {
fn render(&mut self, cx: &mut gpui::ViewContext<Self>) -> impl Element { fn render(&mut self, cx: &mut gpui::ViewContext<Self>) -> impl IntoElement {
let theme = cx.theme(); let theme = cx.theme();
let color_1 = theme.status().created; let color_1 = theme.status().created;
let color_2 = theme.status().modified; let color_2 = theme.status().modified;

View file

@ -14,7 +14,7 @@ impl KitchenSinkStory {
} }
impl Render for KitchenSinkStory { impl Render for KitchenSinkStory {
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl Element { fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoElement {
let component_stories = ComponentStory::iter() let component_stories = ComponentStory::iter()
.map(|selector| selector.story(cx)) .map(|selector| selector.story(cx))
.collect::<Vec<_>>(); .collect::<Vec<_>>();

View file

@ -6,7 +6,7 @@ use ui::prelude::*;
pub struct OverflowScrollStory; pub struct OverflowScrollStory;
impl Render for OverflowScrollStory { impl Render for OverflowScrollStory {
fn render(&mut self, _cx: &mut ViewContext<Self>) -> impl Element { fn render(&mut self, _cx: &mut ViewContext<Self>) -> impl IntoElement {
Story::container() Story::container()
.child(Story::title("Overflow Scroll")) .child(Story::title("Overflow Scroll"))
.child(Story::label("`overflow_x_scroll`")) .child(Story::label("`overflow_x_scroll`"))

View file

@ -200,7 +200,7 @@ impl PickerStory {
} }
impl Render for PickerStory { impl Render for PickerStory {
fn render(&mut self, cx: &mut gpui::ViewContext<Self>) -> impl Element { fn render(&mut self, cx: &mut gpui::ViewContext<Self>) -> impl IntoElement {
div() div()
.bg(cx.theme().styles.colors.background) .bg(cx.theme().styles.colors.background)
.size_full() .size_full()

View file

@ -11,7 +11,7 @@ impl ScrollStory {
} }
impl Render for ScrollStory { impl Render for ScrollStory {
fn render(&mut self, cx: &mut gpui::ViewContext<Self>) -> impl Element { fn render(&mut self, cx: &mut gpui::ViewContext<Self>) -> impl IntoElement {
let theme = cx.theme(); let theme = cx.theme();
let color_1 = theme.status().created; let color_1 = theme.status().created;
let color_2 = theme.status().modified; let color_2 = theme.status().modified;

View file

@ -1,6 +1,6 @@
use gpui::{ use gpui::{
div, green, red, Element, HighlightStyle, InteractiveText, IntoElement, ParentElement, Render, div, green, red, HighlightStyle, InteractiveText, IntoElement, ParentElement, Render, Styled,
Styled, StyledText, View, VisualContext, WindowContext, StyledText, View, VisualContext, WindowContext,
}; };
use indoc::indoc; use indoc::indoc;
use story::*; use story::*;
@ -14,7 +14,7 @@ impl TextStory {
} }
impl Render for TextStory { impl Render for TextStory {
fn render(&mut self, cx: &mut gpui::ViewContext<Self>) -> impl Element { fn render(&mut self, cx: &mut gpui::ViewContext<Self>) -> impl IntoElement {
StoryContainer::new("Text Story", "crates/storybook2/src/stories/text.rs") StoryContainer::new("Text Story", "crates/storybook2/src/stories/text.rs")
.children( .children(
vec![ vec![

View file

@ -6,7 +6,7 @@ use ui::prelude::*;
pub struct ViewportUnitsStory; pub struct ViewportUnitsStory;
impl Render for ViewportUnitsStory { impl Render for ViewportUnitsStory {
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl Element { fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoElement {
Story::container().child( Story::container().child(
div() div()
.flex() .flex()

View file

@ -7,7 +7,7 @@ use ui::prelude::*;
pub struct ZIndexStory; pub struct ZIndexStory;
impl Render for ZIndexStory { impl Render for ZIndexStory {
fn render(&mut self, _cx: &mut ViewContext<Self>) -> impl Element { fn render(&mut self, _cx: &mut ViewContext<Self>) -> impl IntoElement {
Story::container().child(Story::title("z-index")).child( Story::container().child(Story::title("z-index")).child(
div() div()
.flex() .flex()
@ -80,9 +80,7 @@ struct ZIndexExample {
} }
impl RenderOnce for ZIndexExample { impl RenderOnce for ZIndexExample {
type Output = Div; fn render(self, _cx: &mut WindowContext) -> impl IntoElement {
fn render(self, _cx: &mut WindowContext) -> Self::Output {
div() div()
.relative() .relative()
.size_full() .size_full()

View file

@ -113,7 +113,7 @@ impl StoryWrapper {
} }
impl Render for StoryWrapper { impl Render for StoryWrapper {
fn render(&mut self, _cx: &mut ViewContext<Self>) -> impl Element { fn render(&mut self, _cx: &mut ViewContext<Self>) -> impl IntoElement {
div() div()
.flex() .flex()
.flex_col() .flex_col()

View file

@ -3,9 +3,9 @@ use std::{path::PathBuf, sync::Arc};
use crate::TerminalView; use crate::TerminalView;
use db::kvp::KEY_VALUE_STORE; use db::kvp::KEY_VALUE_STORE;
use gpui::{ use gpui::{
actions, div, serde_json, AppContext, AsyncWindowContext, Element, Entity, EventEmitter, actions, div, serde_json, AppContext, AsyncWindowContext, Entity, EventEmitter, ExternalPaths,
ExternalPaths, FocusHandle, FocusableView, IntoElement, ParentElement, Pixels, Render, Styled, FocusHandle, FocusableView, IntoElement, ParentElement, Pixels, Render, Styled, Subscription,
Subscription, Task, View, ViewContext, VisualContext, WeakView, WindowContext, Task, View, ViewContext, VisualContext, WeakView, WindowContext,
}; };
use project::Fs; use project::Fs;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
@ -329,7 +329,7 @@ impl TerminalPanel {
impl EventEmitter<PanelEvent> for TerminalPanel {} impl EventEmitter<PanelEvent> for TerminalPanel {}
impl Render for TerminalPanel { impl Render for TerminalPanel {
fn render(&mut self, _cx: &mut ViewContext<Self>) -> impl Element { fn render(&mut self, _cx: &mut ViewContext<Self>) -> impl IntoElement {
div().size_full().child(self.pane.clone()) div().size_full().child(self.pane.clone())
} }
} }

View file

@ -617,7 +617,7 @@ impl TerminalView {
} }
impl Render for TerminalView { impl Render for TerminalView {
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl Element { fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoElement {
let terminal_handle = self.terminal.clone(); let terminal_handle = self.terminal.clone();
let focused = self.focus_handle.is_focused(cx); let focused = self.focus_handle.is_focused(cx);

View file

@ -7,7 +7,7 @@ use crate::{default_color_scales, ColorScaleStep};
pub struct ColorsStory; pub struct ColorsStory;
impl Render for ColorsStory { impl Render for ColorsStory {
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl Element { fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoElement {
let color_scales = default_color_scales(); let color_scales = default_color_scales();
Story::container().child(Story::title("Colors")).child( Story::container().child(Story::title("Colors")).child(

View file

@ -1,4 +1,4 @@
use gpui::{div, img, px, Element, ParentElement, Render, Styled, ViewContext}; use gpui::{div, img, px, IntoElement, ParentElement, Render, Styled, ViewContext};
use story::Story; use story::Story;
use crate::{ActiveTheme, PlayerColors}; use crate::{ActiveTheme, PlayerColors};
@ -6,7 +6,7 @@ use crate::{ActiveTheme, PlayerColors};
pub struct PlayerStory; pub struct PlayerStory;
impl Render for PlayerStory { impl Render for PlayerStory {
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl Element { fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoElement {
Story::container().child( Story::container().child(
div() div()
.flex() .flex()

View file

@ -69,7 +69,7 @@ impl FocusableView for ThemeSelector {
} }
impl Render for ThemeSelector { impl Render for ThemeSelector {
fn render(&mut self, _cx: &mut ViewContext<Self>) -> impl Element { fn render(&mut self, _cx: &mut ViewContext<Self>) -> impl IntoElement {
v_stack().w(rems(34.)).child(self.picker.clone()) v_stack().w(rems(34.)).child(self.picker.clone())
} }
} }

View file

@ -1,5 +1,5 @@
use crate::prelude::*; use crate::prelude::*;
use gpui::{img, Div, Hsla, ImageSource, Img, IntoElement, Styled}; use gpui::{img, Hsla, ImageSource, Img, IntoElement, Styled};
#[derive(Debug, Default, PartialEq, Clone)] #[derive(Debug, Default, PartialEq, Clone)]
pub enum Shape { pub enum Shape {
@ -16,9 +16,7 @@ pub struct Avatar {
} }
impl RenderOnce for Avatar { impl RenderOnce for Avatar {
type Output = Div; fn render(mut self, cx: &mut WindowContext) -> impl IntoElement {
fn render(mut self, cx: &mut WindowContext) -> Self::Output {
if self.image.style().corner_radii.top_left.is_none() { if self.image.style().corner_radii.top_left.is_none() {
self = self.shape(Shape::Circle); self = self.shape(Shape::Circle);
} }

View file

@ -136,9 +136,8 @@ impl ButtonCommon for Button {
} }
impl RenderOnce for Button { impl RenderOnce for Button {
type Output = ButtonLike; #[allow(refining_impl_trait)]
fn render(self, _cx: &mut WindowContext) -> ButtonLike {
fn render(self, _cx: &mut WindowContext) -> Self::Output {
let is_disabled = self.base.disabled; let is_disabled = self.base.disabled;
let is_selected = self.base.selected; let is_selected = self.base.selected;

View file

@ -63,9 +63,7 @@ impl Selectable for ButtonIcon {
} }
impl RenderOnce for ButtonIcon { impl RenderOnce for ButtonIcon {
type Output = IconElement; fn render(self, _cx: &mut WindowContext) -> impl IntoElement {
fn render(self, _cx: &mut WindowContext) -> Self::Output {
let icon = self let icon = self
.selected_icon .selected_icon
.filter(|_| self.selected) .filter(|_| self.selected)

View file

@ -1,5 +1,5 @@
use gpui::{relative, DefiniteLength, MouseButton}; use gpui::{relative, DefiniteLength, MouseButton};
use gpui::{rems, transparent_black, AnyElement, AnyView, ClickEvent, Div, Hsla, Rems, Stateful}; use gpui::{rems, transparent_black, AnyElement, AnyView, ClickEvent, Hsla, Rems};
use smallvec::SmallVec; use smallvec::SmallVec;
use crate::prelude::*; use crate::prelude::*;
@ -363,9 +363,7 @@ impl ParentElement for ButtonLike {
} }
impl RenderOnce for ButtonLike { impl RenderOnce for ButtonLike {
type Output = Stateful<Div>; fn render(self, cx: &mut WindowContext) -> impl IntoElement {
fn render(self, cx: &mut WindowContext) -> Self::Output {
self.base self.base
.h_flex() .h_flex()
.id(self.id.clone()) .id(self.id.clone())

View file

@ -106,9 +106,7 @@ impl VisibleOnHover for IconButton {
} }
impl RenderOnce for IconButton { impl RenderOnce for IconButton {
type Output = ButtonLike; fn render(self, _cx: &mut WindowContext) -> impl IntoElement {
fn render(self, _cx: &mut WindowContext) -> Self::Output {
let is_disabled = self.base.disabled; let is_disabled = self.base.disabled;
let is_selected = self.base.selected; let is_selected = self.base.selected;

View file

@ -99,9 +99,7 @@ impl ButtonCommon for ToggleButton {
} }
impl RenderOnce for ToggleButton { impl RenderOnce for ToggleButton {
type Output = ButtonLike; fn render(self, _cx: &mut WindowContext) -> impl IntoElement {
fn render(self, _cx: &mut WindowContext) -> Self::Output {
let is_disabled = self.base.disabled; let is_disabled = self.base.disabled;
let is_selected = self.base.selected; let is_selected = self.base.selected;

View file

@ -1,4 +1,4 @@
use gpui::{div, prelude::*, Div, Element, ElementId, IntoElement, Styled, WindowContext}; use gpui::{div, prelude::*, Element, ElementId, IntoElement, Styled, WindowContext};
use crate::prelude::*; use crate::prelude::*;
use crate::{Color, Icon, IconElement, Selection}; use crate::{Color, Icon, IconElement, Selection};
@ -19,9 +19,7 @@ pub struct Checkbox {
} }
impl RenderOnce for Checkbox { impl RenderOnce for Checkbox {
type Output = gpui::Stateful<Div>; fn render(self, cx: &mut WindowContext) -> impl IntoElement {
fn render(self, cx: &mut WindowContext) -> Self::Output {
let group_id = format!("checkbox_group_{:?}", self.id); let group_id = format!("checkbox_group_{:?}", self.id);
let icon = match self.checked { let icon = match self.checked {

View file

@ -232,7 +232,7 @@ impl ContextMenuItem {
} }
impl Render for ContextMenu { impl Render for ContextMenu {
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl Element { fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoElement {
div().elevation_2(cx).flex().flex_row().child( div().elevation_2(cx).flex().flex_row().child(
v_stack() v_stack()
.min_w(px(200.)) .min_w(px(200.))

View file

@ -28,9 +28,7 @@ impl Disclosure {
} }
impl RenderOnce for Disclosure { impl RenderOnce for Disclosure {
type Output = IconButton; fn render(self, _cx: &mut WindowContext) -> impl IntoElement {
fn render(self, _cx: &mut WindowContext) -> Self::Output {
IconButton::new( IconButton::new(
self.id, self.id,
match self.is_open { match self.is_open {

View file

@ -1,4 +1,4 @@
use gpui::{Div, Hsla, IntoElement}; use gpui::{Hsla, IntoElement};
use crate::prelude::*; use crate::prelude::*;
@ -31,9 +31,7 @@ pub struct Divider {
} }
impl RenderOnce for Divider { impl RenderOnce for Divider {
type Output = Div; fn render(self, cx: &mut WindowContext) -> impl IntoElement {
fn render(self, cx: &mut WindowContext) -> Self::Output {
div() div()
.map(|this| match self.direction { .map(|this| match self.direction {
DividerDirection::Horizontal => { DividerDirection::Horizontal => {

View file

@ -1,4 +1,4 @@
use gpui::{rems, svg, IntoElement, Rems, Svg}; use gpui::{rems, svg, IntoElement, Rems};
use strum::EnumIter; use strum::EnumIter;
use crate::prelude::*; use crate::prelude::*;
@ -200,9 +200,7 @@ pub struct IconElement {
} }
impl RenderOnce for IconElement { impl RenderOnce for IconElement {
type Output = Svg; fn render(self, cx: &mut WindowContext) -> impl IntoElement {
fn render(self, cx: &mut WindowContext) -> Self::Output {
svg() svg()
.size(self.size.rems()) .size(self.size.rems())
.flex_none() .flex_none()

View file

@ -1,4 +1,4 @@
use gpui::{Div, Position}; use gpui::Position;
use crate::prelude::*; use crate::prelude::*;
@ -45,9 +45,7 @@ impl Indicator {
} }
impl RenderOnce for Indicator { impl RenderOnce for Indicator {
type Output = Div; fn render(self, cx: &mut WindowContext) -> impl IntoElement {
fn render(self, cx: &mut WindowContext) -> Self::Output {
div() div()
.flex_none() .flex_none()
.map(|this| match self.style { .map(|this| match self.style {

View file

@ -1,5 +1,5 @@
use crate::{h_stack, prelude::*, Icon, IconElement, IconSize}; use crate::{h_stack, prelude::*, Icon, IconElement, IconSize};
use gpui::{relative, rems, Action, Div, FocusHandle, IntoElement, Keystroke}; use gpui::{relative, rems, Action, FocusHandle, IntoElement, Keystroke};
#[derive(IntoElement, Clone)] #[derive(IntoElement, Clone)]
pub struct KeyBinding { pub struct KeyBinding {
@ -11,9 +11,7 @@ pub struct KeyBinding {
} }
impl RenderOnce for KeyBinding { impl RenderOnce for KeyBinding {
type Output = Div; fn render(self, cx: &mut WindowContext) -> impl IntoElement {
fn render(self, cx: &mut WindowContext) -> Self::Output {
h_stack() h_stack()
.flex_none() .flex_none()
.gap_2() .gap_2()
@ -87,9 +85,7 @@ pub struct Key {
} }
impl RenderOnce for Key { impl RenderOnce for Key {
type Output = Div; fn render(self, cx: &mut WindowContext) -> impl IntoElement {
fn render(self, cx: &mut WindowContext) -> Self::Output {
let single_char = self.key.len() == 1; let single_char = self.key.len() == 1;
div() div()
@ -121,9 +117,7 @@ pub struct KeyIcon {
} }
impl RenderOnce for KeyIcon { impl RenderOnce for KeyIcon {
type Output = Div; fn render(self, _cx: &mut WindowContext) -> impl IntoElement {
fn render(self, _cx: &mut WindowContext) -> Self::Output {
div() div()
.w(rems(14. / 16.)) .w(rems(14. / 16.))
.child(IconElement::new(self.icon).size(IconSize::Small)) .child(IconElement::new(self.icon).size(IconSize::Small))

View file

@ -46,9 +46,7 @@ impl LabelCommon for HighlightedLabel {
} }
impl RenderOnce for HighlightedLabel { impl RenderOnce for HighlightedLabel {
type Output = LabelLike; fn render(self, cx: &mut WindowContext) -> impl IntoElement {
fn render(self, cx: &mut WindowContext) -> Self::Output {
let highlight_color = cx.theme().colors().text_accent; let highlight_color = cx.theme().colors().text_accent;
let mut highlight_indices = self.highlight_indices.iter().copied().peekable(); let mut highlight_indices = self.highlight_indices.iter().copied().peekable();

View file

@ -40,9 +40,7 @@ impl LabelCommon for Label {
} }
impl RenderOnce for Label { impl RenderOnce for Label {
type Output = LabelLike; fn render(self, _cx: &mut WindowContext) -> impl IntoElement {
fn render(self, _cx: &mut WindowContext) -> Self::Output {
self.base.child(self.label) self.base.child(self.label)
} }
} }

View file

@ -1,4 +1,4 @@
use gpui::{relative, AnyElement, Div, Styled}; use gpui::{relative, AnyElement, Styled};
use smallvec::SmallVec; use smallvec::SmallVec;
use crate::prelude::*; use crate::prelude::*;
@ -76,9 +76,7 @@ impl ParentElement for LabelLike {
} }
impl RenderOnce for LabelLike { impl RenderOnce for LabelLike {
type Output = Div; fn render(self, cx: &mut WindowContext) -> impl IntoElement {
fn render(self, cx: &mut WindowContext) -> Self::Output {
div() div()
.when(self.strikethrough, |this| { .when(self.strikethrough, |this| {
this.relative().child( this.relative().child(

View file

@ -1,4 +1,4 @@
use gpui::{AnyElement, Div}; use gpui::AnyElement;
use smallvec::SmallVec; use smallvec::SmallVec;
use crate::{prelude::*, v_stack, Label, ListHeader}; use crate::{prelude::*, v_stack, Label, ListHeader};
@ -46,9 +46,7 @@ impl ParentElement for List {
} }
impl RenderOnce for List { impl RenderOnce for List {
type Output = Div; fn render(self, _cx: &mut WindowContext) -> impl IntoElement {
fn render(self, _cx: &mut WindowContext) -> Self::Output {
v_stack().w_full().py_1().children(self.header).map(|this| { v_stack().w_full().py_1().children(self.header).map(|this| {
match (self.children.is_empty(), self.toggle) { match (self.children.is_empty(), self.toggle) {
(false, _) => this.children(self.children), (false, _) => this.children(self.children),

View file

@ -1,6 +1,5 @@
use gpui::{AnyElement, ClickEvent, Div, Stateful};
use crate::{h_stack, prelude::*, Disclosure, Label}; use crate::{h_stack, prelude::*, Disclosure, Label};
use gpui::{AnyElement, ClickEvent};
#[derive(IntoElement)] #[derive(IntoElement)]
pub struct ListHeader { pub struct ListHeader {
@ -76,9 +75,7 @@ impl Selectable for ListHeader {
} }
impl RenderOnce for ListHeader { impl RenderOnce for ListHeader {
type Output = Stateful<Div>; fn render(self, cx: &mut WindowContext) -> impl IntoElement {
fn render(self, cx: &mut WindowContext) -> Self::Output {
h_stack() h_stack()
.id(self.label.clone()) .id(self.label.clone())
.w_full() .w_full()

View file

@ -1,6 +1,4 @@
use gpui::{ use gpui::{px, AnyElement, AnyView, ClickEvent, MouseButton, MouseDownEvent, Pixels};
px, AnyElement, AnyView, ClickEvent, Div, MouseButton, MouseDownEvent, Pixels, Stateful,
};
use smallvec::SmallVec; use smallvec::SmallVec;
use crate::{prelude::*, Disclosure}; use crate::{prelude::*, Disclosure};
@ -147,9 +145,7 @@ impl ParentElement for ListItem {
} }
impl RenderOnce for ListItem { impl RenderOnce for ListItem {
type Output = Stateful<Div>; fn render(self, cx: &mut WindowContext) -> impl IntoElement {
fn render(self, cx: &mut WindowContext) -> Self::Output {
h_stack() h_stack()
.id(self.id) .id(self.id)
.w_full() .w_full()

View file

@ -1,14 +1,10 @@
use gpui::Div;
use crate::prelude::*; use crate::prelude::*;
#[derive(IntoElement)] #[derive(IntoElement)]
pub struct ListSeparator; pub struct ListSeparator;
impl RenderOnce for ListSeparator { impl RenderOnce for ListSeparator {
type Output = Div; fn render(self, cx: &mut WindowContext) -> impl IntoElement {
fn render(self, cx: &mut WindowContext) -> Self::Output {
div() div()
.h_px() .h_px()
.w_full() .w_full()

View file

@ -1,5 +1,3 @@
use gpui::Div;
use crate::prelude::*; use crate::prelude::*;
use crate::{h_stack, Icon, IconElement, IconSize, Label}; use crate::{h_stack, Icon, IconElement, IconSize, Label};
@ -26,9 +24,7 @@ impl ListSubHeader {
} }
impl RenderOnce for ListSubHeader { impl RenderOnce for ListSubHeader {
type Output = Div; fn render(self, _cx: &mut WindowContext) -> impl IntoElement {
fn render(self, _cx: &mut WindowContext) -> Self::Output {
h_stack().flex_1().w_full().relative().py_1().child( h_stack().flex_1().w_full().relative().py_1().child(
div() div()
.h_6() .h_6()

View file

@ -1,5 +1,5 @@
use gpui::{ use gpui::{
div, AnyElement, Div, Element, ElementId, IntoElement, ParentElement, RenderOnce, Styled, div, AnyElement, Element, ElementId, IntoElement, ParentElement, RenderOnce, Styled,
WindowContext, WindowContext,
}; };
use smallvec::SmallVec; use smallvec::SmallVec;
@ -41,9 +41,7 @@ pub struct Popover {
} }
impl RenderOnce for Popover { impl RenderOnce for Popover {
type Output = Div; fn render(self, cx: &mut WindowContext) -> impl IntoElement {
fn render(self, cx: &mut WindowContext) -> Self::Output {
div() div()
.flex() .flex()
.gap_1() .gap_1()

View file

@ -153,7 +153,7 @@ impl<M: ManagedView> Element for PopoverMenu<M> {
} }
let mut element = overlay.child(menu.clone()).into_any(); let mut element = overlay.child(menu.clone()).into_any();
menu_layout_id = Some(element.layout(cx)); menu_layout_id = Some(element.request_layout(cx));
element element
}); });
@ -164,7 +164,7 @@ impl<M: ManagedView> Element for PopoverMenu<M> {
let child_layout_id = child_element let child_layout_id = child_element
.as_mut() .as_mut()
.map(|child_element| child_element.layout(cx)); .map(|child_element| child_element.request_layout(cx));
let layout_id = cx.request_layout( let layout_id = cx.request_layout(
&gpui::Style::default(), &gpui::Style::default(),

View file

@ -81,7 +81,7 @@ impl<M: ManagedView> Element for RightClickMenu<M> {
overlay = overlay.position(*position.borrow()); overlay = overlay.position(*position.borrow());
let mut element = overlay.child(menu.clone()).into_any(); let mut element = overlay.child(menu.clone()).into_any();
menu_layout_id = Some(element.layout(cx)); menu_layout_id = Some(element.request_layout(cx));
element element
}); });
@ -92,7 +92,7 @@ impl<M: ManagedView> Element for RightClickMenu<M> {
let child_layout_id = child_element let child_layout_id = child_element
.as_mut() .as_mut()
.map(|child_element| child_element.layout(cx)); .map(|child_element| child_element.request_layout(cx));
let layout_id = cx.request_layout( let layout_id = cx.request_layout(
&gpui::Style::default(), &gpui::Style::default(),

View file

@ -7,7 +7,7 @@ use crate::Avatar;
pub struct AvatarStory; pub struct AvatarStory;
impl Render for AvatarStory { impl Render for AvatarStory {
fn render(&mut self, _cx: &mut ViewContext<Self>) -> impl Element { fn render(&mut self, _cx: &mut ViewContext<Self>) -> impl IntoElement {
Story::container() Story::container()
.child(Story::title_for::<Avatar>()) .child(Story::title_for::<Avatar>())
.child(Story::label("Default")) .child(Story::label("Default"))

View file

@ -7,7 +7,7 @@ use crate::{Button, ButtonStyle};
pub struct ButtonStory; pub struct ButtonStory;
impl Render for ButtonStory { impl Render for ButtonStory {
fn render(&mut self, _cx: &mut ViewContext<Self>) -> impl Element { fn render(&mut self, _cx: &mut ViewContext<Self>) -> impl IntoElement {
Story::container() Story::container()
.child(Story::title_for::<Button>()) .child(Story::title_for::<Button>())
.child(Story::label("Default")) .child(Story::label("Default"))

View file

@ -7,7 +7,7 @@ use crate::{h_stack, Checkbox};
pub struct CheckboxStory; pub struct CheckboxStory;
impl Render for CheckboxStory { impl Render for CheckboxStory {
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl Element { fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoElement {
Story::container() Story::container()
.child(Story::title_for::<Checkbox>()) .child(Story::title_for::<Checkbox>())
.child(Story::label("Default")) .child(Story::label("Default"))

View file

@ -20,7 +20,7 @@ fn build_menu(cx: &mut WindowContext, header: impl Into<SharedString>) -> View<C
pub struct ContextMenuStory; pub struct ContextMenuStory;
impl Render for ContextMenuStory { impl Render for ContextMenuStory {
fn render(&mut self, _cx: &mut ViewContext<Self>) -> impl Element { fn render(&mut self, _cx: &mut ViewContext<Self>) -> impl IntoElement {
Story::container() Story::container()
.on_action(|_: &PrintCurrentDate, _| { .on_action(|_: &PrintCurrentDate, _| {
println!("printing unix time!"); println!("printing unix time!");

View file

@ -7,7 +7,7 @@ use crate::Disclosure;
pub struct DisclosureStory; pub struct DisclosureStory;
impl Render for DisclosureStory { impl Render for DisclosureStory {
fn render(&mut self, _cx: &mut ViewContext<Self>) -> impl Element { fn render(&mut self, _cx: &mut ViewContext<Self>) -> impl IntoElement {
Story::container() Story::container()
.child(Story::title_for::<Disclosure>()) .child(Story::title_for::<Disclosure>())
.child(Story::label("Toggled")) .child(Story::label("Toggled"))

View file

@ -8,7 +8,7 @@ use crate::{Icon, IconElement};
pub struct IconStory; pub struct IconStory;
impl Render for IconStory { impl Render for IconStory {
fn render(&mut self, _cx: &mut ViewContext<Self>) -> impl Element { fn render(&mut self, _cx: &mut ViewContext<Self>) -> impl IntoElement {
let icons = Icon::iter(); let icons = Icon::iter();
Story::container() Story::container()

View file

@ -7,7 +7,7 @@ use crate::{Icon, IconButton};
pub struct IconButtonStory; pub struct IconButtonStory;
impl Render for IconButtonStory { impl Render for IconButtonStory {
fn render(&mut self, _cx: &mut ViewContext<Self>) -> impl Element { fn render(&mut self, _cx: &mut ViewContext<Self>) -> impl IntoElement {
let default_button = StoryItem::new( let default_button = StoryItem::new(
"Default", "Default",
IconButton::new("default_icon_button", Icon::Hash), IconButton::new("default_icon_button", Icon::Hash),

View file

@ -13,7 +13,7 @@ pub fn binding(key: &str) -> gpui::KeyBinding {
} }
impl Render for KeybindingStory { impl Render for KeybindingStory {
fn render(&mut self, _cx: &mut ViewContext<Self>) -> impl Element { fn render(&mut self, _cx: &mut ViewContext<Self>) -> impl IntoElement {
let all_modifier_permutations = ["ctrl", "alt", "cmd", "shift"].into_iter().permutations(2); let all_modifier_permutations = ["ctrl", "alt", "cmd", "shift"].into_iter().permutations(2);
Story::container() Story::container()

View file

@ -5,7 +5,7 @@ use story::Story;
pub struct LabelStory; pub struct LabelStory;
impl Render for LabelStory { impl Render for LabelStory {
fn render(&mut self, _cx: &mut ViewContext<Self>) -> impl Element { fn render(&mut self, _cx: &mut ViewContext<Self>) -> impl IntoElement {
Story::container() Story::container()
.child(Story::title_for::<Label>()) .child(Story::title_for::<Label>())
.child(Story::label("Default")) .child(Story::label("Default"))

View file

@ -7,7 +7,7 @@ use crate::{List, ListItem};
pub struct ListStory; pub struct ListStory;
impl Render for ListStory { impl Render for ListStory {
fn render(&mut self, _cx: &mut ViewContext<Self>) -> impl Element { fn render(&mut self, _cx: &mut ViewContext<Self>) -> impl IntoElement {
Story::container() Story::container()
.child(Story::title_for::<List>()) .child(Story::title_for::<List>())
.child(Story::label("Default")) .child(Story::label("Default"))

View file

@ -7,7 +7,7 @@ use crate::{Icon, ListHeader};
pub struct ListHeaderStory; pub struct ListHeaderStory;
impl Render for ListHeaderStory { impl Render for ListHeaderStory {
fn render(&mut self, _cx: &mut ViewContext<Self>) -> impl Element { fn render(&mut self, _cx: &mut ViewContext<Self>) -> impl IntoElement {
Story::container() Story::container()
.child(Story::title_for::<ListHeader>()) .child(Story::title_for::<ListHeader>())
.child(Story::label("Default")) .child(Story::label("Default"))

View file

@ -7,7 +7,7 @@ use crate::{Icon, ListItem};
pub struct ListItemStory; pub struct ListItemStory;
impl Render for ListItemStory { impl Render for ListItemStory {
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl Element { fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoElement {
Story::container() Story::container()
.bg(cx.theme().colors().background) .bg(cx.theme().colors().background)
.child(Story::title_for::<ListItem>()) .child(Story::title_for::<ListItem>())

View file

@ -9,7 +9,7 @@ use crate::{Indicator, Tab};
pub struct TabStory; pub struct TabStory;
impl Render for TabStory { impl Render for TabStory {
fn render(&mut self, _cx: &mut ViewContext<Self>) -> impl Element { fn render(&mut self, _cx: &mut ViewContext<Self>) -> impl IntoElement {
Story::container() Story::container()
.child(Story::title_for::<Tab>()) .child(Story::title_for::<Tab>())
.child(Story::label("Default")) .child(Story::label("Default"))

View file

@ -6,7 +6,7 @@ use crate::{prelude::*, Tab, TabBar, TabPosition};
pub struct TabBarStory; pub struct TabBarStory;
impl Render for TabBarStory { impl Render for TabBarStory {
fn render(&mut self, _cx: &mut ViewContext<Self>) -> impl Element { fn render(&mut self, _cx: &mut ViewContext<Self>) -> impl IntoElement {
let tab_count = 20; let tab_count = 20;
let selected_tab_index = 3; let selected_tab_index = 3;

View file

@ -6,7 +6,7 @@ use crate::{prelude::*, ToggleButton};
pub struct ToggleButtonStory; pub struct ToggleButtonStory;
impl Render for ToggleButtonStory { impl Render for ToggleButtonStory {
fn render(&mut self, _cx: &mut ViewContext<Self>) -> impl Element { fn render(&mut self, _cx: &mut ViewContext<Self>) -> impl IntoElement {
StoryContainer::new( StoryContainer::new(
"Toggle Button", "Toggle Button",
"crates/ui2/src/components/stories/toggle_button.rs", "crates/ui2/src/components/stories/toggle_button.rs",

Some files were not shown because too many files have changed in this diff Show more