Rename S
type to V
This commit is contained in:
parent
8a70ef3e8f
commit
1887f3b594
34 changed files with 140 additions and 152 deletions
|
@ -154,7 +154,7 @@ impl Buffer {
|
|||
self
|
||||
}
|
||||
|
||||
fn render_row<S: 'static>(row: BufferRow, cx: &WindowContext) -> impl Component<S> {
|
||||
fn render_row<V: 'static>(row: BufferRow, cx: &WindowContext) -> impl Component<V> {
|
||||
let theme = theme(cx);
|
||||
|
||||
let line_background = if row.current {
|
||||
|
@ -204,7 +204,7 @@ impl Buffer {
|
|||
}))
|
||||
}
|
||||
|
||||
fn render_rows<S: 'static>(&self, cx: &WindowContext) -> Vec<impl Component<S>> {
|
||||
fn render_rows<V: 'static>(&self, cx: &WindowContext) -> Vec<impl Component<V>> {
|
||||
match &self.rows {
|
||||
Some(rows) => rows
|
||||
.rows
|
||||
|
@ -215,7 +215,7 @@ impl Buffer {
|
|||
}
|
||||
}
|
||||
|
||||
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||
let theme = theme(cx);
|
||||
let rows = self.render_rows(cx);
|
||||
|
||||
|
@ -250,7 +250,7 @@ mod stories {
|
|||
Self
|
||||
}
|
||||
|
||||
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||
let theme = theme(cx);
|
||||
|
||||
Story::container(cx)
|
||||
|
|
|
@ -22,7 +22,7 @@ impl ChatPanel {
|
|||
self
|
||||
}
|
||||
|
||||
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||
div()
|
||||
.id(self.element_id.clone())
|
||||
.flex()
|
||||
|
@ -84,7 +84,7 @@ impl ChatMessage {
|
|||
}
|
||||
}
|
||||
|
||||
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||
div()
|
||||
.flex()
|
||||
.flex_col()
|
||||
|
@ -121,7 +121,7 @@ mod stories {
|
|||
Self
|
||||
}
|
||||
|
||||
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||
Story::container(cx)
|
||||
.child(Story::title_for::<_, ChatPanel>(cx))
|
||||
.child(Story::label(cx, "Default"))
|
||||
|
|
|
@ -14,7 +14,7 @@ impl CollabPanel {
|
|||
Self { id: id.into() }
|
||||
}
|
||||
|
||||
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||
let theme = theme(cx);
|
||||
|
||||
v_stack()
|
||||
|
@ -101,7 +101,7 @@ mod stories {
|
|||
Self
|
||||
}
|
||||
|
||||
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||
Story::container(cx)
|
||||
.child(Story::title_for::<_, CollabPanel>(cx))
|
||||
.child(Story::label(cx, "Default"))
|
||||
|
|
|
@ -11,7 +11,7 @@ impl CommandPalette {
|
|||
Self { id: id.into() }
|
||||
}
|
||||
|
||||
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||
div().id(self.id.clone()).child(
|
||||
Palette::new("palette")
|
||||
.items(example_editor_actions())
|
||||
|
@ -39,7 +39,7 @@ mod stories {
|
|||
Self
|
||||
}
|
||||
|
||||
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||
Story::container(cx)
|
||||
.child(Story::title_for::<_, CommandPalette>(cx))
|
||||
.child(Story::label(cx, "Default"))
|
||||
|
|
|
@ -43,7 +43,7 @@ impl ContextMenu {
|
|||
}
|
||||
}
|
||||
|
||||
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||
let theme = theme(cx);
|
||||
|
||||
v_stack()
|
||||
|
@ -80,7 +80,7 @@ mod stories {
|
|||
Self
|
||||
}
|
||||
|
||||
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||
Story::container(cx)
|
||||
.child(Story::title_for::<_, ContextMenu>(cx))
|
||||
.child(Story::label(cx, "Default"))
|
||||
|
|
|
@ -10,7 +10,7 @@ impl CopilotModal {
|
|||
Self { id: id.into() }
|
||||
}
|
||||
|
||||
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||
div().id(self.id.clone()).child(
|
||||
Modal::new("some-id")
|
||||
.title("Connect Copilot to Zed")
|
||||
|
@ -37,7 +37,7 @@ mod stories {
|
|||
Self
|
||||
}
|
||||
|
||||
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||
Story::container(cx)
|
||||
.child(Story::title_for::<_, CopilotModal>(cx))
|
||||
.child(Story::label(cx, "Default"))
|
||||
|
|
|
@ -13,7 +13,7 @@ impl Facepile {
|
|||
}
|
||||
}
|
||||
|
||||
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||
let player_count = self.players.len();
|
||||
let player_list = self.players.iter().enumerate().map(|(ix, player)| {
|
||||
let isnt_last = ix < player_count - 1;
|
||||
|
@ -43,7 +43,7 @@ mod stories {
|
|||
Self
|
||||
}
|
||||
|
||||
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||
let players = static_players();
|
||||
|
||||
Story::container(cx)
|
||||
|
|
|
@ -5,27 +5,27 @@ use gpui2::MouseButton;
|
|||
use crate::{h_stack, prelude::*};
|
||||
use crate::{ClickHandler, Icon, IconColor, IconElement};
|
||||
|
||||
struct IconButtonHandlers<S: 'static> {
|
||||
click: Option<ClickHandler<S>>,
|
||||
struct IconButtonHandlers<V: 'static> {
|
||||
click: Option<ClickHandler<V>>,
|
||||
}
|
||||
|
||||
impl<S: 'static> Default for IconButtonHandlers<S> {
|
||||
impl<V: 'static> Default for IconButtonHandlers<V> {
|
||||
fn default() -> Self {
|
||||
Self { click: None }
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Component)]
|
||||
pub struct IconButton<S: 'static> {
|
||||
pub struct IconButton<V: 'static> {
|
||||
id: ElementId,
|
||||
icon: Icon,
|
||||
color: IconColor,
|
||||
variant: ButtonVariant,
|
||||
state: InteractionState,
|
||||
handlers: IconButtonHandlers<S>,
|
||||
handlers: IconButtonHandlers<V>,
|
||||
}
|
||||
|
||||
impl<S: 'static> IconButton<S> {
|
||||
impl<V: 'static> IconButton<V> {
|
||||
pub fn new(id: impl Into<ElementId>, icon: Icon) -> Self {
|
||||
Self {
|
||||
id: id.into(),
|
||||
|
@ -57,12 +57,12 @@ impl<S: 'static> IconButton<S> {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn on_click(mut self, handler: impl 'static + Fn(&mut S, &mut ViewContext<S>) + Send + Sync) -> Self {
|
||||
pub fn on_click(mut self, handler: impl 'static + Fn(&mut V, &mut ViewContext<V>) + Send + Sync) -> Self {
|
||||
self.handlers.click = Some(Arc::new(handler));
|
||||
self
|
||||
}
|
||||
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
fn render(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||
let theme = theme(cx);
|
||||
|
||||
let icon_color = match (self.state, self.color) {
|
||||
|
|
|
@ -29,7 +29,7 @@ impl Keybinding {
|
|||
}
|
||||
}
|
||||
|
||||
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||
div()
|
||||
.flex()
|
||||
.gap_2()
|
||||
|
@ -59,7 +59,7 @@ impl Key {
|
|||
Self { key: key.into() }
|
||||
}
|
||||
|
||||
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||
let theme = theme(cx);
|
||||
|
||||
div()
|
||||
|
|
|
@ -11,7 +11,7 @@ impl LanguageSelector {
|
|||
Self { id: id.into() }
|
||||
}
|
||||
|
||||
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||
div().id(self.id.clone()).child(
|
||||
Palette::new("palette")
|
||||
.items(vec![
|
||||
|
@ -50,7 +50,7 @@ mod stories {
|
|||
Self
|
||||
}
|
||||
|
||||
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||
Story::container(cx)
|
||||
.child(Story::title_for::<_, LanguageSelector>(cx))
|
||||
.child(Story::label(cx, "Default"))
|
||||
|
|
|
@ -55,7 +55,7 @@ impl ListHeader {
|
|||
self
|
||||
}
|
||||
|
||||
fn disclosure_control<S: 'static>(&self) -> Div<S> {
|
||||
fn disclosure_control<V: 'static>(&self) -> Div<V> {
|
||||
let is_toggleable = self.toggleable != Toggleable::NotToggleable;
|
||||
let is_toggled = Toggleable::is_toggled(&self.toggleable);
|
||||
|
||||
|
@ -88,7 +88,7 @@ impl ListHeader {
|
|||
}
|
||||
}
|
||||
|
||||
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||
let theme = theme(cx);
|
||||
|
||||
let is_toggleable = self.toggleable != Toggleable::NotToggleable;
|
||||
|
@ -151,7 +151,7 @@ impl ListSubHeader {
|
|||
self
|
||||
}
|
||||
|
||||
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||
h_stack().flex_1().w_full().relative().py_1().child(
|
||||
div()
|
||||
.h_6()
|
||||
|
@ -192,39 +192,39 @@ pub enum ListEntrySize {
|
|||
}
|
||||
|
||||
#[derive(Component)]
|
||||
pub enum ListItem<S: 'static> {
|
||||
pub enum ListItem<V: 'static> {
|
||||
Entry(ListEntry),
|
||||
Details(ListDetailsEntry<S>),
|
||||
Details(ListDetailsEntry<V>),
|
||||
Separator(ListSeparator),
|
||||
Header(ListSubHeader),
|
||||
}
|
||||
|
||||
impl<S: 'static> From<ListEntry> for ListItem<S> {
|
||||
impl<V: 'static> From<ListEntry> for ListItem<V> {
|
||||
fn from(entry: ListEntry) -> Self {
|
||||
Self::Entry(entry)
|
||||
}
|
||||
}
|
||||
|
||||
impl<S: 'static> From<ListDetailsEntry<S>> for ListItem<S> {
|
||||
fn from(entry: ListDetailsEntry<S>) -> Self {
|
||||
impl<V: 'static> From<ListDetailsEntry<V>> for ListItem<V> {
|
||||
fn from(entry: ListDetailsEntry<V>) -> Self {
|
||||
Self::Details(entry)
|
||||
}
|
||||
}
|
||||
|
||||
impl<S: 'static> From<ListSeparator> for ListItem<S> {
|
||||
impl<V: 'static> From<ListSeparator> for ListItem<V> {
|
||||
fn from(entry: ListSeparator) -> Self {
|
||||
Self::Separator(entry)
|
||||
}
|
||||
}
|
||||
|
||||
impl<S: 'static> From<ListSubHeader> for ListItem<S> {
|
||||
impl<V: 'static> From<ListSubHeader> for ListItem<V> {
|
||||
fn from(entry: ListSubHeader) -> Self {
|
||||
Self::Header(entry)
|
||||
}
|
||||
}
|
||||
|
||||
impl<S: 'static> ListItem<S> {
|
||||
fn render(self, view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
impl<V: 'static> ListItem<V> {
|
||||
fn render(self, view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||
match self {
|
||||
ListItem::Entry(entry) => div().child(entry.render(view, cx)),
|
||||
ListItem::Separator(separator) => div().child(separator.render(view, cx)),
|
||||
|
@ -361,7 +361,7 @@ impl ListEntry {
|
|||
}
|
||||
}
|
||||
|
||||
fn render<S: 'static>(mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
fn render<V: 'static>(mut self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||
let settings = user_settings(cx);
|
||||
let theme = theme(cx);
|
||||
|
||||
|
@ -417,29 +417,29 @@ impl ListEntry {
|
|||
}
|
||||
}
|
||||
|
||||
struct ListDetailsEntryHandlers<S: 'static> {
|
||||
click: Option<ClickHandler<S>>,
|
||||
struct ListDetailsEntryHandlers<V: 'static> {
|
||||
click: Option<ClickHandler<V>>,
|
||||
}
|
||||
|
||||
impl<S: 'static> Default for ListDetailsEntryHandlers<S> {
|
||||
impl<V: 'static> Default for ListDetailsEntryHandlers<V> {
|
||||
fn default() -> Self {
|
||||
Self { click: None }
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Component)]
|
||||
pub struct ListDetailsEntry<S: 'static> {
|
||||
pub struct ListDetailsEntry<V: 'static> {
|
||||
label: SharedString,
|
||||
meta: Option<SharedString>,
|
||||
left_content: Option<LeftContent>,
|
||||
handlers: ListDetailsEntryHandlers<S>,
|
||||
actions: Option<Vec<Button<S>>>,
|
||||
handlers: ListDetailsEntryHandlers<V>,
|
||||
actions: Option<Vec<Button<V>>>,
|
||||
// TODO: make this more generic instead of
|
||||
// specifically for notifications
|
||||
seen: bool,
|
||||
}
|
||||
|
||||
impl<S: 'static> ListDetailsEntry<S> {
|
||||
impl<V: 'static> ListDetailsEntry<V> {
|
||||
pub fn new(label: impl Into<SharedString>) -> Self {
|
||||
Self {
|
||||
label: label.into(),
|
||||
|
@ -461,17 +461,17 @@ impl<S: 'static> ListDetailsEntry<S> {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn on_click(mut self, handler: ClickHandler<S>) -> Self {
|
||||
pub fn on_click(mut self, handler: ClickHandler<V>) -> Self {
|
||||
self.handlers.click = Some(handler);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn actions(mut self, actions: Vec<Button<S>>) -> Self {
|
||||
pub fn actions(mut self, actions: Vec<Button<V>>) -> Self {
|
||||
self.actions = Some(actions);
|
||||
self
|
||||
}
|
||||
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
fn render(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||
let theme = theme(cx);
|
||||
let settings = user_settings(cx);
|
||||
|
||||
|
@ -531,15 +531,15 @@ impl ListSeparator {
|
|||
}
|
||||
|
||||
#[derive(Component)]
|
||||
pub struct List<S: 'static> {
|
||||
items: Vec<ListItem<S>>,
|
||||
pub struct List<V: 'static> {
|
||||
items: Vec<ListItem<V>>,
|
||||
empty_message: SharedString,
|
||||
header: Option<ListHeader>,
|
||||
toggleable: Toggleable,
|
||||
}
|
||||
|
||||
impl<S: 'static> List<S> {
|
||||
pub fn new(items: Vec<ListItem<S>>) -> Self {
|
||||
impl<V: 'static> List<V> {
|
||||
pub fn new(items: Vec<ListItem<V>>) -> Self {
|
||||
Self {
|
||||
items,
|
||||
empty_message: "No items".into(),
|
||||
|
@ -563,7 +563,7 @@ impl<S: 'static> List<S> {
|
|||
self
|
||||
}
|
||||
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
fn render(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||
let is_toggleable = self.toggleable != Toggleable::NotToggleable;
|
||||
let is_toggled = Toggleable::is_toggled(&self.toggleable);
|
||||
|
||||
|
|
|
@ -4,15 +4,15 @@ use smallvec::SmallVec;
|
|||
use crate::{h_stack, prelude::*, v_stack, Button, Icon, IconButton, Label};
|
||||
|
||||
#[derive(Component)]
|
||||
pub struct Modal<S: 'static> {
|
||||
pub struct Modal<V: 'static> {
|
||||
id: ElementId,
|
||||
title: Option<SharedString>,
|
||||
primary_action: Option<Button<S>>,
|
||||
secondary_action: Option<Button<S>>,
|
||||
children: SmallVec<[AnyElement<S>; 2]>,
|
||||
primary_action: Option<Button<V>>,
|
||||
secondary_action: Option<Button<V>>,
|
||||
children: SmallVec<[AnyElement<V>; 2]>,
|
||||
}
|
||||
|
||||
impl<S: 'static> Modal<S> {
|
||||
impl<V: 'static> Modal<V> {
|
||||
pub fn new(id: impl Into<ElementId>) -> Self {
|
||||
Self {
|
||||
id: id.into(),
|
||||
|
@ -28,17 +28,17 @@ impl<S: 'static> Modal<S> {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn primary_action(mut self, action: Button<S>) -> Self {
|
||||
pub fn primary_action(mut self, action: Button<V>) -> Self {
|
||||
self.primary_action = Some(action);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn secondary_action(mut self, action: Button<S>) -> Self {
|
||||
pub fn secondary_action(mut self, action: Button<V>) -> Self {
|
||||
self.secondary_action = Some(action);
|
||||
self
|
||||
}
|
||||
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
fn render(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||
let theme = theme(cx);
|
||||
|
||||
v_stack()
|
||||
|
@ -76,8 +76,8 @@ impl<S: 'static> Modal<S> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<S: 'static> ParentElement<S> for Modal<S> {
|
||||
fn children_mut(&mut self) -> &mut SmallVec<[AnyElement<S>; 2]> {
|
||||
impl<V: 'static> ParentElement<V> for Modal<V> {
|
||||
fn children_mut(&mut self) -> &mut SmallVec<[AnyElement<V>; 2]> {
|
||||
&mut self.children
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,10 +10,7 @@ pub struct NotificationToast {
|
|||
|
||||
impl NotificationToast {
|
||||
pub fn new(label: SharedString) -> Self {
|
||||
Self {
|
||||
label,
|
||||
icon: None,
|
||||
}
|
||||
Self { label, icon: None }
|
||||
}
|
||||
|
||||
pub fn icon<I>(mut self, icon: I) -> Self
|
||||
|
@ -24,7 +21,7 @@ impl NotificationToast {
|
|||
self
|
||||
}
|
||||
|
||||
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||
let theme = theme(cx);
|
||||
|
||||
h_stack()
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
use crate::{prelude::*, static_new_notification_items, static_read_notification_items};
|
||||
use crate::{List, ListHeader};
|
||||
|
||||
|
@ -9,12 +8,10 @@ pub struct NotificationsPanel {
|
|||
|
||||
impl NotificationsPanel {
|
||||
pub fn new(id: impl Into<ElementId>) -> Self {
|
||||
Self {
|
||||
id: id.into(),
|
||||
}
|
||||
Self { id: id.into() }
|
||||
}
|
||||
|
||||
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||
let theme = theme(cx);
|
||||
|
||||
div()
|
||||
|
|
|
@ -42,7 +42,7 @@ impl Palette {
|
|||
self
|
||||
}
|
||||
|
||||
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||
let theme = theme(cx);
|
||||
|
||||
v_stack()
|
||||
|
@ -131,7 +131,7 @@ impl PaletteItem {
|
|||
self
|
||||
}
|
||||
|
||||
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||
div()
|
||||
.flex()
|
||||
.flex_row()
|
||||
|
|
|
@ -39,17 +39,17 @@ pub enum PanelSide {
|
|||
use std::collections::HashSet;
|
||||
|
||||
#[derive(Component)]
|
||||
pub struct Panel<S: 'static> {
|
||||
pub struct Panel<V: 'static> {
|
||||
id: ElementId,
|
||||
current_side: PanelSide,
|
||||
/// Defaults to PanelAllowedSides::LeftAndRight
|
||||
allowed_sides: PanelAllowedSides,
|
||||
initial_width: AbsoluteLength,
|
||||
width: Option<AbsoluteLength>,
|
||||
children: SmallVec<[AnyElement<S>; 2]>,
|
||||
children: SmallVec<[AnyElement<V>; 2]>,
|
||||
}
|
||||
|
||||
impl<S: 'static> Panel<S> {
|
||||
impl<V: 'static> Panel<V> {
|
||||
pub fn new(id: impl Into<ElementId>, cx: &mut WindowContext) -> Self {
|
||||
let settings = user_settings(cx);
|
||||
|
||||
|
@ -92,7 +92,7 @@ impl<S: 'static> Panel<S> {
|
|||
self
|
||||
}
|
||||
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
fn render(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||
let theme = theme(cx);
|
||||
|
||||
let current_size = self.width.unwrap_or(self.initial_width);
|
||||
|
@ -117,8 +117,8 @@ impl<S: 'static> Panel<S> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<S: 'static> ParentElement<S> for Panel<S> {
|
||||
fn children_mut(&mut self) -> &mut SmallVec<[AnyElement<S>; 2]> {
|
||||
impl<V: 'static> ParentElement<V> for Panel<V> {
|
||||
fn children_mut(&mut self) -> &mut SmallVec<[AnyElement<V>; 2]> {
|
||||
&mut self.children
|
||||
}
|
||||
}
|
||||
|
@ -140,9 +140,9 @@ mod stories {
|
|||
Self
|
||||
}
|
||||
|
||||
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||
Story::container(cx)
|
||||
.child(Story::title_for::<_, Panel<S>>(cx))
|
||||
.child(Story::title_for::<_, Panel<V>>(cx))
|
||||
.child(Story::label(cx, "Default"))
|
||||
.child(
|
||||
Panel::new("panel", cx).child(
|
||||
|
|
|
@ -13,7 +13,7 @@ impl PlayerStack {
|
|||
}
|
||||
}
|
||||
|
||||
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||
let theme = theme(cx);
|
||||
let player = self.player_with_call_status.get_player();
|
||||
self.player_with_call_status.get_call_status();
|
||||
|
|
|
@ -13,7 +13,7 @@ impl ProjectPanel {
|
|||
Self { id: id.into() }
|
||||
}
|
||||
|
||||
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||
let theme = theme(cx);
|
||||
|
||||
div()
|
||||
|
@ -69,7 +69,7 @@ mod stories {
|
|||
Self
|
||||
}
|
||||
|
||||
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||
Story::container(cx)
|
||||
.child(Story::title_for::<_, ProjectPanel>(cx))
|
||||
.child(Story::label(cx, "Default"))
|
||||
|
|
|
@ -11,7 +11,7 @@ impl RecentProjects {
|
|||
Self { id: id.into() }
|
||||
}
|
||||
|
||||
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||
div().id(self.id.clone()).child(
|
||||
Palette::new("palette")
|
||||
.items(vec![
|
||||
|
@ -46,7 +46,7 @@ mod stories {
|
|||
Self
|
||||
}
|
||||
|
||||
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||
Story::container(cx)
|
||||
.child(Story::title_for::<_, RecentProjects>(cx))
|
||||
.child(Story::label(cx, "Default"))
|
||||
|
|
|
@ -23,7 +23,7 @@ impl TabBar {
|
|||
self
|
||||
}
|
||||
|
||||
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||
let theme = theme(cx);
|
||||
|
||||
let (can_navigate_back, can_navigate_forward) = self.can_navigate;
|
||||
|
@ -104,7 +104,7 @@ mod stories {
|
|||
Self
|
||||
}
|
||||
|
||||
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||
Story::container(cx)
|
||||
.child(Story::title_for::<_, TabBar>(cx))
|
||||
.child(Story::label(cx, "Default"))
|
||||
|
|
|
@ -11,7 +11,7 @@ impl Terminal {
|
|||
Self
|
||||
}
|
||||
|
||||
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||
let theme = theme(cx);
|
||||
|
||||
let can_navigate_back = true;
|
||||
|
@ -95,7 +95,7 @@ mod stories {
|
|||
Self
|
||||
}
|
||||
|
||||
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||
Story::container(cx)
|
||||
.child(Story::title_for::<_, Terminal>(cx))
|
||||
.child(Story::label(cx, "Default"))
|
||||
|
|
|
@ -11,7 +11,7 @@ impl ThemeSelector {
|
|||
Self { id: id.into() }
|
||||
}
|
||||
|
||||
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||
div().child(
|
||||
Palette::new(self.id.clone())
|
||||
.items(vec![
|
||||
|
@ -51,7 +51,7 @@ mod stories {
|
|||
Self
|
||||
}
|
||||
|
||||
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||
Story::container(cx)
|
||||
.child(Story::title_for::<_, ThemeSelector>(cx))
|
||||
.child(Story::label(cx, "Default"))
|
||||
|
|
|
@ -23,12 +23,12 @@ pub enum ToastOrigin {
|
|||
///
|
||||
/// Only one toast may be visible at a time.
|
||||
#[derive(Component)]
|
||||
pub struct Toast<S: 'static> {
|
||||
pub struct Toast<V: 'static> {
|
||||
origin: ToastOrigin,
|
||||
children: SmallVec<[AnyElement<S>; 2]>,
|
||||
children: SmallVec<[AnyElement<V>; 2]>,
|
||||
}
|
||||
|
||||
impl<S: 'static> Toast<S> {
|
||||
impl<V: 'static> Toast<V> {
|
||||
pub fn new(origin: ToastOrigin) -> Self {
|
||||
Self {
|
||||
origin,
|
||||
|
@ -36,7 +36,7 @@ impl<S: 'static> Toast<S> {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
fn render(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||
let theme = theme(cx);
|
||||
|
||||
let mut div = div();
|
||||
|
@ -61,8 +61,8 @@ impl<S: 'static> Toast<S> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<S: 'static> ParentElement<S> for Toast<S> {
|
||||
fn children_mut(&mut self) -> &mut SmallVec<[AnyElement<S>; 2]> {
|
||||
impl<V: 'static> ParentElement<V> for Toast<V> {
|
||||
fn children_mut(&mut self) -> &mut SmallVec<[AnyElement<V>; 2]> {
|
||||
&mut self.children
|
||||
}
|
||||
}
|
||||
|
@ -84,9 +84,9 @@ mod stories {
|
|||
Self
|
||||
}
|
||||
|
||||
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||
Story::container(cx)
|
||||
.child(Story::title_for::<_, Toast<S>>(cx))
|
||||
.child(Story::title_for::<_, Toast<V>>(cx))
|
||||
.child(Story::label(cx, "Default"))
|
||||
.child(Toast::new(ToastOrigin::Bottom).child(Label::new("label")))
|
||||
}
|
||||
|
|
|
@ -7,12 +7,12 @@ use crate::prelude::*;
|
|||
pub struct ToolbarItem {}
|
||||
|
||||
#[derive(Component)]
|
||||
pub struct Toolbar<S: 'static> {
|
||||
left_items: SmallVec<[AnyElement<S>; 2]>,
|
||||
right_items: SmallVec<[AnyElement<S>; 2]>,
|
||||
pub struct Toolbar<V: 'static> {
|
||||
left_items: SmallVec<[AnyElement<V>; 2]>,
|
||||
right_items: SmallVec<[AnyElement<V>; 2]>,
|
||||
}
|
||||
|
||||
impl<S: 'static> Toolbar<S> {
|
||||
impl<V: 'static> Toolbar<V> {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
left_items: SmallVec::new(),
|
||||
|
@ -20,7 +20,7 @@ impl<S: 'static> Toolbar<S> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn left_item(mut self, child: impl Component<S>) -> Self
|
||||
pub fn left_item(mut self, child: impl Component<V>) -> Self
|
||||
where
|
||||
Self: Sized,
|
||||
{
|
||||
|
@ -28,7 +28,7 @@ impl<S: 'static> Toolbar<S> {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn left_items(mut self, iter: impl IntoIterator<Item = impl Component<S>>) -> Self
|
||||
pub fn left_items(mut self, iter: impl IntoIterator<Item = impl Component<V>>) -> Self
|
||||
where
|
||||
Self: Sized,
|
||||
{
|
||||
|
@ -37,7 +37,7 @@ impl<S: 'static> Toolbar<S> {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn right_item(mut self, child: impl Component<S>) -> Self
|
||||
pub fn right_item(mut self, child: impl Component<V>) -> Self
|
||||
where
|
||||
Self: Sized,
|
||||
{
|
||||
|
@ -45,7 +45,7 @@ impl<S: 'static> Toolbar<S> {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn right_items(mut self, iter: impl IntoIterator<Item = impl Component<S>>) -> Self
|
||||
pub fn right_items(mut self, iter: impl IntoIterator<Item = impl Component<V>>) -> Self
|
||||
where
|
||||
Self: Sized,
|
||||
{
|
||||
|
@ -54,7 +54,7 @@ impl<S: 'static> Toolbar<S> {
|
|||
self
|
||||
}
|
||||
|
||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
fn render(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||
let theme = theme(cx);
|
||||
|
||||
div()
|
||||
|
|
|
@ -21,7 +21,7 @@ impl TrafficLight {
|
|||
}
|
||||
}
|
||||
|
||||
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||
let theme = theme(cx);
|
||||
|
||||
let fill = match (self.window_has_focus, self.color) {
|
||||
|
@ -52,7 +52,7 @@ impl TrafficLights {
|
|||
self
|
||||
}
|
||||
|
||||
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||
div()
|
||||
.flex()
|
||||
.items_center()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue