Replace derive Element with derive IntoAnyElement everywhere
This commit is contained in:
parent
315744ec20
commit
8ecfea55cd
45 changed files with 185 additions and 292 deletions
|
@ -5,7 +5,7 @@ use gpui2::{rems, AbsoluteLength};
|
|||
use crate::prelude::*;
|
||||
use crate::{Icon, IconButton, Label, Panel, PanelSide};
|
||||
|
||||
#[derive(Element)]
|
||||
#[derive(IntoAnyElement)]
|
||||
pub struct AssistantPanel<S: 'static + Send + Sync> {
|
||||
id: ElementId,
|
||||
state_type: PhantomData<S>,
|
||||
|
@ -26,7 +26,7 @@ impl<S: 'static + Send + Sync> AssistantPanel<S> {
|
|||
self
|
||||
}
|
||||
|
||||
fn render(&mut self, view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
Panel::new(self.id.clone(), cx)
|
||||
.children(vec![div()
|
||||
.flex()
|
||||
|
@ -84,7 +84,7 @@ mod stories {
|
|||
|
||||
use super::*;
|
||||
|
||||
#[derive(Element)]
|
||||
#[derive(IntoAnyElement)]
|
||||
pub struct AssistantPanelStory<S: 'static + Send + Sync> {
|
||||
state_type: PhantomData<S>,
|
||||
}
|
||||
|
@ -96,7 +96,7 @@ mod stories {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
Story::container(cx)
|
||||
.child(Story::title_for::<_, AssistantPanel<S>>(cx))
|
||||
.child(Story::label(cx, "Default"))
|
||||
|
|
|
@ -9,7 +9,7 @@ use crate::{h_stack, HighlightedText};
|
|||
#[derive(Clone)]
|
||||
pub struct Symbol(pub Vec<HighlightedText>);
|
||||
|
||||
#[derive(Element)]
|
||||
#[derive(IntoAnyElement)]
|
||||
pub struct Breadcrumb<S: 'static + Send + Sync> {
|
||||
state_type: PhantomData<S>,
|
||||
path: PathBuf,
|
||||
|
@ -31,7 +31,7 @@ impl<S: 'static + Send + Sync> Breadcrumb<S> {
|
|||
div().child(" › ").text_color(theme.text_muted)
|
||||
}
|
||||
|
||||
fn render(&mut self, view_state: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, view_state: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
let theme = theme(cx);
|
||||
|
||||
let symbols_len = self.symbols.len();
|
||||
|
@ -86,7 +86,7 @@ mod stories {
|
|||
|
||||
use super::*;
|
||||
|
||||
#[derive(Element)]
|
||||
#[derive(IntoAnyElement)]
|
||||
pub struct BreadcrumbStory<S: 'static + Send + Sync> {
|
||||
state_type: PhantomData<S>,
|
||||
}
|
||||
|
@ -98,11 +98,7 @@ mod stories {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(
|
||||
&mut self,
|
||||
view_state: &mut S,
|
||||
cx: &mut ViewContext<S>,
|
||||
) -> impl IntoAnyElement<S> {
|
||||
fn render(self, view_state: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
let theme = theme(cx);
|
||||
|
||||
Story::container(cx)
|
||||
|
|
|
@ -109,7 +109,7 @@ impl BufferRow {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Element, Clone)]
|
||||
#[derive(IntoAnyElement, Clone)]
|
||||
pub struct Buffer<S: 'static + Send + Sync + Clone> {
|
||||
id: ElementId,
|
||||
state_type: PhantomData<S>,
|
||||
|
@ -219,7 +219,7 @@ impl<S: 'static + Send + Sync + Clone> Buffer<S> {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
let theme = theme(cx);
|
||||
let rows = self.render_rows(cx);
|
||||
|
||||
|
@ -246,7 +246,7 @@ mod stories {
|
|||
|
||||
use super::*;
|
||||
|
||||
#[derive(Element)]
|
||||
#[derive(IntoAnyElement)]
|
||||
pub struct BufferStory<S: 'static + Send + Sync + Clone> {
|
||||
state_type: PhantomData<S>,
|
||||
}
|
||||
|
@ -258,7 +258,7 @@ mod stories {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
let theme = theme(cx);
|
||||
|
||||
Story::container(cx)
|
||||
|
|
|
@ -5,7 +5,7 @@ use chrono::NaiveDateTime;
|
|||
use crate::prelude::*;
|
||||
use crate::{Icon, IconButton, Input, Label, LabelColor};
|
||||
|
||||
#[derive(Element)]
|
||||
#[derive(IntoAnyElement)]
|
||||
pub struct ChatPanel<S: 'static + Send + Sync> {
|
||||
element_id: ElementId,
|
||||
messages: Vec<ChatMessage<S>>,
|
||||
|
@ -24,7 +24,7 @@ impl<S: 'static + Send + Sync> ChatPanel<S> {
|
|||
self
|
||||
}
|
||||
|
||||
fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
div()
|
||||
.id(self.element_id.clone())
|
||||
.flex()
|
||||
|
@ -70,7 +70,7 @@ impl<S: 'static + Send + Sync> ChatPanel<S> {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Element)]
|
||||
#[derive(IntoAnyElement)]
|
||||
pub struct ChatMessage<S: 'static + Send + Sync> {
|
||||
state_type: PhantomData<S>,
|
||||
author: String,
|
||||
|
@ -88,7 +88,7 @@ impl<S: 'static + Send + Sync> ChatMessage<S> {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
div()
|
||||
.flex()
|
||||
.flex_col()
|
||||
|
@ -117,7 +117,7 @@ mod stories {
|
|||
|
||||
use super::*;
|
||||
|
||||
#[derive(Element)]
|
||||
#[derive(IntoAnyElement)]
|
||||
pub struct ChatPanelStory<S: 'static + Send + Sync> {
|
||||
state_type: PhantomData<S>,
|
||||
}
|
||||
|
@ -129,7 +129,7 @@ mod stories {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
Story::container(cx)
|
||||
.child(Story::title_for::<_, ChatPanel<S>>(cx))
|
||||
.child(Story::label(cx, "Default"))
|
||||
|
|
|
@ -5,7 +5,7 @@ use crate::{
|
|||
};
|
||||
use std::marker::PhantomData;
|
||||
|
||||
#[derive(Element)]
|
||||
#[derive(IntoAnyElement)]
|
||||
pub struct CollabPanel<S: 'static + Send + Sync> {
|
||||
id: ElementId,
|
||||
state_type: PhantomData<S>,
|
||||
|
@ -19,7 +19,7 @@ impl<S: 'static + Send + Sync> CollabPanel<S> {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
let theme = theme(cx);
|
||||
|
||||
v_stack()
|
||||
|
@ -98,7 +98,7 @@ mod stories {
|
|||
|
||||
use super::*;
|
||||
|
||||
#[derive(Element)]
|
||||
#[derive(IntoAnyElement)]
|
||||
pub struct CollabPanelStory<S: 'static + Send + Sync> {
|
||||
state_type: PhantomData<S>,
|
||||
}
|
||||
|
@ -110,7 +110,7 @@ mod stories {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
Story::container(cx)
|
||||
.child(Story::title_for::<_, CollabPanel<S>>(cx))
|
||||
.child(Story::label(cx, "Default"))
|
||||
|
|
|
@ -3,7 +3,7 @@ use std::marker::PhantomData;
|
|||
use crate::prelude::*;
|
||||
use crate::{example_editor_actions, OrderMethod, Palette};
|
||||
|
||||
#[derive(Element)]
|
||||
#[derive(IntoAnyElement)]
|
||||
pub struct CommandPalette<S: 'static + Send + Sync> {
|
||||
id: ElementId,
|
||||
state_type: PhantomData<S>,
|
||||
|
@ -17,7 +17,7 @@ impl<S: 'static + Send + Sync> CommandPalette<S> {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
div().id(self.id.clone()).child(
|
||||
Palette::new("palette")
|
||||
.items(example_editor_actions())
|
||||
|
@ -37,7 +37,7 @@ mod stories {
|
|||
|
||||
use super::*;
|
||||
|
||||
#[derive(Element)]
|
||||
#[derive(IntoAnyElement)]
|
||||
pub struct CommandPaletteStory<S: 'static + Send + Sync> {
|
||||
state_type: PhantomData<S>,
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ mod stories {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
Story::container(cx)
|
||||
.child(Story::title_for::<_, CommandPalette<S>>(cx))
|
||||
.child(Story::label(cx, "Default"))
|
||||
|
|
|
@ -31,7 +31,7 @@ impl<S: 'static + Send + Sync> ContextMenuItem<S> {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Element)]
|
||||
#[derive(IntoAnyElement)]
|
||||
pub struct ContextMenu<S: 'static + Send + Sync> {
|
||||
items: Vec<ContextMenuItem<S>>,
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ impl<S: 'static + Send + Sync> ContextMenu<S> {
|
|||
items: items.into_iter().collect(),
|
||||
}
|
||||
}
|
||||
fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
let theme = theme(cx);
|
||||
|
||||
v_stack()
|
||||
|
@ -73,7 +73,7 @@ mod stories {
|
|||
|
||||
use super::*;
|
||||
|
||||
#[derive(Element)]
|
||||
#[derive(IntoAnyElement)]
|
||||
pub struct ContextMenuStory<S: 'static + Send + Sync> {
|
||||
state_type: PhantomData<S>,
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ mod stories {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
Story::container(cx)
|
||||
.child(Story::title_for::<_, ContextMenu<S>>(cx))
|
||||
.child(Story::label(cx, "Default"))
|
||||
|
|
|
@ -2,7 +2,7 @@ use std::marker::PhantomData;
|
|||
|
||||
use crate::{prelude::*, Button, Label, LabelColor, Modal};
|
||||
|
||||
#[derive(Element)]
|
||||
#[derive(IntoAnyElement)]
|
||||
pub struct CopilotModal<S: 'static + Send + Sync + Clone> {
|
||||
id: ElementId,
|
||||
state_type: PhantomData<S>,
|
||||
|
@ -16,7 +16,7 @@ impl<S: 'static + Send + Sync + Clone> CopilotModal<S> {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
div().id(self.id.clone()).child(
|
||||
Modal::new("some-id")
|
||||
.title("Connect Copilot to Zed")
|
||||
|
@ -35,7 +35,7 @@ mod stories {
|
|||
|
||||
use super::*;
|
||||
|
||||
#[derive(Element)]
|
||||
#[derive(IntoAnyElement)]
|
||||
pub struct CopilotModalStory<S: 'static + Send + Sync + Clone> {
|
||||
state_type: PhantomData<S>,
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ mod stories {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
Story::container(cx)
|
||||
.child(Story::title_for::<_, CopilotModal<S>>(cx))
|
||||
.child(Story::label(cx, "Default"))
|
||||
|
|
|
@ -3,7 +3,7 @@ use std::marker::PhantomData;
|
|||
use crate::prelude::*;
|
||||
use crate::{Avatar, Player};
|
||||
|
||||
#[derive(Element)]
|
||||
#[derive(IntoAnyElement)]
|
||||
pub struct Facepile<S: 'static + Send + Sync> {
|
||||
state_type: PhantomData<S>,
|
||||
players: Vec<Player>,
|
||||
|
@ -17,7 +17,7 @@ impl<S: 'static + Send + Sync> Facepile<S> {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
let player_count = self.players.len();
|
||||
let player_list = self.players.iter().enumerate().map(|(ix, player)| {
|
||||
let isnt_last = ix < player_count - 1;
|
||||
|
@ -39,7 +39,7 @@ mod stories {
|
|||
|
||||
use super::*;
|
||||
|
||||
#[derive(Element)]
|
||||
#[derive(IntoAnyElement)]
|
||||
pub struct FacepileStory<S: 'static + Send + Sync> {
|
||||
state_type: PhantomData<S>,
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ mod stories {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
let players = static_players();
|
||||
|
||||
Story::container(cx)
|
||||
|
|
|
@ -16,7 +16,7 @@ impl<S: 'static + Send + Sync> Default for IconButtonHandlers<S> {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Element)]
|
||||
#[derive(IntoAnyElement)]
|
||||
pub struct IconButton<S: 'static + Send + Sync> {
|
||||
state_type: PhantomData<S>,
|
||||
id: ElementId,
|
||||
|
@ -68,7 +68,7 @@ impl<S: 'static + Send + Sync> IconButton<S> {
|
|||
self
|
||||
}
|
||||
|
||||
fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
let theme = theme(cx);
|
||||
|
||||
let icon_color = match (self.state, self.color) {
|
||||
|
|
|
@ -5,7 +5,7 @@ use strum::{EnumIter, IntoEnumIterator};
|
|||
|
||||
use crate::prelude::*;
|
||||
|
||||
#[derive(Element)]
|
||||
#[derive(IntoAnyElement)]
|
||||
pub struct Keybinding<S: 'static + Send + Sync> {
|
||||
state_type: PhantomData<S>,
|
||||
|
||||
|
@ -34,7 +34,7 @@ impl<S: 'static + Send + Sync> Keybinding<S> {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
div()
|
||||
.flex()
|
||||
.gap_2()
|
||||
|
@ -54,7 +54,7 @@ impl<S: 'static + Send + Sync> Keybinding<S> {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Element)]
|
||||
#[derive(IntoAnyElement)]
|
||||
pub struct Key<S: 'static + Send + Sync> {
|
||||
state_type: PhantomData<S>,
|
||||
key: SharedString,
|
||||
|
@ -68,7 +68,7 @@ impl<S: 'static + Send + Sync> Key<S> {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
let theme = theme(cx);
|
||||
|
||||
div()
|
||||
|
@ -173,7 +173,7 @@ mod stories {
|
|||
|
||||
use super::*;
|
||||
|
||||
#[derive(Element)]
|
||||
#[derive(IntoAnyElement)]
|
||||
pub struct KeybindingStory<S: 'static + Send + Sync + Clone> {
|
||||
state_type: PhantomData<S>,
|
||||
}
|
||||
|
@ -185,7 +185,7 @@ mod stories {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
let all_modifier_permutations = ModifierKey::iter().permutations(2);
|
||||
|
||||
Story::container(cx)
|
||||
|
|
|
@ -3,7 +3,7 @@ use std::marker::PhantomData;
|
|||
use crate::prelude::*;
|
||||
use crate::{OrderMethod, Palette, PaletteItem};
|
||||
|
||||
#[derive(Element)]
|
||||
#[derive(IntoAnyElement)]
|
||||
pub struct LanguageSelector<S: 'static + Send + Sync + Clone> {
|
||||
id: ElementId,
|
||||
state_type: PhantomData<S>,
|
||||
|
@ -17,7 +17,7 @@ impl<S: 'static + Send + Sync + Clone> LanguageSelector<S> {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
div().id(self.id.clone()).child(
|
||||
Palette::new("palette")
|
||||
.items(vec![
|
||||
|
@ -48,7 +48,7 @@ mod stories {
|
|||
|
||||
use super::*;
|
||||
|
||||
#[derive(Element)]
|
||||
#[derive(IntoAnyElement)]
|
||||
pub struct LanguageSelectorStory<S: 'static + Send + Sync + Clone> {
|
||||
state_type: PhantomData<S>,
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ mod stories {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
Story::container(cx)
|
||||
.child(Story::title_for::<_, LanguageSelector<S>>(cx))
|
||||
.child(Story::label(cx, "Default"))
|
||||
|
|
|
@ -17,7 +17,7 @@ pub enum ListItemVariant {
|
|||
Inset,
|
||||
}
|
||||
|
||||
#[derive(Element)]
|
||||
#[derive(IntoAnyElement)]
|
||||
pub struct ListHeader<S: 'static + Send + Sync> {
|
||||
state_type: PhantomData<S>,
|
||||
label: SharedString,
|
||||
|
@ -92,7 +92,7 @@ impl<S: 'static + Send + Sync> ListHeader<S> {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
let theme = theme(cx);
|
||||
|
||||
let is_toggleable = self.toggleable != Toggleable::NotToggleable;
|
||||
|
@ -134,7 +134,7 @@ impl<S: 'static + Send + Sync> ListHeader<S> {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Element)]
|
||||
#[derive(IntoAnyElement)]
|
||||
pub struct ListSubHeader<S: 'static + Send + Sync> {
|
||||
state_type: PhantomData<S>,
|
||||
label: SharedString,
|
||||
|
@ -157,7 +157,7 @@ impl<S: 'static + Send + Sync> ListSubHeader<S> {
|
|||
self
|
||||
}
|
||||
|
||||
fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
h_stack().flex_1().w_full().relative().py_1().child(
|
||||
div()
|
||||
.h_6()
|
||||
|
@ -197,7 +197,7 @@ pub enum ListEntrySize {
|
|||
Medium,
|
||||
}
|
||||
|
||||
#[derive(Element)]
|
||||
#[derive(IntoAnyElement)]
|
||||
pub enum ListItem<S: 'static + Send + Sync> {
|
||||
Entry(ListEntry<S>),
|
||||
Details(ListDetailsEntry<S>),
|
||||
|
@ -230,7 +230,7 @@ impl<S: 'static + Send + Sync> From<ListSubHeader<S>> for ListItem<S> {
|
|||
}
|
||||
|
||||
impl<S: 'static + Send + Sync> ListItem<S> {
|
||||
fn render(&mut self, view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
match self {
|
||||
ListItem::Entry(entry) => div().child(entry.render(view, cx)),
|
||||
ListItem::Separator(separator) => div().child(separator.render(view, cx)),
|
||||
|
@ -252,7 +252,7 @@ impl<S: 'static + Send + Sync> ListItem<S> {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Element)]
|
||||
#[derive(IntoAnyElement)]
|
||||
pub struct ListEntry<S: 'static + Send + Sync> {
|
||||
disclosure_control_style: DisclosureControlVisibility,
|
||||
indent_level: u32,
|
||||
|
@ -364,7 +364,7 @@ impl<S: 'static + Send + Sync> ListEntry<S> {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
let settings = user_settings(cx);
|
||||
let theme = theme(cx);
|
||||
|
||||
|
@ -430,7 +430,7 @@ impl<S: 'static + Send + Sync> Default for ListDetailsEntryHandlers<S> {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Element)]
|
||||
#[derive(IntoAnyElement)]
|
||||
pub struct ListDetailsEntry<S: 'static + Send + Sync> {
|
||||
label: SharedString,
|
||||
meta: Option<SharedString>,
|
||||
|
@ -474,7 +474,7 @@ impl<S: 'static + Send + Sync> ListDetailsEntry<S> {
|
|||
self
|
||||
}
|
||||
|
||||
fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
let theme = theme(cx);
|
||||
let settings = user_settings(cx);
|
||||
|
||||
|
@ -519,7 +519,7 @@ impl<S: 'static + Send + Sync> ListDetailsEntry<S> {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Element)]
|
||||
#[derive(Clone, IntoAnyElement)]
|
||||
pub struct ListSeparator<S: 'static + Send + Sync> {
|
||||
state_type: PhantomData<S>,
|
||||
}
|
||||
|
@ -531,14 +531,14 @@ impl<S: 'static + Send + Sync> ListSeparator<S> {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
let theme = theme(cx);
|
||||
|
||||
div().h_px().w_full().bg(theme.border)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Element)]
|
||||
#[derive(IntoAnyElement)]
|
||||
pub struct List<S: 'static + Send + Sync> {
|
||||
items: Vec<ListItem<S>>,
|
||||
empty_message: SharedString,
|
||||
|
@ -571,7 +571,7 @@ impl<S: 'static + Send + Sync> List<S> {
|
|||
self
|
||||
}
|
||||
|
||||
fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
let is_toggleable = self.toggleable != Toggleable::NotToggleable;
|
||||
let is_toggled = Toggleable::is_toggled(&self.toggleable);
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ use smallvec::SmallVec;
|
|||
|
||||
use crate::{h_stack, prelude::*, v_stack, Button, Icon, IconButton, Label};
|
||||
|
||||
#[derive(Element)]
|
||||
#[derive(IntoAnyElement)]
|
||||
pub struct Modal<S: 'static + Send + Sync> {
|
||||
id: ElementId,
|
||||
state_type: PhantomData<S>,
|
||||
|
@ -42,7 +42,7 @@ impl<S: 'static + Send + Sync> Modal<S> {
|
|||
self
|
||||
}
|
||||
|
||||
fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
let theme = theme(cx);
|
||||
|
||||
v_stack()
|
||||
|
|
|
@ -3,7 +3,7 @@ use std::marker::PhantomData;
|
|||
use crate::prelude::*;
|
||||
use crate::{v_stack, Buffer, Icon, IconButton, Label};
|
||||
|
||||
#[derive(Element)]
|
||||
#[derive(IntoAnyElement)]
|
||||
pub struct MultiBuffer<S: 'static + Send + Sync + Clone> {
|
||||
state_type: PhantomData<S>,
|
||||
buffers: Vec<Buffer<S>>,
|
||||
|
@ -17,7 +17,7 @@ impl<S: 'static + Send + Sync + Clone> MultiBuffer<S> {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
let theme = theme(cx);
|
||||
|
||||
v_stack()
|
||||
|
@ -50,7 +50,7 @@ mod stories {
|
|||
|
||||
use super::*;
|
||||
|
||||
#[derive(Element)]
|
||||
#[derive(IntoAnyElement)]
|
||||
pub struct MultiBufferStory<S: 'static + Send + Sync + Clone> {
|
||||
state_type: PhantomData<S>,
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ mod stories {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
let theme = theme(cx);
|
||||
|
||||
Story::container(cx)
|
||||
|
|
|
@ -4,7 +4,7 @@ use gpui2::rems;
|
|||
|
||||
use crate::{h_stack, prelude::*, Icon};
|
||||
|
||||
#[derive(Element)]
|
||||
#[derive(IntoAnyElement)]
|
||||
pub struct NotificationToast<S: 'static + Send + Sync + Clone> {
|
||||
state_type: PhantomData<S>,
|
||||
label: SharedString,
|
||||
|
@ -28,7 +28,7 @@ impl<S: 'static + Send + Sync + Clone> NotificationToast<S> {
|
|||
self
|
||||
}
|
||||
|
||||
fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
let theme = theme(cx);
|
||||
|
||||
h_stack()
|
||||
|
|
|
@ -3,7 +3,7 @@ use std::marker::PhantomData;
|
|||
use crate::{prelude::*, static_new_notification_items, static_read_notification_items};
|
||||
use crate::{List, ListHeader};
|
||||
|
||||
#[derive(Element)]
|
||||
#[derive(IntoAnyElement)]
|
||||
pub struct NotificationsPanel<S: 'static + Send + Sync> {
|
||||
id: ElementId,
|
||||
state_type: PhantomData<S>,
|
||||
|
@ -17,7 +17,7 @@ impl<S: 'static + Send + Sync> NotificationsPanel<S> {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
let theme = theme(cx);
|
||||
|
||||
div()
|
||||
|
@ -58,7 +58,7 @@ mod stories {
|
|||
|
||||
use super::*;
|
||||
|
||||
#[derive(Element)]
|
||||
#[derive(IntoAnyElement)]
|
||||
pub struct NotificationsPanelStory<S: 'static + Send + Sync + Clone> {
|
||||
state_type: PhantomData<S>,
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ mod stories {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
Story::container(cx)
|
||||
.child(Story::title_for::<_, NotificationsPanel<S>>(cx))
|
||||
.child(Story::label(cx, "Default"))
|
||||
|
|
|
@ -3,7 +3,7 @@ use std::marker::PhantomData;
|
|||
use crate::prelude::*;
|
||||
use crate::{h_stack, v_stack, Keybinding, Label, LabelColor};
|
||||
|
||||
#[derive(Element)]
|
||||
#[derive(IntoAnyElement)]
|
||||
pub struct Palette<S: 'static + Send + Sync> {
|
||||
id: ElementId,
|
||||
state_type: PhantomData<S>,
|
||||
|
@ -46,7 +46,7 @@ impl<S: 'static + Send + Sync> Palette<S> {
|
|||
self
|
||||
}
|
||||
|
||||
fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
let theme = theme(cx);
|
||||
|
||||
v_stack()
|
||||
|
@ -101,7 +101,7 @@ impl<S: 'static + Send + Sync> Palette<S> {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Element)]
|
||||
#[derive(IntoAnyElement)]
|
||||
pub struct PaletteItem<S: 'static + Send + Sync> {
|
||||
pub label: SharedString,
|
||||
pub sublabel: Option<SharedString>,
|
||||
|
@ -135,7 +135,7 @@ impl<S: 'static + Send + Sync> PaletteItem<S> {
|
|||
self
|
||||
}
|
||||
|
||||
fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
div()
|
||||
.flex()
|
||||
.flex_row()
|
||||
|
@ -160,7 +160,7 @@ mod stories {
|
|||
|
||||
use super::*;
|
||||
|
||||
#[derive(Element)]
|
||||
#[derive(IntoAnyElement)]
|
||||
pub struct PaletteStory<S: 'static + Send + Sync + Clone> {
|
||||
state_type: PhantomData<S>,
|
||||
}
|
||||
|
@ -172,7 +172,7 @@ mod stories {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
Story::container(cx)
|
||||
.child(Story::title_for::<_, Palette<S>>(cx))
|
||||
.child(Story::label(cx, "Default"))
|
||||
|
|
|
@ -40,7 +40,7 @@ pub enum PanelSide {
|
|||
|
||||
use std::collections::HashSet;
|
||||
|
||||
#[derive(Element)]
|
||||
#[derive(IntoAnyElement)]
|
||||
pub struct Panel<S: 'static + Send + Sync> {
|
||||
id: ElementId,
|
||||
state_type: PhantomData<S>,
|
||||
|
@ -96,7 +96,7 @@ impl<S: 'static + Send + Sync> Panel<S> {
|
|||
self
|
||||
}
|
||||
|
||||
fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
let theme = theme(cx);
|
||||
|
||||
let current_size = self.width.unwrap_or(self.initial_width);
|
||||
|
@ -136,7 +136,7 @@ mod stories {
|
|||
|
||||
use super::*;
|
||||
|
||||
#[derive(Element)]
|
||||
#[derive(IntoAnyElement)]
|
||||
pub struct PanelStory<S: 'static + Send + Sync + Clone> {
|
||||
state_type: PhantomData<S>,
|
||||
}
|
||||
|
@ -148,7 +148,7 @@ mod stories {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
Story::container(cx)
|
||||
.child(Story::title_for::<_, Panel<S>>(cx))
|
||||
.child(Story::label(cx, "Default"))
|
||||
|
|
|
@ -75,7 +75,7 @@ impl<V: 'static> ParentElement<V> for Pane<V> {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Element)]
|
||||
#[derive(IntoAnyElement)]
|
||||
pub struct PaneGroup<V: 'static + Send + Sync> {
|
||||
state_type: PhantomData<V>,
|
||||
groups: Vec<PaneGroup<V>>,
|
||||
|
@ -102,7 +102,7 @@ impl<V: 'static + Send + Sync> PaneGroup<V> {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(&mut self, view: &mut V, cx: &mut ViewContext<V>) -> impl IntoAnyElement<V> {
|
||||
fn render(mut self, view: &mut V, cx: &mut ViewContext<V>) -> impl IntoAnyElement<V> {
|
||||
let theme = theme(cx);
|
||||
|
||||
if !self.panes.is_empty() {
|
||||
|
@ -129,7 +129,7 @@ impl<V: 'static + Send + Sync> PaneGroup<V> {
|
|||
.w_full()
|
||||
.h_full()
|
||||
.bg(theme.editor)
|
||||
.children(self.groups.iter_mut().map(|group| group.render(view, cx)));
|
||||
.children(self.groups.drain(..).map(|group| group.render(view, cx)));
|
||||
|
||||
if self.split_direction == SplitDirection::Horizontal {
|
||||
return el;
|
||||
|
|
|
@ -3,7 +3,7 @@ use std::marker::PhantomData;
|
|||
use crate::prelude::*;
|
||||
use crate::{Avatar, Facepile, PlayerWithCallStatus};
|
||||
|
||||
#[derive(Element)]
|
||||
#[derive(IntoAnyElement)]
|
||||
pub struct PlayerStack<S: 'static + Send + Sync> {
|
||||
state_type: PhantomData<S>,
|
||||
player_with_call_status: PlayerWithCallStatus,
|
||||
|
@ -17,7 +17,7 @@ impl<S: 'static + Send + Sync> PlayerStack<S> {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
let theme = theme(cx);
|
||||
let player = self.player_with_call_status.get_player();
|
||||
self.player_with_call_status.get_call_status();
|
||||
|
|
|
@ -5,7 +5,7 @@ use crate::{
|
|||
static_project_panel_project_items, static_project_panel_single_items, Input, List, ListHeader,
|
||||
};
|
||||
|
||||
#[derive(Element)]
|
||||
#[derive(IntoAnyElement)]
|
||||
pub struct ProjectPanel<S: 'static + Send + Sync> {
|
||||
id: ElementId,
|
||||
state_type: PhantomData<S>,
|
||||
|
@ -19,7 +19,7 @@ impl<S: 'static + Send + Sync> ProjectPanel<S> {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
let theme = theme(cx);
|
||||
|
||||
div()
|
||||
|
@ -67,7 +67,7 @@ mod stories {
|
|||
|
||||
use super::*;
|
||||
|
||||
#[derive(Element)]
|
||||
#[derive(IntoAnyElement)]
|
||||
pub struct ProjectPanelStory<S: 'static + Send + Sync + Clone> {
|
||||
state_type: PhantomData<S>,
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ mod stories {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
Story::container(cx)
|
||||
.child(Story::title_for::<_, ProjectPanel<S>>(cx))
|
||||
.child(Story::label(cx, "Default"))
|
||||
|
|
|
@ -3,7 +3,7 @@ use std::marker::PhantomData;
|
|||
use crate::prelude::*;
|
||||
use crate::{OrderMethod, Palette, PaletteItem};
|
||||
|
||||
#[derive(Element)]
|
||||
#[derive(IntoAnyElement)]
|
||||
pub struct RecentProjects<S: 'static + Send + Sync + Clone> {
|
||||
id: ElementId,
|
||||
state_type: PhantomData<S>,
|
||||
|
@ -17,7 +17,7 @@ impl<S: 'static + Send + Sync + Clone> RecentProjects<S> {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
div().id(self.id.clone()).child(
|
||||
Palette::new("palette")
|
||||
.items(vec![
|
||||
|
@ -44,7 +44,7 @@ mod stories {
|
|||
|
||||
use super::*;
|
||||
|
||||
#[derive(Element)]
|
||||
#[derive(IntoAnyElement)]
|
||||
pub struct RecentProjectsStory<S: 'static + Send + Sync + Clone> {
|
||||
state_type: PhantomData<S>,
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ mod stories {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
Story::container(cx)
|
||||
.child(Story::title_for::<_, RecentProjects<S>>(cx))
|
||||
.child(Story::label(cx, "Default"))
|
||||
|
|
|
@ -36,15 +36,6 @@ pub struct StatusBar {
|
|||
bottom_tools: Option<ToolGroup>,
|
||||
}
|
||||
|
||||
// impl IntoAnyElement<Workspace> for StatusBar {
|
||||
// fn into_any(self) -> gpui2::AnyElement<Workspace> {
|
||||
// (move |workspace: &mut Workspace, cx: &mut ViewContext<'_, '_, Workspace>| {
|
||||
// self.render(workspace, cx)
|
||||
// })
|
||||
// .into_any()
|
||||
// }
|
||||
// }
|
||||
|
||||
impl StatusBar {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
|
|
|
@ -3,7 +3,7 @@ use std::marker::PhantomData;
|
|||
use crate::prelude::*;
|
||||
use crate::{Icon, IconColor, IconElement, Label, LabelColor};
|
||||
|
||||
#[derive(Element, Clone)]
|
||||
#[derive(IntoAnyElement, Clone)]
|
||||
pub struct Tab<S: 'static + Send + Sync + Clone> {
|
||||
state_type: PhantomData<S>,
|
||||
id: ElementId,
|
||||
|
@ -81,7 +81,7 @@ impl<S: 'static + Send + Sync + Clone> Tab<S> {
|
|||
self
|
||||
}
|
||||
|
||||
fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
let theme = theme(cx);
|
||||
let has_fs_conflict = self.fs_status == FileSystemStatus::Conflict;
|
||||
let is_deleted = self.fs_status == FileSystemStatus::Deleted;
|
||||
|
@ -176,7 +176,7 @@ mod stories {
|
|||
|
||||
use super::*;
|
||||
|
||||
#[derive(Element)]
|
||||
#[derive(IntoAnyElement)]
|
||||
pub struct TabStory<S: 'static + Send + Sync + Clone> {
|
||||
state_type: PhantomData<S>,
|
||||
}
|
||||
|
@ -188,7 +188,7 @@ mod stories {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
let git_statuses = GitStatus::iter();
|
||||
let fs_statuses = FileSystemStatus::iter();
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ use std::marker::PhantomData;
|
|||
use crate::prelude::*;
|
||||
use crate::{Icon, IconButton, Tab};
|
||||
|
||||
#[derive(Element)]
|
||||
#[derive(IntoAnyElement)]
|
||||
pub struct TabBar<S: 'static + Send + Sync + Clone> {
|
||||
id: ElementId,
|
||||
state_type: PhantomData<S>,
|
||||
|
@ -27,7 +27,7 @@ impl<S: 'static + Send + Sync + Clone> TabBar<S> {
|
|||
self
|
||||
}
|
||||
|
||||
fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
let theme = theme(cx);
|
||||
|
||||
let (can_navigate_back, can_navigate_forward) = self.can_navigate;
|
||||
|
@ -100,7 +100,7 @@ mod stories {
|
|||
|
||||
use super::*;
|
||||
|
||||
#[derive(Element)]
|
||||
#[derive(IntoAnyElement)]
|
||||
pub struct TabBarStory<S: 'static + Send + Sync + Clone> {
|
||||
state_type: PhantomData<S>,
|
||||
}
|
||||
|
@ -112,7 +112,7 @@ mod stories {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
Story::container(cx)
|
||||
.child(Story::title_for::<_, TabBar<S>>(cx))
|
||||
.child(Story::label(cx, "Default"))
|
||||
|
|
|
@ -5,7 +5,7 @@ use gpui2::{relative, rems, Size};
|
|||
use crate::prelude::*;
|
||||
use crate::{Icon, IconButton, Pane, Tab};
|
||||
|
||||
#[derive(Element)]
|
||||
#[derive(IntoAnyElement)]
|
||||
pub struct Terminal<S: 'static + Send + Sync + Clone> {
|
||||
state_type: PhantomData<S>,
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ impl<S: 'static + Send + Sync + Clone> Terminal<S> {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
let theme = theme(cx);
|
||||
|
||||
let can_navigate_back = true;
|
||||
|
@ -93,7 +93,7 @@ mod stories {
|
|||
|
||||
use super::*;
|
||||
|
||||
#[derive(Element)]
|
||||
#[derive(IntoAnyElement)]
|
||||
pub struct TerminalStory<S: 'static + Send + Sync + Clone> {
|
||||
state_type: PhantomData<S>,
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ mod stories {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
Story::container(cx)
|
||||
.child(Story::title_for::<_, Terminal<S>>(cx))
|
||||
.child(Story::label(cx, "Default"))
|
||||
|
|
|
@ -3,7 +3,7 @@ use std::marker::PhantomData;
|
|||
use crate::prelude::*;
|
||||
use crate::{OrderMethod, Palette, PaletteItem};
|
||||
|
||||
#[derive(Element)]
|
||||
#[derive(IntoAnyElement)]
|
||||
pub struct ThemeSelector<S: 'static + Send + Sync> {
|
||||
id: ElementId,
|
||||
state_type: PhantomData<S>,
|
||||
|
@ -17,7 +17,7 @@ impl<S: 'static + Send + Sync> ThemeSelector<S> {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
div().child(
|
||||
Palette::new(self.id.clone())
|
||||
.items(vec![
|
||||
|
@ -49,7 +49,7 @@ mod stories {
|
|||
|
||||
use super::*;
|
||||
|
||||
#[derive(Element)]
|
||||
#[derive(IntoAnyElement)]
|
||||
pub struct ThemeSelectorStory<S: 'static + Send + Sync + Clone> {
|
||||
state_type: PhantomData<S>,
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ mod stories {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
Story::container(cx)
|
||||
.child(Story::title_for::<_, ThemeSelector<S>>(cx))
|
||||
.child(Story::label(cx, "Default"))
|
||||
|
|
|
@ -22,7 +22,7 @@ pub enum ToastOrigin {
|
|||
/// they are actively showing the a process in progress.
|
||||
///
|
||||
/// Only one toast may be visible at a time.
|
||||
#[derive(Element)]
|
||||
#[derive(IntoAnyElement)]
|
||||
pub struct Toast<S: 'static + Send + Sync> {
|
||||
origin: ToastOrigin,
|
||||
children: SmallVec<[AnyElement<S>; 2]>,
|
||||
|
@ -36,7 +36,7 @@ impl<S: 'static + Send + Sync> Toast<S> {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
let theme = theme(cx);
|
||||
|
||||
let mut div = div();
|
||||
|
@ -57,7 +57,7 @@ impl<S: 'static + Send + Sync> Toast<S> {
|
|||
.shadow_md()
|
||||
.overflow_hidden()
|
||||
.bg(theme.elevated_surface)
|
||||
.children(self.children.drain(..))
|
||||
.children(self.children)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -78,7 +78,7 @@ mod stories {
|
|||
|
||||
use super::*;
|
||||
|
||||
#[derive(Element)]
|
||||
#[derive(IntoAnyElement)]
|
||||
pub struct ToastStory<S: 'static + Send + Sync> {
|
||||
state_type: PhantomData<S>,
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ mod stories {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
Story::container(cx)
|
||||
.child(Story::title_for::<_, Toast<S>>(cx))
|
||||
.child(Story::label(cx, "Default"))
|
||||
|
|
|
@ -6,7 +6,7 @@ use crate::prelude::*;
|
|||
#[derive(Clone)]
|
||||
pub struct ToolbarItem {}
|
||||
|
||||
#[derive(Element)]
|
||||
#[derive(IntoAnyElement)]
|
||||
pub struct Toolbar<S: 'static + Send + Sync> {
|
||||
left_items: SmallVec<[AnyElement<S>; 2]>,
|
||||
right_items: SmallVec<[AnyElement<S>; 2]>,
|
||||
|
@ -54,7 +54,7 @@ impl<S: 'static + Send + Sync> Toolbar<S> {
|
|||
self
|
||||
}
|
||||
|
||||
fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
let theme = theme(cx);
|
||||
|
||||
div()
|
||||
|
@ -80,7 +80,7 @@ mod stories {
|
|||
|
||||
use super::*;
|
||||
|
||||
#[derive(Element)]
|
||||
#[derive(IntoAnyElement)]
|
||||
pub struct ToolbarStory<S: 'static + Send + Sync + Clone> {
|
||||
state_type: PhantomData<S>,
|
||||
}
|
||||
|
@ -92,7 +92,7 @@ mod stories {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
let theme = theme(cx);
|
||||
|
||||
Story::container(cx)
|
||||
|
|
|
@ -9,7 +9,7 @@ enum TrafficLightColor {
|
|||
Green,
|
||||
}
|
||||
|
||||
#[derive(Element)]
|
||||
#[derive(IntoAnyElement)]
|
||||
struct TrafficLight<S: 'static + Send + Sync> {
|
||||
state_type: PhantomData<S>,
|
||||
color: TrafficLightColor,
|
||||
|
@ -25,7 +25,7 @@ impl<S: 'static + Send + Sync> TrafficLight<S> {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
let theme = theme(cx);
|
||||
|
||||
let fill = match (self.window_has_focus, self.color) {
|
||||
|
@ -39,7 +39,7 @@ impl<S: 'static + Send + Sync> TrafficLight<S> {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Element)]
|
||||
#[derive(IntoAnyElement)]
|
||||
pub struct TrafficLights<S: 'static + Send + Sync> {
|
||||
state_type: PhantomData<S>,
|
||||
window_has_focus: bool,
|
||||
|
@ -58,7 +58,7 @@ impl<S: 'static + Send + Sync> TrafficLights<S> {
|
|||
self
|
||||
}
|
||||
|
||||
fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
div()
|
||||
.flex()
|
||||
.items_center()
|
||||
|
@ -87,7 +87,7 @@ mod stories {
|
|||
|
||||
use super::*;
|
||||
|
||||
#[derive(Element)]
|
||||
#[derive(IntoAnyElement)]
|
||||
pub struct TrafficLightsStory<S: 'static + Send + Sync> {
|
||||
state_type: PhantomData<S>,
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ mod stories {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl IntoAnyElement<S> {
|
||||
Story::container(cx)
|
||||
.child(Story::title_for::<_, TrafficLights<S>>(cx))
|
||||
.child(Story::label(cx, "Default"))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue