Checkpoint: Compiling after view type removal
This commit is contained in:
parent
c9c9db903d
commit
88ef74ec8f
44 changed files with 392 additions and 695 deletions
|
@ -19,7 +19,7 @@ pub fn derive_component(input: TokenStream) -> TokenStream {
|
||||||
}) {
|
}) {
|
||||||
quote! { #first_type_param }
|
quote! { #first_type_param }
|
||||||
} else {
|
} else {
|
||||||
trait_generics.params.push(parse_quote! { V: 'static + Send + Sync });
|
trait_generics.params.push(parse_quote! { V: 'static });
|
||||||
quote! { V }
|
quote! { V }
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
use std::marker::PhantomData;
|
|
||||||
|
|
||||||
use gpui2::{px, rgb, Div, Hsla};
|
use gpui2::{px, rgb, Div, Hsla};
|
||||||
use ui::prelude::*;
|
use ui::prelude::*;
|
||||||
|
@ -8,18 +7,14 @@ use crate::story::Story;
|
||||||
/// A reimplementation of the MDN `z-index` example, found here:
|
/// A reimplementation of the MDN `z-index` example, found here:
|
||||||
/// [https://developer.mozilla.org/en-US/docs/Web/CSS/z-index](https://developer.mozilla.org/en-US/docs/Web/CSS/z-index).
|
/// [https://developer.mozilla.org/en-US/docs/Web/CSS/z-index](https://developer.mozilla.org/en-US/docs/Web/CSS/z-index).
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct ZIndexStory<S: 'static + Send + Sync> {
|
pub struct ZIndexStory;
|
||||||
state_type: PhantomData<S>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync> ZIndexStory<S> {
|
impl ZIndexStory {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self {
|
Self
|
||||||
state_type: PhantomData,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||||
Story::container(cx)
|
Story::container(cx)
|
||||||
.child(Story::title(cx, "z-index"))
|
.child(Story::title(cx, "z-index"))
|
||||||
.child(
|
.child(
|
||||||
|
@ -86,23 +81,19 @@ trait Styles: Styled + Sized {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<V: 'static + Send + Sync> Styles for Div<V> {}
|
impl<V: 'static> Styles for Div<V> {}
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
struct ZIndexExample<V: 'static + Send + Sync> {
|
struct ZIndexExample {
|
||||||
view_type: PhantomData<V>,
|
|
||||||
z_index: u32,
|
z_index: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<V: 'static + Send + Sync> ZIndexExample<V> {
|
impl ZIndexExample {
|
||||||
pub fn new(z_index: u32) -> Self {
|
pub fn new(z_index: u32) -> Self {
|
||||||
Self {
|
Self { z_index }
|
||||||
view_type: PhantomData,
|
|
||||||
z_index,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||||
div()
|
div()
|
||||||
.relative()
|
.relative()
|
||||||
.size_full()
|
.size_full()
|
||||||
|
|
|
@ -1,22 +1,18 @@
|
||||||
use std::marker::PhantomData;
|
|
||||||
|
|
||||||
use gpui2::{rems, AbsoluteLength};
|
use gpui2::{rems, AbsoluteLength};
|
||||||
|
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
use crate::{Icon, IconButton, Label, Panel, PanelSide};
|
use crate::{Icon, IconButton, Label, Panel, PanelSide};
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct AssistantPanel<S: 'static + Send + Sync> {
|
pub struct AssistantPanel {
|
||||||
id: ElementId,
|
id: ElementId,
|
||||||
state_type: PhantomData<S>,
|
|
||||||
current_side: PanelSide,
|
current_side: PanelSide,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync> AssistantPanel<S> {
|
impl AssistantPanel {
|
||||||
pub fn new(id: impl Into<ElementId>) -> Self {
|
pub fn new(id: impl Into<ElementId>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
id: id.into(),
|
id: id.into(),
|
||||||
state_type: PhantomData,
|
|
||||||
current_side: PanelSide::default(),
|
current_side: PanelSide::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,7 +22,7 @@ impl<S: 'static + Send + Sync> AssistantPanel<S> {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(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> {
|
||||||
Panel::new(self.id.clone(), cx)
|
Panel::new(self.id.clone(), cx)
|
||||||
.children(vec![div()
|
.children(vec![div()
|
||||||
.flex()
|
.flex()
|
||||||
|
@ -92,9 +88,9 @@ mod stories {
|
||||||
Self {}
|
Self {}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render<V: 'static + Send + Sync>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||||
Story::container(cx)
|
Story::container(cx)
|
||||||
.child(Story::title_for::<_, AssistantPanel<V>>(cx))
|
.child(Story::title_for::<_, AssistantPanel>(cx))
|
||||||
.child(Story::label(cx, "Default"))
|
.child(Story::label(cx, "Default"))
|
||||||
.child(AssistantPanel::new("assistant-panel"))
|
.child(AssistantPanel::new("assistant-panel"))
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
use std::marker::PhantomData;
|
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
use gpui2::Div;
|
use gpui2::Div;
|
||||||
|
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
use crate::{h_stack, HighlightedText};
|
use crate::{h_stack, HighlightedText};
|
||||||
|
|
||||||
|
@ -10,28 +8,26 @@ use crate::{h_stack, HighlightedText};
|
||||||
pub struct Symbol(pub Vec<HighlightedText>);
|
pub struct Symbol(pub Vec<HighlightedText>);
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct Breadcrumb<S: 'static + Send + Sync> {
|
pub struct Breadcrumb {
|
||||||
state_type: PhantomData<S>,
|
|
||||||
path: PathBuf,
|
path: PathBuf,
|
||||||
symbols: Vec<Symbol>,
|
symbols: Vec<Symbol>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync> Breadcrumb<S> {
|
impl Breadcrumb {
|
||||||
pub fn new(path: PathBuf, symbols: Vec<Symbol>) -> Self {
|
pub fn new(path: PathBuf, symbols: Vec<Symbol>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
state_type: PhantomData,
|
|
||||||
path,
|
path,
|
||||||
symbols,
|
symbols,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render_separator(&self, cx: &WindowContext) -> Div<S> {
|
fn render_separator<V: 'static>(&self, cx: &WindowContext) -> Div<V> {
|
||||||
let theme = theme(cx);
|
let theme = theme(cx);
|
||||||
|
|
||||||
div().child(" › ").text_color(theme.text_muted)
|
div().child(" › ").text_color(theme.text_muted)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(self, view_state: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
fn render<V: 'static>(self, view_state: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||||
let theme = theme(cx);
|
let theme = theme(cx);
|
||||||
|
|
||||||
let symbols_len = self.symbols.len();
|
let symbols_len = self.symbols.len();
|
||||||
|
@ -87,22 +83,18 @@ mod stories {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct BreadcrumbStory<S: 'static + Send + Sync> {
|
pub struct BreadcrumbStory;
|
||||||
state_type: PhantomData<S>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync> BreadcrumbStory<S> {
|
impl BreadcrumbStory {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self {
|
Self
|
||||||
state_type: PhantomData,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(self, view_state: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
fn render<V: 'static>(self, view_state: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||||
let theme = theme(cx);
|
let theme = theme(cx);
|
||||||
|
|
||||||
Story::container(cx)
|
Story::container(cx)
|
||||||
.child(Story::title_for::<_, Breadcrumb<S>>(cx))
|
.child(Story::title_for::<_, Breadcrumb>(cx))
|
||||||
.child(Story::label(cx, "Default"))
|
.child(Story::label(cx, "Default"))
|
||||||
.child(Breadcrumb::new(
|
.child(Breadcrumb::new(
|
||||||
PathBuf::from_str("crates/ui/src/components/toolbar.rs").unwrap(),
|
PathBuf::from_str("crates/ui/src/components/toolbar.rs").unwrap(),
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
use std::marker::PhantomData;
|
|
||||||
|
|
||||||
use gpui2::{Hsla, WindowContext};
|
use gpui2::{Hsla, WindowContext};
|
||||||
|
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
|
@ -110,9 +108,8 @@ impl BufferRow {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Component, Clone)]
|
#[derive(Component, Clone)]
|
||||||
pub struct Buffer<S: 'static + Send + Sync + Clone> {
|
pub struct Buffer {
|
||||||
id: ElementId,
|
id: ElementId,
|
||||||
state_type: PhantomData<S>,
|
|
||||||
rows: Option<BufferRows>,
|
rows: Option<BufferRows>,
|
||||||
readonly: bool,
|
readonly: bool,
|
||||||
language: Option<String>,
|
language: Option<String>,
|
||||||
|
@ -120,11 +117,10 @@ pub struct Buffer<S: 'static + Send + Sync + Clone> {
|
||||||
path: Option<String>,
|
path: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync + Clone> Buffer<S> {
|
impl Buffer {
|
||||||
pub fn new(id: impl Into<ElementId>) -> Self {
|
pub fn new(id: impl Into<ElementId>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
id: id.into(),
|
id: id.into(),
|
||||||
state_type: PhantomData,
|
|
||||||
rows: Some(BufferRows::default()),
|
rows: Some(BufferRows::default()),
|
||||||
readonly: false,
|
readonly: false,
|
||||||
language: None,
|
language: None,
|
||||||
|
@ -158,7 +154,7 @@ impl<S: 'static + Send + Sync + Clone> Buffer<S> {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render_row(row: BufferRow, cx: &WindowContext) -> impl Component<S> {
|
fn render_row<S: 'static>(row: BufferRow, cx: &WindowContext) -> impl Component<S> {
|
||||||
let theme = theme(cx);
|
let theme = theme(cx);
|
||||||
|
|
||||||
let line_background = if row.current {
|
let line_background = if row.current {
|
||||||
|
@ -208,7 +204,7 @@ impl<S: 'static + Send + Sync + Clone> Buffer<S> {
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render_rows(&self, cx: &WindowContext) -> Vec<impl Component<S>> {
|
fn render_rows<S: 'static>(&self, cx: &WindowContext) -> Vec<impl Component<S>> {
|
||||||
match &self.rows {
|
match &self.rows {
|
||||||
Some(rows) => rows
|
Some(rows) => rows
|
||||||
.rows
|
.rows
|
||||||
|
@ -219,7 +215,7 @@ impl<S: 'static + Send + Sync + Clone> Buffer<S> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||||
let theme = theme(cx);
|
let theme = theme(cx);
|
||||||
let rows = self.render_rows(cx);
|
let rows = self.render_rows(cx);
|
||||||
|
|
||||||
|
@ -247,22 +243,18 @@ mod stories {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct BufferStory<S: 'static + Send + Sync + Clone> {
|
pub struct BufferStory;
|
||||||
state_type: PhantomData<S>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync + Clone> BufferStory<S> {
|
impl BufferStory {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self {
|
Self
|
||||||
state_type: PhantomData,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||||
let theme = theme(cx);
|
let theme = theme(cx);
|
||||||
|
|
||||||
Story::container(cx)
|
Story::container(cx)
|
||||||
.child(Story::title_for::<_, Buffer<S>>(cx))
|
.child(Story::title_for::<_, Buffer>(cx))
|
||||||
.child(Story::label(cx, "Default"))
|
.child(Story::label(cx, "Default"))
|
||||||
.child(div().w(rems(64.)).h_96().child(empty_buffer_example()))
|
.child(div().w(rems(64.)).h_96().child(empty_buffer_example()))
|
||||||
.child(Story::label(cx, "Hello World (Rust)"))
|
.child(Story::label(cx, "Hello World (Rust)"))
|
||||||
|
|
|
@ -1,17 +1,15 @@
|
||||||
use std::marker::PhantomData;
|
|
||||||
|
|
||||||
use chrono::NaiveDateTime;
|
use chrono::NaiveDateTime;
|
||||||
|
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
use crate::{Icon, IconButton, Input, Label, LabelColor};
|
use crate::{Icon, IconButton, Input, Label, LabelColor};
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct ChatPanel<S: 'static + Send + Sync> {
|
pub struct ChatPanel {
|
||||||
element_id: ElementId,
|
element_id: ElementId,
|
||||||
messages: Vec<ChatMessage<S>>,
|
messages: Vec<ChatMessage>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync> ChatPanel<S> {
|
impl ChatPanel {
|
||||||
pub fn new(element_id: impl Into<ElementId>) -> Self {
|
pub fn new(element_id: impl Into<ElementId>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
element_id: element_id.into(),
|
element_id: element_id.into(),
|
||||||
|
@ -19,12 +17,12 @@ impl<S: 'static + Send + Sync> ChatPanel<S> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn messages(mut self, messages: Vec<ChatMessage<S>>) -> Self {
|
pub fn messages(mut self, messages: Vec<ChatMessage>) -> Self {
|
||||||
self.messages = messages;
|
self.messages = messages;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
fn render<S: 'static>(mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||||
div()
|
div()
|
||||||
.id(self.element_id.clone())
|
.id(self.element_id.clone())
|
||||||
.flex()
|
.flex()
|
||||||
|
@ -71,24 +69,22 @@ impl<S: 'static + Send + Sync> ChatPanel<S> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct ChatMessage<S: 'static + Send + Sync> {
|
pub struct ChatMessage {
|
||||||
state_type: PhantomData<S>,
|
|
||||||
author: String,
|
author: String,
|
||||||
text: String,
|
text: String,
|
||||||
sent_at: NaiveDateTime,
|
sent_at: NaiveDateTime,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync> ChatMessage<S> {
|
impl ChatMessage {
|
||||||
pub fn new(author: String, text: String, sent_at: NaiveDateTime) -> Self {
|
pub fn new(author: String, text: String, sent_at: NaiveDateTime) -> Self {
|
||||||
Self {
|
Self {
|
||||||
state_type: PhantomData,
|
|
||||||
author,
|
author,
|
||||||
text,
|
text,
|
||||||
sent_at,
|
sent_at,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||||
div()
|
div()
|
||||||
.flex()
|
.flex()
|
||||||
.flex_col()
|
.flex_col()
|
||||||
|
@ -118,20 +114,16 @@ mod stories {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct ChatPanelStory<S: 'static + Send + Sync> {
|
pub struct ChatPanelStory;
|
||||||
state_type: PhantomData<S>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync> ChatPanelStory<S> {
|
impl ChatPanelStory {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self {
|
Self
|
||||||
state_type: PhantomData,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||||
Story::container(cx)
|
Story::container(cx)
|
||||||
.child(Story::title_for::<_, ChatPanel<S>>(cx))
|
.child(Story::title_for::<_, ChatPanel>(cx))
|
||||||
.child(Story::label(cx, "Default"))
|
.child(Story::label(cx, "Default"))
|
||||||
.child(
|
.child(
|
||||||
Panel::new("chat-panel-1-outer", cx)
|
Panel::new("chat-panel-1-outer", cx)
|
||||||
|
|
|
@ -3,23 +3,18 @@ use crate::{
|
||||||
static_collab_panel_channels, static_collab_panel_current_call, v_stack, Icon, List,
|
static_collab_panel_channels, static_collab_panel_current_call, v_stack, Icon, List,
|
||||||
ListHeader, ToggleState,
|
ListHeader, ToggleState,
|
||||||
};
|
};
|
||||||
use std::marker::PhantomData;
|
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct CollabPanel<S: 'static + Send + Sync> {
|
pub struct CollabPanel {
|
||||||
id: ElementId,
|
id: ElementId,
|
||||||
state_type: PhantomData<S>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync> CollabPanel<S> {
|
impl CollabPanel {
|
||||||
pub fn new(id: impl Into<ElementId>) -> Self {
|
pub fn new(id: impl Into<ElementId>) -> Self {
|
||||||
Self {
|
Self { id: id.into() }
|
||||||
id: id.into(),
|
|
||||||
state_type: PhantomData,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||||
let theme = theme(cx);
|
let theme = theme(cx);
|
||||||
|
|
||||||
v_stack()
|
v_stack()
|
||||||
|
@ -99,20 +94,16 @@ mod stories {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct CollabPanelStory<S: 'static + Send + Sync> {
|
pub struct CollabPanelStory;
|
||||||
state_type: PhantomData<S>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync> CollabPanelStory<S> {
|
impl CollabPanelStory {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self {
|
Self
|
||||||
state_type: PhantomData,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||||
Story::container(cx)
|
Story::container(cx)
|
||||||
.child(Story::title_for::<_, CollabPanel<S>>(cx))
|
.child(Story::title_for::<_, CollabPanel>(cx))
|
||||||
.child(Story::label(cx, "Default"))
|
.child(Story::label(cx, "Default"))
|
||||||
.child(CollabPanel::new("collab-panel"))
|
.child(CollabPanel::new("collab-panel"))
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,23 +1,17 @@
|
||||||
use std::marker::PhantomData;
|
|
||||||
|
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
use crate::{example_editor_actions, OrderMethod, Palette};
|
use crate::{example_editor_actions, OrderMethod, Palette};
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct CommandPalette<S: 'static + Send + Sync> {
|
pub struct CommandPalette {
|
||||||
id: ElementId,
|
id: ElementId,
|
||||||
state_type: PhantomData<S>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync> CommandPalette<S> {
|
impl CommandPalette {
|
||||||
pub fn new(id: impl Into<ElementId>) -> Self {
|
pub fn new(id: impl Into<ElementId>) -> Self {
|
||||||
Self {
|
Self { id: id.into() }
|
||||||
id: id.into(),
|
|
||||||
state_type: PhantomData,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||||
div().id(self.id.clone()).child(
|
div().id(self.id.clone()).child(
|
||||||
Palette::new("palette")
|
Palette::new("palette")
|
||||||
.items(example_editor_actions())
|
.items(example_editor_actions())
|
||||||
|
@ -38,20 +32,16 @@ mod stories {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct CommandPaletteStory<S: 'static + Send + Sync> {
|
pub struct CommandPaletteStory;
|
||||||
state_type: PhantomData<S>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync> CommandPaletteStory<S> {
|
impl CommandPaletteStory {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self {
|
Self
|
||||||
state_type: PhantomData,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||||
Story::container(cx)
|
Story::container(cx)
|
||||||
.child(Story::title_for::<_, CommandPalette<S>>(cx))
|
.child(Story::title_for::<_, CommandPalette>(cx))
|
||||||
.child(Story::label(cx, "Default"))
|
.child(Story::label(cx, "Default"))
|
||||||
.child(CommandPalette::new("command-palette"))
|
.child(CommandPalette::new("command-palette"))
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
use crate::{prelude::*, ListItemVariant};
|
use crate::{prelude::*, ListItemVariant};
|
||||||
use crate::{v_stack, Label, List, ListEntry, ListItem, ListSeparator, ListSubHeader};
|
use crate::{v_stack, Label, List, ListEntry, ListItem, ListSeparator, ListSubHeader};
|
||||||
|
|
||||||
pub enum ContextMenuItem<S: 'static + Send + Sync> {
|
pub enum ContextMenuItem {
|
||||||
Header(SharedString),
|
Header(SharedString),
|
||||||
Entry(Label<S>),
|
Entry(Label),
|
||||||
Separator,
|
Separator,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync> ContextMenuItem<S> {
|
impl ContextMenuItem {
|
||||||
fn to_list_item(self) -> ListItem<S> {
|
fn to_list_item<V: 'static>(self) -> ListItem<V> {
|
||||||
match self {
|
match self {
|
||||||
ContextMenuItem::Header(label) => ListSubHeader::new(label).into(),
|
ContextMenuItem::Header(label) => ListSubHeader::new(label).into(),
|
||||||
ContextMenuItem::Entry(label) => {
|
ContextMenuItem::Entry(label) => {
|
||||||
|
@ -26,23 +26,23 @@ impl<S: 'static + Send + Sync> ContextMenuItem<S> {
|
||||||
Self::Separator
|
Self::Separator
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn entry(label: Label<S>) -> Self {
|
pub fn entry(label: Label) -> Self {
|
||||||
Self::Entry(label)
|
Self::Entry(label)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct ContextMenu<S: 'static + Send + Sync> {
|
pub struct ContextMenu {
|
||||||
items: Vec<ContextMenuItem<S>>,
|
items: Vec<ContextMenuItem>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync> ContextMenu<S> {
|
impl ContextMenu {
|
||||||
pub fn new(items: impl IntoIterator<Item = ContextMenuItem<S>>) -> Self {
|
pub fn new(items: impl IntoIterator<Item = ContextMenuItem>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
items: items.into_iter().collect(),
|
items: items.into_iter().collect(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn render(mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
fn render<S: 'static>(mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||||
let theme = theme(cx);
|
let theme = theme(cx);
|
||||||
|
|
||||||
v_stack()
|
v_stack()
|
||||||
|
@ -67,27 +67,21 @@ pub use stories::*;
|
||||||
|
|
||||||
#[cfg(feature = "stories")]
|
#[cfg(feature = "stories")]
|
||||||
mod stories {
|
mod stories {
|
||||||
use std::marker::PhantomData;
|
|
||||||
|
|
||||||
use crate::story::Story;
|
use crate::story::Story;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct ContextMenuStory<S: 'static + Send + Sync> {
|
pub struct ContextMenuStory;
|
||||||
state_type: PhantomData<S>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync> ContextMenuStory<S> {
|
impl ContextMenuStory {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self {
|
Self
|
||||||
state_type: PhantomData,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||||
Story::container(cx)
|
Story::container(cx)
|
||||||
.child(Story::title_for::<_, ContextMenu<S>>(cx))
|
.child(Story::title_for::<_, ContextMenu>(cx))
|
||||||
.child(Story::label(cx, "Default"))
|
.child(Story::label(cx, "Default"))
|
||||||
.child(ContextMenu::new([
|
.child(ContextMenu::new([
|
||||||
ContextMenuItem::header("Section header"),
|
ContextMenuItem::header("Section header"),
|
||||||
|
|
|
@ -1,22 +1,16 @@
|
||||||
use std::marker::PhantomData;
|
|
||||||
|
|
||||||
use crate::{prelude::*, Button, Label, LabelColor, Modal};
|
use crate::{prelude::*, Button, Label, LabelColor, Modal};
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct CopilotModal<S: 'static + Send + Sync + Clone> {
|
pub struct CopilotModal {
|
||||||
id: ElementId,
|
id: ElementId,
|
||||||
state_type: PhantomData<S>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync + Clone> CopilotModal<S> {
|
impl CopilotModal {
|
||||||
pub fn new(id: impl Into<ElementId>) -> Self {
|
pub fn new(id: impl Into<ElementId>) -> Self {
|
||||||
Self {
|
Self { id: id.into() }
|
||||||
id: id.into(),
|
|
||||||
state_type: PhantomData,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||||
div().id(self.id.clone()).child(
|
div().id(self.id.clone()).child(
|
||||||
Modal::new("some-id")
|
Modal::new("some-id")
|
||||||
.title("Connect Copilot to Zed")
|
.title("Connect Copilot to Zed")
|
||||||
|
@ -36,20 +30,16 @@ mod stories {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct CopilotModalStory<S: 'static + Send + Sync + Clone> {
|
pub struct CopilotModalStory;
|
||||||
state_type: PhantomData<S>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync + Clone> CopilotModalStory<S> {
|
impl CopilotModalStory {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self {
|
Self
|
||||||
state_type: PhantomData,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||||
Story::container(cx)
|
Story::container(cx)
|
||||||
.child(Story::title_for::<_, CopilotModal<S>>(cx))
|
.child(Story::title_for::<_, CopilotModal>(cx))
|
||||||
.child(Story::label(cx, "Default"))
|
.child(Story::label(cx, "Default"))
|
||||||
.child(CopilotModal::new("copilot-modal"))
|
.child(CopilotModal::new("copilot-modal"))
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,10 +10,10 @@ use crate::{
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct EditorPane {
|
pub struct EditorPane {
|
||||||
tabs: Vec<Tab<Self>>,
|
tabs: Vec<Tab>,
|
||||||
path: PathBuf,
|
path: PathBuf,
|
||||||
symbols: Vec<Symbol>,
|
symbols: Vec<Symbol>,
|
||||||
buffer: Buffer<Self>,
|
buffer: Buffer,
|
||||||
buffer_search: View<BufferSearch>,
|
buffer_search: View<BufferSearch>,
|
||||||
is_buffer_search_open: bool,
|
is_buffer_search_open: bool,
|
||||||
}
|
}
|
||||||
|
@ -21,10 +21,10 @@ pub struct EditorPane {
|
||||||
impl EditorPane {
|
impl EditorPane {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
cx: &mut WindowContext,
|
cx: &mut WindowContext,
|
||||||
tabs: Vec<Tab<Self>>,
|
tabs: Vec<Tab>,
|
||||||
path: PathBuf,
|
path: PathBuf,
|
||||||
symbols: Vec<Symbol>,
|
symbols: Vec<Symbol>,
|
||||||
buffer: Buffer<Self>,
|
buffer: Buffer,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self {
|
Self {
|
||||||
tabs,
|
tabs,
|
||||||
|
|
|
@ -1,23 +1,19 @@
|
||||||
use std::marker::PhantomData;
|
|
||||||
|
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
use crate::{Avatar, Player};
|
use crate::{Avatar, Player};
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct Facepile<S: 'static + Send + Sync> {
|
pub struct Facepile {
|
||||||
state_type: PhantomData<S>,
|
|
||||||
players: Vec<Player>,
|
players: Vec<Player>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync> Facepile<S> {
|
impl Facepile {
|
||||||
pub fn new<P: Iterator<Item = Player>>(players: P) -> Self {
|
pub fn new<P: Iterator<Item = Player>>(players: P) -> Self {
|
||||||
Self {
|
Self {
|
||||||
state_type: PhantomData,
|
|
||||||
players: players.collect(),
|
players: players.collect(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||||
let player_count = self.players.len();
|
let player_count = self.players.len();
|
||||||
let player_list = self.players.iter().enumerate().map(|(ix, player)| {
|
let player_list = self.players.iter().enumerate().map(|(ix, player)| {
|
||||||
let isnt_last = ix < player_count - 1;
|
let isnt_last = ix < player_count - 1;
|
||||||
|
@ -40,22 +36,18 @@ mod stories {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct FacepileStory<S: 'static + Send + Sync> {
|
pub struct FacepileStory;
|
||||||
state_type: PhantomData<S>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync> FacepileStory<S> {
|
impl FacepileStory {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self {
|
Self
|
||||||
state_type: PhantomData,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||||
let players = static_players();
|
let players = static_players();
|
||||||
|
|
||||||
Story::container(cx)
|
Story::container(cx)
|
||||||
.child(Story::title_for::<_, Facepile<S>>(cx))
|
.child(Story::title_for::<_, Facepile>(cx))
|
||||||
.child(Story::label(cx, "Default"))
|
.child(Story::label(cx, "Default"))
|
||||||
.child(
|
.child(
|
||||||
div()
|
div()
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
use std::marker::PhantomData;
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use gpui2::MouseButton;
|
use gpui2::MouseButton;
|
||||||
|
@ -6,19 +5,18 @@ use gpui2::MouseButton;
|
||||||
use crate::{h_stack, prelude::*};
|
use crate::{h_stack, prelude::*};
|
||||||
use crate::{ClickHandler, Icon, IconColor, IconElement};
|
use crate::{ClickHandler, Icon, IconColor, IconElement};
|
||||||
|
|
||||||
struct IconButtonHandlers<S: 'static + Send + Sync> {
|
struct IconButtonHandlers<S: 'static> {
|
||||||
click: Option<ClickHandler<S>>,
|
click: Option<ClickHandler<S>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync> Default for IconButtonHandlers<S> {
|
impl<S: 'static> Default for IconButtonHandlers<S> {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self { click: None }
|
Self { click: None }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct IconButton<S: 'static + Send + Sync> {
|
pub struct IconButton<S: 'static> {
|
||||||
state_type: PhantomData<S>,
|
|
||||||
id: ElementId,
|
id: ElementId,
|
||||||
icon: Icon,
|
icon: Icon,
|
||||||
color: IconColor,
|
color: IconColor,
|
||||||
|
@ -27,10 +25,9 @@ pub struct IconButton<S: 'static + Send + Sync> {
|
||||||
handlers: IconButtonHandlers<S>,
|
handlers: IconButtonHandlers<S>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync> IconButton<S> {
|
impl<S: 'static> IconButton<S> {
|
||||||
pub fn new(id: impl Into<ElementId>, icon: Icon) -> Self {
|
pub fn new(id: impl Into<ElementId>, icon: Icon) -> Self {
|
||||||
Self {
|
Self {
|
||||||
state_type: PhantomData,
|
|
||||||
id: id.into(),
|
id: id.into(),
|
||||||
icon,
|
icon,
|
||||||
color: IconColor::default(),
|
color: IconColor::default(),
|
||||||
|
@ -60,10 +57,7 @@ impl<S: 'static + Send + Sync> IconButton<S> {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn on_click(
|
pub fn on_click(mut self, handler: impl 'static + Fn(&mut S, &mut ViewContext<S>) + Send + Sync) -> Self {
|
||||||
mut self,
|
|
||||||
handler: impl Fn(&mut S, &mut ViewContext<S>) + 'static + Send + Sync,
|
|
||||||
) -> Self {
|
|
||||||
self.handlers.click = Some(Arc::new(handler));
|
self.handlers.click = Some(Arc::new(handler));
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,11 @@
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
use std::marker::PhantomData;
|
|
||||||
|
|
||||||
use strum::{EnumIter, IntoEnumIterator};
|
use strum::{EnumIter, IntoEnumIterator};
|
||||||
|
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct Keybinding<S: 'static + Send + Sync> {
|
pub struct Keybinding {
|
||||||
state_type: PhantomData<S>,
|
|
||||||
|
|
||||||
/// A keybinding consists of a key and a set of modifier keys.
|
/// A keybinding consists of a key and a set of modifier keys.
|
||||||
/// More then one keybinding produces a chord.
|
/// More then one keybinding produces a chord.
|
||||||
///
|
///
|
||||||
|
@ -16,10 +13,9 @@ pub struct Keybinding<S: 'static + Send + Sync> {
|
||||||
keybinding: Vec<(String, ModifierKeys)>,
|
keybinding: Vec<(String, ModifierKeys)>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync> Keybinding<S> {
|
impl Keybinding {
|
||||||
pub fn new(key: String, modifiers: ModifierKeys) -> Self {
|
pub fn new(key: String, modifiers: ModifierKeys) -> Self {
|
||||||
Self {
|
Self {
|
||||||
state_type: PhantomData,
|
|
||||||
keybinding: vec![(key, modifiers)],
|
keybinding: vec![(key, modifiers)],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,12 +25,11 @@ impl<S: 'static + Send + Sync> Keybinding<S> {
|
||||||
second_note: (String, ModifierKeys),
|
second_note: (String, ModifierKeys),
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self {
|
Self {
|
||||||
state_type: PhantomData,
|
|
||||||
keybinding: vec![first_note, second_note],
|
keybinding: vec![first_note, second_note],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||||
div()
|
div()
|
||||||
.flex()
|
.flex()
|
||||||
.gap_2()
|
.gap_2()
|
||||||
|
@ -55,20 +50,16 @@ impl<S: 'static + Send + Sync> Keybinding<S> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct Key<S: 'static + Send + Sync> {
|
pub struct Key {
|
||||||
state_type: PhantomData<S>,
|
|
||||||
key: SharedString,
|
key: SharedString,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync> Key<S> {
|
impl Key {
|
||||||
pub fn new(key: impl Into<SharedString>) -> Self {
|
pub fn new(key: impl Into<SharedString>) -> Self {
|
||||||
Self {
|
Self { key: key.into() }
|
||||||
state_type: PhantomData,
|
|
||||||
key: key.into(),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||||
let theme = theme(cx);
|
let theme = theme(cx);
|
||||||
|
|
||||||
div()
|
div()
|
||||||
|
@ -174,22 +165,18 @@ mod stories {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct KeybindingStory<S: 'static + Send + Sync + Clone> {
|
pub struct KeybindingStory;
|
||||||
state_type: PhantomData<S>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync + Clone> KeybindingStory<S> {
|
impl KeybindingStory {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self {
|
Self
|
||||||
state_type: PhantomData,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(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 all_modifier_permutations = ModifierKey::iter().permutations(2);
|
let all_modifier_permutations = ModifierKey::iter().permutations(2);
|
||||||
|
|
||||||
Story::container(cx)
|
Story::container(cx)
|
||||||
.child(Story::title_for::<_, Keybinding<S>>(cx))
|
.child(Story::title_for::<_, Keybinding>(cx))
|
||||||
.child(Story::label(cx, "Single Key"))
|
.child(Story::label(cx, "Single Key"))
|
||||||
.child(Keybinding::new("Z".to_string(), ModifierKeys::new()))
|
.child(Keybinding::new("Z".to_string(), ModifierKeys::new()))
|
||||||
.child(Story::label(cx, "Single Key with Modifier"))
|
.child(Story::label(cx, "Single Key with Modifier"))
|
||||||
|
|
|
@ -1,23 +1,17 @@
|
||||||
use std::marker::PhantomData;
|
|
||||||
|
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
use crate::{OrderMethod, Palette, PaletteItem};
|
use crate::{OrderMethod, Palette, PaletteItem};
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct LanguageSelector<S: 'static + Send + Sync + Clone> {
|
pub struct LanguageSelector {
|
||||||
id: ElementId,
|
id: ElementId,
|
||||||
state_type: PhantomData<S>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync + Clone> LanguageSelector<S> {
|
impl LanguageSelector {
|
||||||
pub fn new(id: impl Into<ElementId>) -> Self {
|
pub fn new(id: impl Into<ElementId>) -> Self {
|
||||||
Self {
|
Self { id: id.into() }
|
||||||
id: id.into(),
|
|
||||||
state_type: PhantomData,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||||
div().id(self.id.clone()).child(
|
div().id(self.id.clone()).child(
|
||||||
Palette::new("palette")
|
Palette::new("palette")
|
||||||
.items(vec![
|
.items(vec![
|
||||||
|
@ -49,20 +43,16 @@ mod stories {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct LanguageSelectorStory<S: 'static + Send + Sync + Clone> {
|
pub struct LanguageSelectorStory;
|
||||||
state_type: PhantomData<S>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync + Clone> LanguageSelectorStory<S> {
|
impl LanguageSelectorStory {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self {
|
Self
|
||||||
state_type: PhantomData,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||||
Story::container(cx)
|
Story::container(cx)
|
||||||
.child(Story::title_for::<_, LanguageSelector<S>>(cx))
|
.child(Story::title_for::<_, LanguageSelector>(cx))
|
||||||
.child(Story::label(cx, "Default"))
|
.child(Story::label(cx, "Default"))
|
||||||
.child(LanguageSelector::new("language-selector"))
|
.child(LanguageSelector::new("language-selector"))
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
use std::marker::PhantomData;
|
|
||||||
|
|
||||||
use gpui2::{div, relative, Div};
|
use gpui2::{div, relative, Div};
|
||||||
|
|
||||||
use crate::settings::user_settings;
|
use crate::settings::user_settings;
|
||||||
|
@ -18,8 +16,7 @@ pub enum ListItemVariant {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct ListHeader<S: 'static + Send + Sync> {
|
pub struct ListHeader {
|
||||||
state_type: PhantomData<S>,
|
|
||||||
label: SharedString,
|
label: SharedString,
|
||||||
left_icon: Option<Icon>,
|
left_icon: Option<Icon>,
|
||||||
variant: ListItemVariant,
|
variant: ListItemVariant,
|
||||||
|
@ -27,10 +24,9 @@ pub struct ListHeader<S: 'static + Send + Sync> {
|
||||||
toggleable: Toggleable,
|
toggleable: Toggleable,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync> ListHeader<S> {
|
impl ListHeader {
|
||||||
pub fn new(label: impl Into<SharedString>) -> Self {
|
pub fn new(label: impl Into<SharedString>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
state_type: PhantomData,
|
|
||||||
label: label.into(),
|
label: label.into(),
|
||||||
left_icon: None,
|
left_icon: None,
|
||||||
variant: ListItemVariant::default(),
|
variant: ListItemVariant::default(),
|
||||||
|
@ -59,7 +55,7 @@ impl<S: 'static + Send + Sync> ListHeader<S> {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
fn disclosure_control(&self) -> Div<S> {
|
fn disclosure_control<S: 'static>(&self) -> Div<S> {
|
||||||
let is_toggleable = self.toggleable != Toggleable::NotToggleable;
|
let is_toggleable = self.toggleable != Toggleable::NotToggleable;
|
||||||
let is_toggled = Toggleable::is_toggled(&self.toggleable);
|
let is_toggled = Toggleable::is_toggled(&self.toggleable);
|
||||||
|
|
||||||
|
@ -92,7 +88,7 @@ impl<S: 'static + Send + Sync> ListHeader<S> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||||
let theme = theme(cx);
|
let theme = theme(cx);
|
||||||
|
|
||||||
let is_toggleable = self.toggleable != Toggleable::NotToggleable;
|
let is_toggleable = self.toggleable != Toggleable::NotToggleable;
|
||||||
|
@ -135,17 +131,15 @@ impl<S: 'static + Send + Sync> ListHeader<S> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct ListSubHeader<S: 'static + Send + Sync> {
|
pub struct ListSubHeader {
|
||||||
state_type: PhantomData<S>,
|
|
||||||
label: SharedString,
|
label: SharedString,
|
||||||
left_icon: Option<Icon>,
|
left_icon: Option<Icon>,
|
||||||
variant: ListItemVariant,
|
variant: ListItemVariant,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync> ListSubHeader<S> {
|
impl ListSubHeader {
|
||||||
pub fn new(label: impl Into<SharedString>) -> Self {
|
pub fn new(label: impl Into<SharedString>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
state_type: PhantomData,
|
|
||||||
label: label.into(),
|
label: label.into(),
|
||||||
left_icon: None,
|
left_icon: None,
|
||||||
variant: ListItemVariant::default(),
|
variant: ListItemVariant::default(),
|
||||||
|
@ -157,7 +151,7 @@ impl<S: 'static + Send + Sync> ListSubHeader<S> {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||||
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()
|
||||||
|
@ -198,38 +192,38 @@ pub enum ListEntrySize {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub enum ListItem<S: 'static + Send + Sync> {
|
pub enum ListItem<S: 'static> {
|
||||||
Entry(ListEntry<S>),
|
Entry(ListEntry),
|
||||||
Details(ListDetailsEntry<S>),
|
Details(ListDetailsEntry<S>),
|
||||||
Separator(ListSeparator<S>),
|
Separator(ListSeparator),
|
||||||
Header(ListSubHeader<S>),
|
Header(ListSubHeader),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync> From<ListEntry<S>> for ListItem<S> {
|
impl<S: 'static> From<ListEntry> for ListItem<S> {
|
||||||
fn from(entry: ListEntry<S>) -> Self {
|
fn from(entry: ListEntry) -> Self {
|
||||||
Self::Entry(entry)
|
Self::Entry(entry)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync> From<ListDetailsEntry<S>> for ListItem<S> {
|
impl<S: 'static> From<ListDetailsEntry<S>> for ListItem<S> {
|
||||||
fn from(entry: ListDetailsEntry<S>) -> Self {
|
fn from(entry: ListDetailsEntry<S>) -> Self {
|
||||||
Self::Details(entry)
|
Self::Details(entry)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync> From<ListSeparator<S>> for ListItem<S> {
|
impl<S: 'static> From<ListSeparator> for ListItem<S> {
|
||||||
fn from(entry: ListSeparator<S>) -> Self {
|
fn from(entry: ListSeparator) -> Self {
|
||||||
Self::Separator(entry)
|
Self::Separator(entry)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync> From<ListSubHeader<S>> for ListItem<S> {
|
impl<S: 'static> From<ListSubHeader> for ListItem<S> {
|
||||||
fn from(entry: ListSubHeader<S>) -> Self {
|
fn from(entry: ListSubHeader) -> Self {
|
||||||
Self::Header(entry)
|
Self::Header(entry)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync> ListItem<S> {
|
impl<S: 'static> ListItem<S> {
|
||||||
fn render(self, view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
fn render(self, view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||||
match self {
|
match self {
|
||||||
ListItem::Entry(entry) => div().child(entry.render(view, cx)),
|
ListItem::Entry(entry) => div().child(entry.render(view, cx)),
|
||||||
|
@ -239,11 +233,11 @@ impl<S: 'static + Send + Sync> ListItem<S> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(label: Label<S>) -> Self {
|
pub fn new(label: Label) -> Self {
|
||||||
Self::Entry(ListEntry::new(label))
|
Self::Entry(ListEntry::new(label))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn as_entry(&mut self) -> Option<&mut ListEntry<S>> {
|
pub fn as_entry(&mut self) -> Option<&mut ListEntry> {
|
||||||
if let Self::Entry(entry) = self {
|
if let Self::Entry(entry) = self {
|
||||||
Some(entry)
|
Some(entry)
|
||||||
} else {
|
} else {
|
||||||
|
@ -253,10 +247,10 @@ impl<S: 'static + Send + Sync> ListItem<S> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct ListEntry<S: 'static + Send + Sync> {
|
pub struct ListEntry {
|
||||||
disclosure_control_style: DisclosureControlVisibility,
|
disclosure_control_style: DisclosureControlVisibility,
|
||||||
indent_level: u32,
|
indent_level: u32,
|
||||||
label: Option<Label<S>>,
|
label: Option<Label>,
|
||||||
left_content: Option<LeftContent>,
|
left_content: Option<LeftContent>,
|
||||||
variant: ListItemVariant,
|
variant: ListItemVariant,
|
||||||
size: ListEntrySize,
|
size: ListEntrySize,
|
||||||
|
@ -265,8 +259,8 @@ pub struct ListEntry<S: 'static + Send + Sync> {
|
||||||
overflow: OverflowStyle,
|
overflow: OverflowStyle,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync> ListEntry<S> {
|
impl ListEntry {
|
||||||
pub fn new(label: Label<S>) -> Self {
|
pub fn new(label: Label) -> Self {
|
||||||
Self {
|
Self {
|
||||||
disclosure_control_style: DisclosureControlVisibility::default(),
|
disclosure_control_style: DisclosureControlVisibility::default(),
|
||||||
indent_level: 0,
|
indent_level: 0,
|
||||||
|
@ -344,7 +338,10 @@ impl<S: 'static + Send + Sync> ListEntry<S> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn disclosure_control(&mut self, cx: &mut ViewContext<S>) -> Option<impl Component<S>> {
|
fn disclosure_control<V: 'static>(
|
||||||
|
&mut self,
|
||||||
|
cx: &mut ViewContext<V>,
|
||||||
|
) -> Option<impl Component<V>> {
|
||||||
let disclosure_control_icon = if let Some(ToggleState::Toggled) = self.toggle {
|
let disclosure_control_icon = if let Some(ToggleState::Toggled) = self.toggle {
|
||||||
IconElement::new(Icon::ChevronDown)
|
IconElement::new(Icon::ChevronDown)
|
||||||
} else {
|
} else {
|
||||||
|
@ -364,7 +361,7 @@ impl<S: 'static + Send + Sync> ListEntry<S> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
fn render<S: 'static>(mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||||
let settings = user_settings(cx);
|
let settings = user_settings(cx);
|
||||||
let theme = theme(cx);
|
let theme = theme(cx);
|
||||||
|
|
||||||
|
@ -420,18 +417,18 @@ impl<S: 'static + Send + Sync> ListEntry<S> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ListDetailsEntryHandlers<S: 'static + Send + Sync> {
|
struct ListDetailsEntryHandlers<S: 'static> {
|
||||||
click: Option<ClickHandler<S>>,
|
click: Option<ClickHandler<S>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync> Default for ListDetailsEntryHandlers<S> {
|
impl<S: 'static> Default for ListDetailsEntryHandlers<S> {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self { click: None }
|
Self { click: None }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct ListDetailsEntry<S: 'static + Send + Sync> {
|
pub struct ListDetailsEntry<S: 'static> {
|
||||||
label: SharedString,
|
label: SharedString,
|
||||||
meta: Option<SharedString>,
|
meta: Option<SharedString>,
|
||||||
left_content: Option<LeftContent>,
|
left_content: Option<LeftContent>,
|
||||||
|
@ -442,7 +439,7 @@ pub struct ListDetailsEntry<S: 'static + Send + Sync> {
|
||||||
seen: bool,
|
seen: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync> ListDetailsEntry<S> {
|
impl<S: 'static> ListDetailsEntry<S> {
|
||||||
pub fn new(label: impl Into<SharedString>) -> Self {
|
pub fn new(label: impl Into<SharedString>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
label: label.into(),
|
label: label.into(),
|
||||||
|
@ -520,18 +517,14 @@ impl<S: 'static + Send + Sync> ListDetailsEntry<S> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Component)]
|
#[derive(Clone, Component)]
|
||||||
pub struct ListSeparator<S: 'static + Send + Sync> {
|
pub struct ListSeparator;
|
||||||
state_type: PhantomData<S>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync> ListSeparator<S> {
|
impl ListSeparator {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self {
|
Self
|
||||||
state_type: PhantomData,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(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 theme = theme(cx);
|
||||||
|
|
||||||
div().h_px().w_full().bg(theme.border)
|
div().h_px().w_full().bg(theme.border)
|
||||||
|
@ -539,14 +532,14 @@ impl<S: 'static + Send + Sync> ListSeparator<S> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct List<S: 'static + Send + Sync> {
|
pub struct List<S: 'static> {
|
||||||
items: Vec<ListItem<S>>,
|
items: Vec<ListItem<S>>,
|
||||||
empty_message: SharedString,
|
empty_message: SharedString,
|
||||||
header: Option<ListHeader<S>>,
|
header: Option<ListHeader>,
|
||||||
toggleable: Toggleable,
|
toggleable: Toggleable,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync> List<S> {
|
impl<S: 'static> List<S> {
|
||||||
pub fn new(items: Vec<ListItem<S>>) -> Self {
|
pub fn new(items: Vec<ListItem<S>>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
items,
|
items,
|
||||||
|
@ -561,7 +554,7 @@ impl<S: 'static + Send + Sync> List<S> {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn header(mut self, header: ListHeader<S>) -> Self {
|
pub fn header(mut self, header: ListHeader) -> Self {
|
||||||
self.header = Some(header);
|
self.header = Some(header);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,25 +1,21 @@
|
||||||
use std::marker::PhantomData;
|
|
||||||
|
|
||||||
use gpui2::AnyElement;
|
use gpui2::AnyElement;
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
|
|
||||||
use crate::{h_stack, prelude::*, v_stack, Button, Icon, IconButton, Label};
|
use crate::{h_stack, prelude::*, v_stack, Button, Icon, IconButton, Label};
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct Modal<S: 'static + Send + Sync> {
|
pub struct Modal<S: 'static> {
|
||||||
id: ElementId,
|
id: ElementId,
|
||||||
state_type: PhantomData<S>,
|
|
||||||
title: Option<SharedString>,
|
title: Option<SharedString>,
|
||||||
primary_action: Option<Button<S>>,
|
primary_action: Option<Button<S>>,
|
||||||
secondary_action: Option<Button<S>>,
|
secondary_action: Option<Button<S>>,
|
||||||
children: SmallVec<[AnyElement<S>; 2]>,
|
children: SmallVec<[AnyElement<S>; 2]>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync> Modal<S> {
|
impl<S: 'static> Modal<S> {
|
||||||
pub fn new(id: impl Into<ElementId>) -> Self {
|
pub fn new(id: impl Into<ElementId>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
id: id.into(),
|
id: id.into(),
|
||||||
state_type: PhantomData,
|
|
||||||
title: None,
|
title: None,
|
||||||
primary_action: None,
|
primary_action: None,
|
||||||
secondary_action: None,
|
secondary_action: None,
|
||||||
|
@ -80,7 +76,7 @@ impl<S: 'static + Send + Sync> Modal<S> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync> ParentElement<S> for Modal<S> {
|
impl<S: 'static> ParentElement<S> for Modal<S> {
|
||||||
fn children_mut(&mut self) -> &mut SmallVec<[AnyElement<S>; 2]> {
|
fn children_mut(&mut self) -> &mut SmallVec<[AnyElement<S>; 2]> {
|
||||||
&mut self.children
|
&mut self.children
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,23 +1,17 @@
|
||||||
use std::marker::PhantomData;
|
|
||||||
|
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
use crate::{v_stack, Buffer, Icon, IconButton, Label};
|
use crate::{v_stack, Buffer, Icon, IconButton, Label};
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct MultiBuffer<S: 'static + Send + Sync + Clone> {
|
pub struct MultiBuffer {
|
||||||
state_type: PhantomData<S>,
|
buffers: Vec<Buffer>,
|
||||||
buffers: Vec<Buffer<S>>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync + Clone> MultiBuffer<S> {
|
impl MultiBuffer {
|
||||||
pub fn new(buffers: Vec<Buffer<S>>) -> Self {
|
pub fn new(buffers: Vec<Buffer>) -> Self {
|
||||||
Self {
|
Self { buffers }
|
||||||
state_type: PhantomData,
|
|
||||||
buffers,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(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 theme = theme(cx);
|
||||||
|
|
||||||
v_stack()
|
v_stack()
|
||||||
|
@ -51,22 +45,18 @@ mod stories {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct MultiBufferStory<S: 'static + Send + Sync + Clone> {
|
pub struct MultiBufferStory;
|
||||||
state_type: PhantomData<S>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync + Clone> MultiBufferStory<S> {
|
impl MultiBufferStory {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self {
|
Self
|
||||||
state_type: PhantomData,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(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 theme = theme(cx);
|
||||||
|
|
||||||
Story::container(cx)
|
Story::container(cx)
|
||||||
.child(Story::title_for::<_, MultiBuffer<S>>(cx))
|
.child(Story::title_for::<_, MultiBuffer>(cx))
|
||||||
.child(Story::label(cx, "Default"))
|
.child(Story::label(cx, "Default"))
|
||||||
.child(MultiBuffer::new(vec![
|
.child(MultiBuffer::new(vec![
|
||||||
hello_world_rust_buffer_example(&theme),
|
hello_world_rust_buffer_example(&theme),
|
||||||
|
|
|
@ -1,20 +1,16 @@
|
||||||
use std::marker::PhantomData;
|
|
||||||
|
|
||||||
use gpui2::rems;
|
use gpui2::rems;
|
||||||
|
|
||||||
use crate::{h_stack, prelude::*, Icon};
|
use crate::{h_stack, prelude::*, Icon};
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct NotificationToast<S: 'static + Send + Sync + Clone> {
|
pub struct NotificationToast {
|
||||||
state_type: PhantomData<S>,
|
|
||||||
label: SharedString,
|
label: SharedString,
|
||||||
icon: Option<Icon>,
|
icon: Option<Icon>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync + Clone> NotificationToast<S> {
|
impl NotificationToast {
|
||||||
pub fn new(label: SharedString) -> Self {
|
pub fn new(label: SharedString) -> Self {
|
||||||
Self {
|
Self {
|
||||||
state_type: PhantomData,
|
|
||||||
label,
|
label,
|
||||||
icon: None,
|
icon: None,
|
||||||
}
|
}
|
||||||
|
@ -28,7 +24,7 @@ impl<S: 'static + Send + Sync + Clone> NotificationToast<S> {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||||
let theme = theme(cx);
|
let theme = theme(cx);
|
||||||
|
|
||||||
h_stack()
|
h_stack()
|
||||||
|
|
|
@ -1,23 +1,20 @@
|
||||||
use std::marker::PhantomData;
|
|
||||||
|
|
||||||
use crate::{prelude::*, static_new_notification_items, static_read_notification_items};
|
use crate::{prelude::*, static_new_notification_items, static_read_notification_items};
|
||||||
use crate::{List, ListHeader};
|
use crate::{List, ListHeader};
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct NotificationsPanel<S: 'static + Send + Sync> {
|
pub struct NotificationsPanel {
|
||||||
id: ElementId,
|
id: ElementId,
|
||||||
state_type: PhantomData<S>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync> NotificationsPanel<S> {
|
impl NotificationsPanel {
|
||||||
pub fn new(id: impl Into<ElementId>) -> Self {
|
pub fn new(id: impl Into<ElementId>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
id: id.into(),
|
id: id.into(),
|
||||||
state_type: PhantomData,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||||
let theme = theme(cx);
|
let theme = theme(cx);
|
||||||
|
|
||||||
div()
|
div()
|
||||||
|
@ -59,20 +56,16 @@ mod stories {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct NotificationsPanelStory<S: 'static + Send + Sync + Clone> {
|
pub struct NotificationsPanelStory;
|
||||||
state_type: PhantomData<S>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync + Clone> NotificationsPanelStory<S> {
|
impl NotificationsPanelStory {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self {
|
Self
|
||||||
state_type: PhantomData,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(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)
|
Story::container(cx)
|
||||||
.child(Story::title_for::<_, NotificationsPanel<S>>(cx))
|
.child(Story::title_for::<_, NotificationsPanel>(cx))
|
||||||
.child(Story::label(cx, "Default"))
|
.child(Story::label(cx, "Default"))
|
||||||
.child(
|
.child(
|
||||||
Panel::new("panel", cx).child(NotificationsPanel::new("notifications_panel")),
|
Panel::new("panel", cx).child(NotificationsPanel::new("notifications_panel")),
|
||||||
|
|
|
@ -1,23 +1,19 @@
|
||||||
use std::marker::PhantomData;
|
|
||||||
|
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
use crate::{h_stack, v_stack, Keybinding, Label, LabelColor};
|
use crate::{h_stack, v_stack, Keybinding, Label, LabelColor};
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct Palette<S: 'static + Send + Sync> {
|
pub struct Palette {
|
||||||
id: ElementId,
|
id: ElementId,
|
||||||
state_type: PhantomData<S>,
|
|
||||||
input_placeholder: SharedString,
|
input_placeholder: SharedString,
|
||||||
empty_string: SharedString,
|
empty_string: SharedString,
|
||||||
items: Vec<PaletteItem<S>>,
|
items: Vec<PaletteItem>,
|
||||||
default_order: OrderMethod,
|
default_order: OrderMethod,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync> Palette<S> {
|
impl Palette {
|
||||||
pub fn new(id: impl Into<ElementId>) -> Self {
|
pub fn new(id: impl Into<ElementId>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
id: id.into(),
|
id: id.into(),
|
||||||
state_type: PhantomData,
|
|
||||||
input_placeholder: "Find something...".into(),
|
input_placeholder: "Find something...".into(),
|
||||||
empty_string: "No items found.".into(),
|
empty_string: "No items found.".into(),
|
||||||
items: vec![],
|
items: vec![],
|
||||||
|
@ -25,7 +21,7 @@ impl<S: 'static + Send + Sync> Palette<S> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn items(mut self, items: Vec<PaletteItem<S>>) -> Self {
|
pub fn items(mut self, items: Vec<PaletteItem>) -> Self {
|
||||||
self.items = items;
|
self.items = items;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
@ -46,7 +42,7 @@ impl<S: 'static + Send + Sync> Palette<S> {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
fn render<S: 'static>(mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||||
let theme = theme(cx);
|
let theme = theme(cx);
|
||||||
|
|
||||||
v_stack()
|
v_stack()
|
||||||
|
@ -102,13 +98,13 @@ impl<S: 'static + Send + Sync> Palette<S> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct PaletteItem<S: 'static + Send + Sync> {
|
pub struct PaletteItem {
|
||||||
pub label: SharedString,
|
pub label: SharedString,
|
||||||
pub sublabel: Option<SharedString>,
|
pub sublabel: Option<SharedString>,
|
||||||
pub keybinding: Option<Keybinding<S>>,
|
pub keybinding: Option<Keybinding>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync> PaletteItem<S> {
|
impl PaletteItem {
|
||||||
pub fn new(label: impl Into<SharedString>) -> Self {
|
pub fn new(label: impl Into<SharedString>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
label: label.into(),
|
label: label.into(),
|
||||||
|
@ -129,13 +125,13 @@ impl<S: 'static + Send + Sync> PaletteItem<S> {
|
||||||
|
|
||||||
pub fn keybinding<K>(mut self, keybinding: K) -> Self
|
pub fn keybinding<K>(mut self, keybinding: K) -> Self
|
||||||
where
|
where
|
||||||
K: Into<Option<Keybinding<S>>>,
|
K: Into<Option<Keybinding>>,
|
||||||
{
|
{
|
||||||
self.keybinding = keybinding.into();
|
self.keybinding = keybinding.into();
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
fn render<S: 'static>(mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||||
div()
|
div()
|
||||||
.flex()
|
.flex()
|
||||||
.flex_row()
|
.flex_row()
|
||||||
|
@ -161,20 +157,16 @@ mod stories {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct PaletteStory<S: 'static + Send + Sync + Clone> {
|
pub struct PaletteStory;
|
||||||
state_type: PhantomData<S>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync + Clone> PaletteStory<S> {
|
impl PaletteStory {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self {
|
Self
|
||||||
state_type: PhantomData,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(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)
|
Story::container(cx)
|
||||||
.child(Story::title_for::<_, Palette<S>>(cx))
|
.child(Story::title_for::<_, Palette>(cx))
|
||||||
.child(Story::label(cx, "Default"))
|
.child(Story::label(cx, "Default"))
|
||||||
.child(Palette::new("palette-1"))
|
.child(Palette::new("palette-1"))
|
||||||
.child(Story::label(cx, "With Items"))
|
.child(Story::label(cx, "With Items"))
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
use std::marker::PhantomData;
|
|
||||||
|
|
||||||
use gpui2::{AbsoluteLength, AnyElement};
|
use gpui2::{AbsoluteLength, AnyElement};
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
|
|
||||||
|
@ -41,9 +39,8 @@ pub enum PanelSide {
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct Panel<S: 'static + Send + Sync> {
|
pub struct Panel<S: 'static> {
|
||||||
id: ElementId,
|
id: ElementId,
|
||||||
state_type: PhantomData<S>,
|
|
||||||
current_side: PanelSide,
|
current_side: PanelSide,
|
||||||
/// Defaults to PanelAllowedSides::LeftAndRight
|
/// Defaults to PanelAllowedSides::LeftAndRight
|
||||||
allowed_sides: PanelAllowedSides,
|
allowed_sides: PanelAllowedSides,
|
||||||
|
@ -52,13 +49,12 @@ pub struct Panel<S: 'static + Send + Sync> {
|
||||||
children: SmallVec<[AnyElement<S>; 2]>,
|
children: SmallVec<[AnyElement<S>; 2]>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync> Panel<S> {
|
impl<S: 'static> Panel<S> {
|
||||||
pub fn new(id: impl Into<ElementId>, cx: &mut WindowContext) -> Self {
|
pub fn new(id: impl Into<ElementId>, cx: &mut WindowContext) -> Self {
|
||||||
let settings = user_settings(cx);
|
let settings = user_settings(cx);
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
id: id.into(),
|
id: id.into(),
|
||||||
state_type: PhantomData,
|
|
||||||
current_side: PanelSide::default(),
|
current_side: PanelSide::default(),
|
||||||
allowed_sides: PanelAllowedSides::default(),
|
allowed_sides: PanelAllowedSides::default(),
|
||||||
initial_width: *settings.default_panel_size,
|
initial_width: *settings.default_panel_size,
|
||||||
|
@ -121,7 +117,7 @@ impl<S: 'static + Send + Sync> Panel<S> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync> ParentElement<S> for Panel<S> {
|
impl<S: 'static> ParentElement<S> for Panel<S> {
|
||||||
fn children_mut(&mut self) -> &mut SmallVec<[AnyElement<S>; 2]> {
|
fn children_mut(&mut self) -> &mut SmallVec<[AnyElement<S>; 2]> {
|
||||||
&mut self.children
|
&mut self.children
|
||||||
}
|
}
|
||||||
|
@ -137,18 +133,14 @@ mod stories {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct PanelStory<S: 'static + Send + Sync + Clone> {
|
pub struct PanelStory;
|
||||||
state_type: PhantomData<S>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync + Clone> PanelStory<S> {
|
impl PanelStory {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self {
|
Self
|
||||||
state_type: PhantomData,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||||
Story::container(cx)
|
Story::container(cx)
|
||||||
.child(Story::title_for::<_, Panel<S>>(cx))
|
.child(Story::title_for::<_, Panel<S>>(cx))
|
||||||
.child(Story::label(cx, "Default"))
|
.child(Story::label(cx, "Default"))
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
use std::marker::PhantomData;
|
|
||||||
|
|
||||||
use gpui2::{hsla, red, AnyElement, ElementId, ExternalPaths, Hsla, Length, Size};
|
use gpui2::{hsla, red, AnyElement, ElementId, ExternalPaths, Hsla, Length, Size};
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
|
|
||||||
|
@ -76,17 +74,15 @@ impl<V: 'static> ParentElement<V> for Pane<V> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct PaneGroup<V: 'static + Send + Sync> {
|
pub struct PaneGroup<V: 'static> {
|
||||||
state_type: PhantomData<V>,
|
|
||||||
groups: Vec<PaneGroup<V>>,
|
groups: Vec<PaneGroup<V>>,
|
||||||
panes: Vec<Pane<V>>,
|
panes: Vec<Pane<V>>,
|
||||||
split_direction: SplitDirection,
|
split_direction: SplitDirection,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<V: 'static + Send + Sync> PaneGroup<V> {
|
impl<V: 'static> PaneGroup<V> {
|
||||||
pub fn new_groups(groups: Vec<PaneGroup<V>>, split_direction: SplitDirection) -> Self {
|
pub fn new_groups(groups: Vec<PaneGroup<V>>, split_direction: SplitDirection) -> Self {
|
||||||
Self {
|
Self {
|
||||||
state_type: PhantomData,
|
|
||||||
groups,
|
groups,
|
||||||
panes: Vec::new(),
|
panes: Vec::new(),
|
||||||
split_direction,
|
split_direction,
|
||||||
|
@ -95,7 +91,6 @@ impl<V: 'static + Send + Sync> PaneGroup<V> {
|
||||||
|
|
||||||
pub fn new_panes(panes: Vec<Pane<V>>, split_direction: SplitDirection) -> Self {
|
pub fn new_panes(panes: Vec<Pane<V>>, split_direction: SplitDirection) -> Self {
|
||||||
Self {
|
Self {
|
||||||
state_type: PhantomData,
|
|
||||||
groups: Vec::new(),
|
groups: Vec::new(),
|
||||||
panes,
|
panes,
|
||||||
split_direction,
|
split_direction,
|
||||||
|
|
|
@ -1,23 +1,19 @@
|
||||||
use std::marker::PhantomData;
|
|
||||||
|
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
use crate::{Avatar, Facepile, PlayerWithCallStatus};
|
use crate::{Avatar, Facepile, PlayerWithCallStatus};
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct PlayerStack<S: 'static + Send + Sync> {
|
pub struct PlayerStack {
|
||||||
state_type: PhantomData<S>,
|
|
||||||
player_with_call_status: PlayerWithCallStatus,
|
player_with_call_status: PlayerWithCallStatus,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync> PlayerStack<S> {
|
impl PlayerStack {
|
||||||
pub fn new(player_with_call_status: PlayerWithCallStatus) -> Self {
|
pub fn new(player_with_call_status: PlayerWithCallStatus) -> Self {
|
||||||
Self {
|
Self {
|
||||||
state_type: PhantomData,
|
|
||||||
player_with_call_status,
|
player_with_call_status,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||||
let theme = theme(cx);
|
let theme = theme(cx);
|
||||||
let player = self.player_with_call_status.get_player();
|
let player = self.player_with_call_status.get_player();
|
||||||
self.player_with_call_status.get_call_status();
|
self.player_with_call_status.get_call_status();
|
||||||
|
|
|
@ -1,25 +1,19 @@
|
||||||
use std::marker::PhantomData;
|
|
||||||
|
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
use crate::{
|
use crate::{
|
||||||
static_project_panel_project_items, static_project_panel_single_items, Input, List, ListHeader,
|
static_project_panel_project_items, static_project_panel_single_items, Input, List, ListHeader,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct ProjectPanel<S: 'static + Send + Sync> {
|
pub struct ProjectPanel {
|
||||||
id: ElementId,
|
id: ElementId,
|
||||||
state_type: PhantomData<S>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync> ProjectPanel<S> {
|
impl ProjectPanel {
|
||||||
pub fn new(id: impl Into<ElementId>) -> Self {
|
pub fn new(id: impl Into<ElementId>) -> Self {
|
||||||
Self {
|
Self { id: id.into() }
|
||||||
id: id.into(),
|
|
||||||
state_type: PhantomData,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||||
let theme = theme(cx);
|
let theme = theme(cx);
|
||||||
|
|
||||||
div()
|
div()
|
||||||
|
@ -68,20 +62,16 @@ mod stories {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct ProjectPanelStory<S: 'static + Send + Sync + Clone> {
|
pub struct ProjectPanelStory;
|
||||||
state_type: PhantomData<S>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync + Clone> ProjectPanelStory<S> {
|
impl ProjectPanelStory {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self {
|
Self
|
||||||
state_type: PhantomData,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||||
Story::container(cx)
|
Story::container(cx)
|
||||||
.child(Story::title_for::<_, ProjectPanel<S>>(cx))
|
.child(Story::title_for::<_, ProjectPanel>(cx))
|
||||||
.child(Story::label(cx, "Default"))
|
.child(Story::label(cx, "Default"))
|
||||||
.child(
|
.child(
|
||||||
Panel::new("project-panel-outer", cx)
|
Panel::new("project-panel-outer", cx)
|
||||||
|
|
|
@ -1,23 +1,17 @@
|
||||||
use std::marker::PhantomData;
|
|
||||||
|
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
use crate::{OrderMethod, Palette, PaletteItem};
|
use crate::{OrderMethod, Palette, PaletteItem};
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct RecentProjects<S: 'static + Send + Sync + Clone> {
|
pub struct RecentProjects {
|
||||||
id: ElementId,
|
id: ElementId,
|
||||||
state_type: PhantomData<S>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync + Clone> RecentProjects<S> {
|
impl RecentProjects {
|
||||||
pub fn new(id: impl Into<ElementId>) -> Self {
|
pub fn new(id: impl Into<ElementId>) -> Self {
|
||||||
Self {
|
Self { id: id.into() }
|
||||||
id: id.into(),
|
|
||||||
state_type: PhantomData,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||||
div().id(self.id.clone()).child(
|
div().id(self.id.clone()).child(
|
||||||
Palette::new("palette")
|
Palette::new("palette")
|
||||||
.items(vec![
|
.items(vec![
|
||||||
|
@ -45,20 +39,16 @@ mod stories {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct RecentProjectsStory<S: 'static + Send + Sync + Clone> {
|
pub struct RecentProjectsStory;
|
||||||
state_type: PhantomData<S>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync + Clone> RecentProjectsStory<S> {
|
impl RecentProjectsStory {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self {
|
Self
|
||||||
state_type: PhantomData,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||||
Story::container(cx)
|
Story::container(cx)
|
||||||
.child(Story::title_for::<_, RecentProjects<S>>(cx))
|
.child(Story::title_for::<_, RecentProjects>(cx))
|
||||||
.child(Story::label(cx, "Default"))
|
.child(Story::label(cx, "Default"))
|
||||||
.child(RecentProjects::new("recent-projects"))
|
.child(RecentProjects::new("recent-projects"))
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,8 @@
|
||||||
use std::marker::PhantomData;
|
|
||||||
|
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
use crate::{Icon, IconColor, IconElement, Label, LabelColor};
|
use crate::{Icon, IconColor, IconElement, Label, LabelColor};
|
||||||
|
|
||||||
#[derive(Component, Clone)]
|
#[derive(Component, Clone)]
|
||||||
pub struct Tab<S: 'static + Send + Sync + Clone> {
|
pub struct Tab {
|
||||||
state_type: PhantomData<S>,
|
|
||||||
id: ElementId,
|
id: ElementId,
|
||||||
title: String,
|
title: String,
|
||||||
icon: Option<Icon>,
|
icon: Option<Icon>,
|
||||||
|
@ -22,10 +19,9 @@ struct TabDragState {
|
||||||
title: String,
|
title: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync + Clone> Tab<S> {
|
impl Tab {
|
||||||
pub fn new(id: impl Into<ElementId>) -> Self {
|
pub fn new(id: impl Into<ElementId>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
state_type: PhantomData,
|
|
||||||
id: id.into(),
|
id: id.into(),
|
||||||
title: "untitled".to_string(),
|
title: "untitled".to_string(),
|
||||||
icon: None,
|
icon: None,
|
||||||
|
@ -81,7 +77,7 @@ impl<S: 'static + Send + Sync + Clone> Tab<S> {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(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 theme = theme(cx);
|
||||||
let has_fs_conflict = self.fs_status == FileSystemStatus::Conflict;
|
let has_fs_conflict = self.fs_status == FileSystemStatus::Conflict;
|
||||||
let is_deleted = self.fs_status == FileSystemStatus::Deleted;
|
let is_deleted = self.fs_status == FileSystemStatus::Deleted;
|
||||||
|
@ -177,23 +173,19 @@ mod stories {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct TabStory<S: 'static + Send + Sync + Clone> {
|
pub struct TabStory;
|
||||||
state_type: PhantomData<S>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync + Clone> TabStory<S> {
|
impl TabStory {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self {
|
Self
|
||||||
state_type: PhantomData,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(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 git_statuses = GitStatus::iter();
|
let git_statuses = GitStatus::iter();
|
||||||
let fs_statuses = FileSystemStatus::iter();
|
let fs_statuses = FileSystemStatus::iter();
|
||||||
|
|
||||||
Story::container(cx)
|
Story::container(cx)
|
||||||
.child(Story::title_for::<_, Tab<S>>(cx))
|
.child(Story::title_for::<_, Tab>(cx))
|
||||||
.child(
|
.child(
|
||||||
h_stack().child(
|
h_stack().child(
|
||||||
v_stack()
|
v_stack()
|
||||||
|
|
|
@ -1,22 +1,18 @@
|
||||||
use std::marker::PhantomData;
|
|
||||||
|
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
use crate::{Icon, IconButton, Tab};
|
use crate::{Icon, IconButton, Tab};
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct TabBar<S: 'static + Send + Sync + Clone> {
|
pub struct TabBar {
|
||||||
id: ElementId,
|
id: ElementId,
|
||||||
state_type: PhantomData<S>,
|
|
||||||
/// Backwards, Forwards
|
/// Backwards, Forwards
|
||||||
can_navigate: (bool, bool),
|
can_navigate: (bool, bool),
|
||||||
tabs: Vec<Tab<S>>,
|
tabs: Vec<Tab>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync + Clone> TabBar<S> {
|
impl TabBar {
|
||||||
pub fn new(id: impl Into<ElementId>, tabs: Vec<Tab<S>>) -> Self {
|
pub fn new(id: impl Into<ElementId>, tabs: Vec<Tab>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
id: id.into(),
|
id: id.into(),
|
||||||
state_type: PhantomData,
|
|
||||||
can_navigate: (false, false),
|
can_navigate: (false, false),
|
||||||
tabs,
|
tabs,
|
||||||
}
|
}
|
||||||
|
@ -27,7 +23,7 @@ impl<S: 'static + Send + Sync + Clone> TabBar<S> {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||||
let theme = theme(cx);
|
let theme = theme(cx);
|
||||||
|
|
||||||
let (can_navigate_back, can_navigate_forward) = self.can_navigate;
|
let (can_navigate_back, can_navigate_forward) = self.can_navigate;
|
||||||
|
@ -101,20 +97,16 @@ mod stories {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct TabBarStory<S: 'static + Send + Sync + Clone> {
|
pub struct TabBarStory;
|
||||||
state_type: PhantomData<S>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync + Clone> TabBarStory<S> {
|
impl TabBarStory {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self {
|
Self
|
||||||
state_type: PhantomData,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||||
Story::container(cx)
|
Story::container(cx)
|
||||||
.child(Story::title_for::<_, TabBar<S>>(cx))
|
.child(Story::title_for::<_, TabBar>(cx))
|
||||||
.child(Story::label(cx, "Default"))
|
.child(Story::label(cx, "Default"))
|
||||||
.child(TabBar::new(
|
.child(TabBar::new(
|
||||||
"tab-bar",
|
"tab-bar",
|
||||||
|
|
|
@ -1,23 +1,17 @@
|
||||||
use std::marker::PhantomData;
|
|
||||||
|
|
||||||
use gpui2::{relative, rems, Size};
|
use gpui2::{relative, rems, Size};
|
||||||
|
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
use crate::{Icon, IconButton, Pane, Tab};
|
use crate::{Icon, IconButton, Pane, Tab};
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct Terminal<S: 'static + Send + Sync + Clone> {
|
pub struct Terminal;
|
||||||
state_type: PhantomData<S>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync + Clone> Terminal<S> {
|
impl Terminal {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self {
|
Self
|
||||||
state_type: PhantomData,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||||
let theme = theme(cx);
|
let theme = theme(cx);
|
||||||
|
|
||||||
let can_navigate_back = true;
|
let can_navigate_back = true;
|
||||||
|
@ -94,20 +88,16 @@ mod stories {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct TerminalStory<S: 'static + Send + Sync + Clone> {
|
pub struct TerminalStory;
|
||||||
state_type: PhantomData<S>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync + Clone> TerminalStory<S> {
|
impl TerminalStory {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self {
|
Self
|
||||||
state_type: PhantomData,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||||
Story::container(cx)
|
Story::container(cx)
|
||||||
.child(Story::title_for::<_, Terminal<S>>(cx))
|
.child(Story::title_for::<_, Terminal>(cx))
|
||||||
.child(Story::label(cx, "Default"))
|
.child(Story::label(cx, "Default"))
|
||||||
.child(Terminal::new())
|
.child(Terminal::new())
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,23 +1,17 @@
|
||||||
use std::marker::PhantomData;
|
|
||||||
|
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
use crate::{OrderMethod, Palette, PaletteItem};
|
use crate::{OrderMethod, Palette, PaletteItem};
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct ThemeSelector<S: 'static + Send + Sync> {
|
pub struct ThemeSelector {
|
||||||
id: ElementId,
|
id: ElementId,
|
||||||
state_type: PhantomData<S>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync> ThemeSelector<S> {
|
impl ThemeSelector {
|
||||||
pub fn new(id: impl Into<ElementId>) -> Self {
|
pub fn new(id: impl Into<ElementId>) -> Self {
|
||||||
Self {
|
Self { id: id.into() }
|
||||||
id: id.into(),
|
|
||||||
state_type: PhantomData,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||||
div().child(
|
div().child(
|
||||||
Palette::new(self.id.clone())
|
Palette::new(self.id.clone())
|
||||||
.items(vec![
|
.items(vec![
|
||||||
|
@ -50,20 +44,16 @@ mod stories {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct ThemeSelectorStory<S: 'static + Send + Sync + Clone> {
|
pub struct ThemeSelectorStory;
|
||||||
state_type: PhantomData<S>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync + Clone> ThemeSelectorStory<S> {
|
impl ThemeSelectorStory {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self {
|
Self
|
||||||
state_type: PhantomData,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||||
Story::container(cx)
|
Story::container(cx)
|
||||||
.child(Story::title_for::<_, ThemeSelector<S>>(cx))
|
.child(Story::title_for::<_, ThemeSelector>(cx))
|
||||||
.child(Story::label(cx, "Default"))
|
.child(Story::label(cx, "Default"))
|
||||||
.child(ThemeSelector::new("theme-selector"))
|
.child(ThemeSelector::new("theme-selector"))
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,12 +23,12 @@ pub enum ToastOrigin {
|
||||||
///
|
///
|
||||||
/// Only one toast may be visible at a time.
|
/// Only one toast may be visible at a time.
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct Toast<S: 'static + Send + Sync> {
|
pub struct Toast<S: 'static> {
|
||||||
origin: ToastOrigin,
|
origin: ToastOrigin,
|
||||||
children: SmallVec<[AnyElement<S>; 2]>,
|
children: SmallVec<[AnyElement<S>; 2]>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync> Toast<S> {
|
impl<S: 'static> Toast<S> {
|
||||||
pub fn new(origin: ToastOrigin) -> Self {
|
pub fn new(origin: ToastOrigin) -> Self {
|
||||||
Self {
|
Self {
|
||||||
origin,
|
origin,
|
||||||
|
@ -61,7 +61,7 @@ impl<S: 'static + Send + Sync> Toast<S> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync> ParentElement<S> for Toast<S> {
|
impl<S: 'static> ParentElement<S> for Toast<S> {
|
||||||
fn children_mut(&mut self) -> &mut SmallVec<[AnyElement<S>; 2]> {
|
fn children_mut(&mut self) -> &mut SmallVec<[AnyElement<S>; 2]> {
|
||||||
&mut self.children
|
&mut self.children
|
||||||
}
|
}
|
||||||
|
@ -72,25 +72,19 @@ pub use stories::*;
|
||||||
|
|
||||||
#[cfg(feature = "stories")]
|
#[cfg(feature = "stories")]
|
||||||
mod stories {
|
mod stories {
|
||||||
use std::marker::PhantomData;
|
|
||||||
|
|
||||||
use crate::{Label, Story};
|
use crate::{Label, Story};
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct ToastStory<S: 'static + Send + Sync> {
|
pub struct ToastStory;
|
||||||
state_type: PhantomData<S>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync> ToastStory<S> {
|
impl ToastStory {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self {
|
Self
|
||||||
state_type: PhantomData,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||||
Story::container(cx)
|
Story::container(cx)
|
||||||
.child(Story::title_for::<_, Toast<S>>(cx))
|
.child(Story::title_for::<_, Toast<S>>(cx))
|
||||||
.child(Story::label(cx, "Default"))
|
.child(Story::label(cx, "Default"))
|
||||||
|
|
|
@ -7,12 +7,12 @@ use crate::prelude::*;
|
||||||
pub struct ToolbarItem {}
|
pub struct ToolbarItem {}
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct Toolbar<S: 'static + Send + Sync> {
|
pub struct Toolbar<S: 'static> {
|
||||||
left_items: SmallVec<[AnyElement<S>; 2]>,
|
left_items: SmallVec<[AnyElement<S>; 2]>,
|
||||||
right_items: SmallVec<[AnyElement<S>; 2]>,
|
right_items: SmallVec<[AnyElement<S>; 2]>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync> Toolbar<S> {
|
impl<S: 'static> Toolbar<S> {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self {
|
Self {
|
||||||
left_items: SmallVec::new(),
|
left_items: SmallVec::new(),
|
||||||
|
@ -72,7 +72,6 @@ pub use stories::*;
|
||||||
|
|
||||||
#[cfg(feature = "stories")]
|
#[cfg(feature = "stories")]
|
||||||
mod stories {
|
mod stories {
|
||||||
use std::marker::PhantomData;
|
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
|
@ -81,22 +80,18 @@ mod stories {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct ToolbarStory<S: 'static + Send + Sync + Clone> {
|
pub struct ToolbarStory;
|
||||||
state_type: PhantomData<S>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync + Clone> ToolbarStory<S> {
|
impl ToolbarStory {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self {
|
Self
|
||||||
state_type: PhantomData,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(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 theme = theme(cx);
|
||||||
|
|
||||||
Story::container(cx)
|
Story::container(cx)
|
||||||
.child(Story::title_for::<_, Toolbar<S>>(cx))
|
.child(Story::title_for::<_, Toolbar<V>>(cx))
|
||||||
.child(Story::label(cx, "Default"))
|
.child(Story::label(cx, "Default"))
|
||||||
.child(
|
.child(
|
||||||
Toolbar::new()
|
Toolbar::new()
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
use std::marker::PhantomData;
|
|
||||||
|
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
#[derive(Clone, Copy)]
|
#[derive(Clone, Copy)]
|
||||||
|
@ -10,22 +8,20 @@ enum TrafficLightColor {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
struct TrafficLight<S: 'static + Send + Sync> {
|
struct TrafficLight {
|
||||||
state_type: PhantomData<S>,
|
|
||||||
color: TrafficLightColor,
|
color: TrafficLightColor,
|
||||||
window_has_focus: bool,
|
window_has_focus: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync> TrafficLight<S> {
|
impl TrafficLight {
|
||||||
fn new(color: TrafficLightColor, window_has_focus: bool) -> Self {
|
fn new(color: TrafficLightColor, window_has_focus: bool) -> Self {
|
||||||
Self {
|
Self {
|
||||||
state_type: PhantomData,
|
|
||||||
color,
|
color,
|
||||||
window_has_focus,
|
window_has_focus,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||||
let theme = theme(cx);
|
let theme = theme(cx);
|
||||||
|
|
||||||
let fill = match (self.window_has_focus, self.color) {
|
let fill = match (self.window_has_focus, self.color) {
|
||||||
|
@ -40,15 +36,13 @@ impl<S: 'static + Send + Sync> TrafficLight<S> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct TrafficLights<S: 'static + Send + Sync> {
|
pub struct TrafficLights {
|
||||||
state_type: PhantomData<S>,
|
|
||||||
window_has_focus: bool,
|
window_has_focus: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync> TrafficLights<S> {
|
impl TrafficLights {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self {
|
Self {
|
||||||
state_type: PhantomData,
|
|
||||||
window_has_focus: true,
|
window_has_focus: true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -58,7 +52,7 @@ impl<S: 'static + Send + Sync> TrafficLights<S> {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||||
div()
|
div()
|
||||||
.flex()
|
.flex()
|
||||||
.items_center()
|
.items_center()
|
||||||
|
@ -88,20 +82,16 @@ mod stories {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct TrafficLightsStory<S: 'static + Send + Sync> {
|
pub struct TrafficLightsStory;
|
||||||
state_type: PhantomData<S>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync> TrafficLightsStory<S> {
|
impl TrafficLightsStory {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self {
|
Self
|
||||||
state_type: PhantomData,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(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)
|
Story::container(cx)
|
||||||
.child(Story::title_for::<_, TrafficLights<S>>(cx))
|
.child(Story::title_for::<_, TrafficLights>(cx))
|
||||||
.child(Story::label(cx, "Default"))
|
.child(Story::label(cx, "Default"))
|
||||||
.child(TrafficLights::new())
|
.child(TrafficLights::new())
|
||||||
.child(Story::label(cx, "Unfocused"))
|
.child(Story::label(cx, "Unfocused"))
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use gpui2::Element;
|
use gpui2::Element;
|
||||||
|
|
||||||
pub trait ElementExt<S: 'static + Send + Sync>: Element<S> {
|
pub trait ElementExt<S: 'static>: Element<S> {
|
||||||
// fn when(mut self, condition: bool, then: impl FnOnce(Self) -> Self) -> Self
|
// fn when(mut self, condition: bool, then: impl FnOnce(Self) -> Self) -> Self
|
||||||
// where
|
// where
|
||||||
// Self: Sized,
|
// Self: Sized,
|
||||||
|
@ -22,4 +22,4 @@ pub trait ElementExt<S: 'static + Send + Sync>: Element<S> {
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync, E: Element<S>> ElementExt<S> for E {}
|
impl<S: 'static, E: Element<S>> ElementExt<S> for E {}
|
||||||
|
|
|
@ -1,20 +1,16 @@
|
||||||
use std::marker::PhantomData;
|
|
||||||
|
|
||||||
use gpui2::img;
|
use gpui2::img;
|
||||||
|
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct Avatar<S: 'static + Send + Sync> {
|
pub struct Avatar {
|
||||||
state_type: PhantomData<S>,
|
|
||||||
src: SharedString,
|
src: SharedString,
|
||||||
shape: Shape,
|
shape: Shape,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync> Avatar<S> {
|
impl Avatar {
|
||||||
pub fn new(src: impl Into<SharedString>) -> Self {
|
pub fn new(src: impl Into<SharedString>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
state_type: PhantomData,
|
|
||||||
src: src.into(),
|
src: src.into(),
|
||||||
shape: Shape::Circle,
|
shape: Shape::Circle,
|
||||||
}
|
}
|
||||||
|
@ -25,7 +21,7 @@ impl<S: 'static + Send + Sync> Avatar<S> {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(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 theme = theme(cx);
|
||||||
|
|
||||||
let mut img = img();
|
let mut img = img();
|
||||||
|
@ -52,20 +48,16 @@ mod stories {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct AvatarStory<S: 'static + Send + Sync> {
|
pub struct AvatarStory;
|
||||||
state_type: PhantomData<S>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync> AvatarStory<S> {
|
impl AvatarStory {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self {
|
Self
|
||||||
state_type: PhantomData,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(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)
|
Story::container(cx)
|
||||||
.child(Story::title_for::<_, Avatar<S>>(cx))
|
.child(Story::title_for::<_, Avatar>(cx))
|
||||||
.child(Story::label(cx, "Default"))
|
.child(Story::label(cx, "Default"))
|
||||||
.child(Avatar::new(
|
.child(Avatar::new(
|
||||||
"https://avatars.githubusercontent.com/u/1714999?v=4",
|
"https://avatars.githubusercontent.com/u/1714999?v=4",
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
use std::marker::PhantomData;
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use gpui2::{div, DefiniteLength, Hsla, MouseButton, WindowContext};
|
use gpui2::{div, DefiniteLength, Hsla, MouseButton, WindowContext};
|
||||||
|
@ -49,21 +48,23 @@ impl ButtonVariant {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type ClickHandler<S> = Arc<dyn Fn(&mut S, &mut ViewContext<S>) + 'static + Send + Sync>;
|
pub type ClickHandler<S> = Arc<dyn Fn(&mut S, &mut ViewContext<S>) + Send + Sync>;
|
||||||
|
|
||||||
struct ButtonHandlers<S: 'static + Send + Sync> {
|
struct ButtonHandlers<S: 'static> {
|
||||||
click: Option<ClickHandler<S>>,
|
click: Option<ClickHandler<S>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync> Default for ButtonHandlers<S> {
|
unsafe impl<S> Send for ButtonHandlers<S> {}
|
||||||
|
unsafe impl<S> Sync for ButtonHandlers<S> {}
|
||||||
|
|
||||||
|
impl<S: 'static> Default for ButtonHandlers<S> {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self { click: None }
|
Self { click: None }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct Button<S: 'static + Send + Sync> {
|
pub struct Button<S: 'static> {
|
||||||
state_type: PhantomData<S>,
|
|
||||||
disabled: bool,
|
disabled: bool,
|
||||||
handlers: ButtonHandlers<S>,
|
handlers: ButtonHandlers<S>,
|
||||||
icon: Option<Icon>,
|
icon: Option<Icon>,
|
||||||
|
@ -73,10 +74,9 @@ pub struct Button<S: 'static + Send + Sync> {
|
||||||
width: Option<DefiniteLength>,
|
width: Option<DefiniteLength>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync> Button<S> {
|
impl<S: 'static> Button<S> {
|
||||||
pub fn new(label: impl Into<SharedString>) -> Self {
|
pub fn new(label: impl Into<SharedString>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
state_type: PhantomData,
|
|
||||||
disabled: false,
|
disabled: false,
|
||||||
handlers: ButtonHandlers::default(),
|
handlers: ButtonHandlers::default(),
|
||||||
icon: None,
|
icon: None,
|
||||||
|
@ -140,13 +140,13 @@ impl<S: 'static + Send + Sync> Button<S> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render_label(&self) -> Label<S> {
|
fn render_label(&self) -> Label {
|
||||||
Label::new(self.label.clone())
|
Label::new(self.label.clone())
|
||||||
.color(self.label_color())
|
.color(self.label_color())
|
||||||
.line_height_style(LineHeightStyle::UILabel)
|
.line_height_style(LineHeightStyle::UILabel)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render_icon(&self, icon_color: IconColor) -> Option<IconElement<S>> {
|
fn render_icon(&self, icon_color: IconColor) -> Option<IconElement> {
|
||||||
self.icon.map(|i| IconElement::new(i).color(icon_color))
|
self.icon.map(|i| IconElement::new(i).color(icon_color))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -194,20 +194,16 @@ impl<S: 'static + Send + Sync> Button<S> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct ButtonGroup<S: 'static + Send + Sync> {
|
pub struct ButtonGroup<V: 'static> {
|
||||||
state_type: PhantomData<S>,
|
buttons: Vec<Button<V>>,
|
||||||
buttons: Vec<Button<S>>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync> ButtonGroup<S> {
|
impl<V: 'static> ButtonGroup<V> {
|
||||||
pub fn new(buttons: Vec<Button<S>>) -> Self {
|
pub fn new(buttons: Vec<Button<V>>) -> Self {
|
||||||
Self {
|
Self { buttons }
|
||||||
state_type: PhantomData,
|
|
||||||
buttons,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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 mut el = h_stack().text_size(ui_size(cx, 1.));
|
let mut el = h_stack().text_size(ui_size(cx, 1.));
|
||||||
|
|
||||||
for button in self.buttons {
|
for button in self.buttons {
|
||||||
|
@ -231,22 +227,18 @@ mod stories {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct ButtonStory<S: 'static + Send + Sync + Clone> {
|
pub struct ButtonStory;
|
||||||
state_type: PhantomData<S>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync + Clone> ButtonStory<S> {
|
impl ButtonStory {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self {
|
Self
|
||||||
state_type: PhantomData,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(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 states = InteractionState::iter();
|
let states = InteractionState::iter();
|
||||||
|
|
||||||
Story::container(cx)
|
Story::container(cx)
|
||||||
.child(Story::title_for::<_, Button<S>>(cx))
|
.child(Story::title_for::<_, Button<V>>(cx))
|
||||||
.child(
|
.child(
|
||||||
div()
|
div()
|
||||||
.flex()
|
.flex()
|
||||||
|
|
|
@ -1,19 +1,15 @@
|
||||||
use std::marker::PhantomData;
|
|
||||||
|
|
||||||
use crate::{prelude::*, v_stack, ButtonGroup};
|
use crate::{prelude::*, v_stack, ButtonGroup};
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct Details<S: 'static + Send + Sync> {
|
pub struct Details<V: 'static> {
|
||||||
state_type: PhantomData<S>,
|
|
||||||
text: &'static str,
|
text: &'static str,
|
||||||
meta: Option<&'static str>,
|
meta: Option<&'static str>,
|
||||||
actions: Option<ButtonGroup<S>>,
|
actions: Option<ButtonGroup<V>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync> Details<S> {
|
impl<S: 'static> Details<S> {
|
||||||
pub fn new(text: &'static str) -> Self {
|
pub fn new(text: &'static str) -> Self {
|
||||||
Self {
|
Self {
|
||||||
state_type: PhantomData,
|
|
||||||
text,
|
text,
|
||||||
meta: None,
|
meta: None,
|
||||||
actions: None,
|
actions: None,
|
||||||
|
@ -55,20 +51,16 @@ mod stories {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct DetailsStory<S: 'static + Send + Sync + Clone> {
|
pub struct DetailsStory;
|
||||||
state_type: PhantomData<S>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync + Clone> DetailsStory<S> {
|
impl DetailsStory {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self {
|
Self
|
||||||
state_type: PhantomData,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(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)
|
Story::container(cx)
|
||||||
.child(Story::title_for::<_, Details<S>>(cx))
|
.child(Story::title_for::<_, Details<V>>(cx))
|
||||||
.child(Story::label(cx, "Default"))
|
.child(Story::label(cx, "Default"))
|
||||||
.child(Details::new("The quick brown fox jumps over the lazy dog"))
|
.child(Details::new("The quick brown fox jumps over the lazy dog"))
|
||||||
.child(Story::label(cx, "With meta"))
|
.child(Story::label(cx, "With meta"))
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
use std::marker::PhantomData;
|
|
||||||
|
|
||||||
use gpui2::{svg, Hsla};
|
use gpui2::{svg, Hsla};
|
||||||
use strum::EnumIter;
|
use strum::EnumIter;
|
||||||
|
|
||||||
|
@ -149,17 +147,15 @@ impl Icon {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct IconElement<S: 'static + Send + Sync> {
|
pub struct IconElement {
|
||||||
state_type: PhantomData<S>,
|
|
||||||
icon: Icon,
|
icon: Icon,
|
||||||
color: IconColor,
|
color: IconColor,
|
||||||
size: IconSize,
|
size: IconSize,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync> IconElement<S> {
|
impl IconElement {
|
||||||
pub fn new(icon: Icon) -> Self {
|
pub fn new(icon: Icon) -> Self {
|
||||||
Self {
|
Self {
|
||||||
state_type: PhantomData,
|
|
||||||
icon,
|
icon,
|
||||||
color: IconColor::default(),
|
color: IconColor::default(),
|
||||||
size: IconSize::default(),
|
size: IconSize::default(),
|
||||||
|
@ -176,7 +172,7 @@ impl<S: 'static + Send + Sync> IconElement<S> {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(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 fill = self.color.color(cx);
|
let fill = self.color.color(cx);
|
||||||
let svg_size = match self.size {
|
let svg_size = match self.size {
|
||||||
IconSize::Small => ui_size(cx, 12. / 14.),
|
IconSize::Small => ui_size(cx, 12. / 14.),
|
||||||
|
@ -203,22 +199,18 @@ mod stories {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct IconStory<S: 'static + Send + Sync> {
|
pub struct IconStory;
|
||||||
state_type: PhantomData<S>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync> IconStory<S> {
|
impl IconStory {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self {
|
Self
|
||||||
state_type: PhantomData,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(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 icons = Icon::iter();
|
let icons = Icon::iter();
|
||||||
|
|
||||||
Story::container(cx)
|
Story::container(cx)
|
||||||
.child(Story::title_for::<_, IconElement<S>>(cx))
|
.child(Story::title_for::<_, IconElement>(cx))
|
||||||
.child(Story::label(cx, "All Icons"))
|
.child(Story::label(cx, "All Icons"))
|
||||||
.child(div().flex().gap_3().children(icons.map(IconElement::new)))
|
.child(div().flex().gap_3().children(icons.map(IconElement::new)))
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
use std::marker::PhantomData;
|
|
||||||
|
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
use crate::Label;
|
use crate::Label;
|
||||||
use crate::LabelColor;
|
use crate::LabelColor;
|
||||||
|
@ -12,8 +10,7 @@ pub enum InputVariant {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct Input<S: 'static + Send + Sync> {
|
pub struct Input {
|
||||||
state_type: PhantomData<S>,
|
|
||||||
placeholder: SharedString,
|
placeholder: SharedString,
|
||||||
value: String,
|
value: String,
|
||||||
state: InteractionState,
|
state: InteractionState,
|
||||||
|
@ -22,10 +19,9 @@ pub struct Input<S: 'static + Send + Sync> {
|
||||||
is_active: bool,
|
is_active: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync> Input<S> {
|
impl Input {
|
||||||
pub fn new(placeholder: impl Into<SharedString>) -> Self {
|
pub fn new(placeholder: impl Into<SharedString>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
state_type: PhantomData,
|
|
||||||
placeholder: placeholder.into(),
|
placeholder: placeholder.into(),
|
||||||
value: "".to_string(),
|
value: "".to_string(),
|
||||||
state: InteractionState::default(),
|
state: InteractionState::default(),
|
||||||
|
@ -60,7 +56,7 @@ impl<S: 'static + Send + Sync> Input<S> {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
fn render<S: 'static>(self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||||
let theme = theme(cx);
|
let theme = theme(cx);
|
||||||
|
|
||||||
let (input_bg, input_hover_bg, input_active_bg) = match self.variant {
|
let (input_bg, input_hover_bg, input_active_bg) = match self.variant {
|
||||||
|
@ -121,20 +117,16 @@ mod stories {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct InputStory<S: 'static + Send + Sync> {
|
pub struct InputStory;
|
||||||
state_type: PhantomData<S>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync> InputStory<S> {
|
impl InputStory {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self {
|
Self
|
||||||
state_type: PhantomData,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(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)
|
Story::container(cx)
|
||||||
.child(Story::title_for::<_, Input<S>>(cx))
|
.child(Story::title_for::<_, Input>(cx))
|
||||||
.child(Story::label(cx, "Default"))
|
.child(Story::label(cx, "Default"))
|
||||||
.child(div().flex().child(Input::new("Search")))
|
.child(div().flex().child(Input::new("Search")))
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
use std::marker::PhantomData;
|
|
||||||
|
|
||||||
use gpui2::{relative, Hsla, WindowContext};
|
use gpui2::{relative, Hsla, WindowContext};
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
|
|
||||||
|
@ -49,18 +47,16 @@ pub enum LineHeightStyle {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct Label<S: 'static + Send + Sync> {
|
pub struct Label {
|
||||||
state_type: PhantomData<S>,
|
|
||||||
label: SharedString,
|
label: SharedString,
|
||||||
line_height_style: LineHeightStyle,
|
line_height_style: LineHeightStyle,
|
||||||
color: LabelColor,
|
color: LabelColor,
|
||||||
strikethrough: bool,
|
strikethrough: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync> Label<S> {
|
impl Label {
|
||||||
pub fn new(label: impl Into<SharedString>) -> Self {
|
pub fn new(label: impl Into<SharedString>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
state_type: PhantomData,
|
|
||||||
label: label.into(),
|
label: label.into(),
|
||||||
line_height_style: LineHeightStyle::default(),
|
line_height_style: LineHeightStyle::default(),
|
||||||
color: LabelColor::Default,
|
color: LabelColor::Default,
|
||||||
|
@ -83,7 +79,7 @@ impl<S: 'static + Send + Sync> Label<S> {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(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()
|
div()
|
||||||
.when(self.strikethrough, |this| {
|
.when(self.strikethrough, |this| {
|
||||||
this.relative().child(
|
this.relative().child(
|
||||||
|
@ -106,18 +102,16 @@ impl<S: 'static + Send + Sync> Label<S> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct HighlightedLabel<S: 'static + Send + Sync> {
|
pub struct HighlightedLabel {
|
||||||
state_type: PhantomData<S>,
|
|
||||||
label: SharedString,
|
label: SharedString,
|
||||||
color: LabelColor,
|
color: LabelColor,
|
||||||
highlight_indices: Vec<usize>,
|
highlight_indices: Vec<usize>,
|
||||||
strikethrough: bool,
|
strikethrough: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync> HighlightedLabel<S> {
|
impl HighlightedLabel {
|
||||||
pub fn new(label: impl Into<SharedString>, highlight_indices: Vec<usize>) -> Self {
|
pub fn new(label: impl Into<SharedString>, highlight_indices: Vec<usize>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
state_type: PhantomData,
|
|
||||||
label: label.into(),
|
label: label.into(),
|
||||||
color: LabelColor::Default,
|
color: LabelColor::Default,
|
||||||
highlight_indices,
|
highlight_indices,
|
||||||
|
@ -135,7 +129,7 @@ impl<S: 'static + Send + Sync> HighlightedLabel<S> {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(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 theme = theme(cx);
|
||||||
|
|
||||||
let highlight_color = theme.text_accent;
|
let highlight_color = theme.text_accent;
|
||||||
|
@ -212,20 +206,16 @@ mod stories {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct LabelStory<S: 'static + Send + Sync> {
|
pub struct LabelStory;
|
||||||
state_type: PhantomData<S>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync> LabelStory<S> {
|
impl LabelStory {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self {
|
Self
|
||||||
state_type: PhantomData,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(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)
|
Story::container(cx)
|
||||||
.child(Story::title_for::<_, Label<S>>(cx))
|
.child(Story::title_for::<_, Label>(cx))
|
||||||
.child(Story::label(cx, "Default"))
|
.child(Story::label(cx, "Default"))
|
||||||
.child(Label::new("Hello, world!"))
|
.child(Label::new("Hello, world!"))
|
||||||
.child(Story::label(cx, "Highlighted"))
|
.child(Story::label(cx, "Highlighted"))
|
||||||
|
|
|
@ -14,18 +14,18 @@ pub trait Stack: Styled + Sized {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync> Stack for Div<S> {}
|
impl<S: 'static> Stack for Div<S> {}
|
||||||
|
|
||||||
/// Horizontally stacks elements.
|
/// Horizontally stacks elements.
|
||||||
///
|
///
|
||||||
/// Sets `flex()`, `flex_row()`, `items_center()`
|
/// Sets `flex()`, `flex_row()`, `items_center()`
|
||||||
pub fn h_stack<S: 'static + Send + Sync>() -> Div<S> {
|
pub fn h_stack<S: 'static>() -> Div<S> {
|
||||||
div().h_stack()
|
div().h_stack()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Vertically stacks elements.
|
/// Vertically stacks elements.
|
||||||
///
|
///
|
||||||
/// Sets `flex()`, `flex_col()`
|
/// Sets `flex()`, `flex_col()`
|
||||||
pub fn v_stack<S: 'static + Send + Sync>() -> Div<S> {
|
pub fn v_stack<S: 'static>() -> Div<S> {
|
||||||
div().v_stack()
|
div().v_stack()
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,20 +1,14 @@
|
||||||
use std::marker::PhantomData;
|
|
||||||
|
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct ToolDivider<S: 'static + Send + Sync> {
|
pub struct ToolDivider;
|
||||||
state_type: PhantomData<S>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<S: 'static + Send + Sync> ToolDivider<S> {
|
impl ToolDivider {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self {
|
Self
|
||||||
state_type: PhantomData,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(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 theme = theme(cx);
|
||||||
|
|
||||||
div().w_px().h_3().bg(theme.border)
|
div().w_px().h_3().bg(theme.border)
|
||||||
|
|
|
@ -13,7 +13,7 @@ use crate::{
|
||||||
};
|
};
|
||||||
use crate::{HighlightedText, ListDetailsEntry};
|
use crate::{HighlightedText, ListDetailsEntry};
|
||||||
|
|
||||||
pub fn static_tabs_example<S: 'static + Send + Sync + Clone>() -> Vec<Tab<S>> {
|
pub fn static_tabs_example() -> Vec<Tab> {
|
||||||
vec![
|
vec![
|
||||||
Tab::new("wip.rs")
|
Tab::new("wip.rs")
|
||||||
.title("wip.rs".to_string())
|
.title("wip.rs".to_string())
|
||||||
|
@ -63,7 +63,7 @@ pub fn static_tabs_example<S: 'static + Send + Sync + Clone>() -> Vec<Tab<S>> {
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn static_tabs_1<S: 'static + Send + Sync + Clone>() -> Vec<Tab<S>> {
|
pub fn static_tabs_1() -> Vec<Tab> {
|
||||||
vec![
|
vec![
|
||||||
Tab::new("project_panel.rs")
|
Tab::new("project_panel.rs")
|
||||||
.title("project_panel.rs".to_string())
|
.title("project_panel.rs".to_string())
|
||||||
|
@ -87,7 +87,7 @@ pub fn static_tabs_1<S: 'static + Send + Sync + Clone>() -> Vec<Tab<S>> {
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn static_tabs_2<S: 'static + Send + Sync + Clone>() -> Vec<Tab<S>> {
|
pub fn static_tabs_2() -> Vec<Tab> {
|
||||||
vec![
|
vec![
|
||||||
Tab::new("tab_bar.rs")
|
Tab::new("tab_bar.rs")
|
||||||
.title("tab_bar.rs".to_string())
|
.title("tab_bar.rs".to_string())
|
||||||
|
@ -102,7 +102,7 @@ pub fn static_tabs_2<S: 'static + Send + Sync + Clone>() -> Vec<Tab<S>> {
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn static_tabs_3<S: 'static + Send + Sync + Clone>() -> Vec<Tab<S>> {
|
pub fn static_tabs_3() -> Vec<Tab> {
|
||||||
vec![Tab::new("static_tabs_3")
|
vec![Tab::new("static_tabs_3")
|
||||||
.git_status(GitStatus::Created)
|
.git_status(GitStatus::Created)
|
||||||
.current(true)]
|
.current(true)]
|
||||||
|
@ -325,7 +325,7 @@ pub fn static_players_with_call_status() -> Vec<PlayerWithCallStatus> {
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn static_new_notification_items<S: 'static + Send + Sync>() -> Vec<ListItem<S>> {
|
pub fn static_new_notification_items<S: 'static>() -> Vec<ListItem<S>> {
|
||||||
vec![
|
vec![
|
||||||
ListDetailsEntry::new("maxdeviant invited you to join a stream in #design.")
|
ListDetailsEntry::new("maxdeviant invited you to join a stream in #design.")
|
||||||
.meta("4 people in stream."),
|
.meta("4 people in stream."),
|
||||||
|
@ -336,7 +336,7 @@ pub fn static_new_notification_items<S: 'static + Send + Sync>() -> Vec<ListItem
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn static_read_notification_items<S: 'static + Send + Sync>() -> Vec<ListItem<S>> {
|
pub fn static_read_notification_items<S: 'static>() -> Vec<ListItem<S>> {
|
||||||
vec![
|
vec![
|
||||||
ListDetailsEntry::new("mikaylamaki added you as a contact.").actions(vec![
|
ListDetailsEntry::new("mikaylamaki added you as a contact.").actions(vec![
|
||||||
Button::new("Decline"),
|
Button::new("Decline"),
|
||||||
|
@ -352,7 +352,7 @@ pub fn static_read_notification_items<S: 'static + Send + Sync>() -> Vec<ListIte
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn static_project_panel_project_items<S: 'static + Send + Sync>() -> Vec<ListItem<S>> {
|
pub fn static_project_panel_project_items<S: 'static>() -> Vec<ListItem<S>> {
|
||||||
vec![
|
vec![
|
||||||
ListEntry::new(Label::new("zed"))
|
ListEntry::new(Label::new("zed"))
|
||||||
.left_icon(Icon::FolderOpen.into())
|
.left_icon(Icon::FolderOpen.into())
|
||||||
|
@ -479,7 +479,7 @@ pub fn static_project_panel_project_items<S: 'static + Send + Sync>() -> Vec<Lis
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn static_project_panel_single_items<S: 'static + Send + Sync>() -> Vec<ListItem<S>> {
|
pub fn static_project_panel_single_items<S: 'static>() -> Vec<ListItem<S>> {
|
||||||
vec![
|
vec![
|
||||||
ListEntry::new(Label::new("todo.md"))
|
ListEntry::new(Label::new("todo.md"))
|
||||||
.left_icon(Icon::FileDoc.into())
|
.left_icon(Icon::FileDoc.into())
|
||||||
|
@ -496,7 +496,7 @@ pub fn static_project_panel_single_items<S: 'static + Send + Sync>() -> Vec<List
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn static_collab_panel_current_call<S: 'static + Send + Sync>() -> Vec<ListItem<S>> {
|
pub fn static_collab_panel_current_call<S: 'static>() -> Vec<ListItem<S>> {
|
||||||
vec![
|
vec![
|
||||||
ListEntry::new(Label::new("as-cii")).left_avatar("http://github.com/as-cii.png?s=50"),
|
ListEntry::new(Label::new("as-cii")).left_avatar("http://github.com/as-cii.png?s=50"),
|
||||||
ListEntry::new(Label::new("nathansobo"))
|
ListEntry::new(Label::new("nathansobo"))
|
||||||
|
@ -509,7 +509,7 @@ pub fn static_collab_panel_current_call<S: 'static + Send + Sync>() -> Vec<ListI
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn static_collab_panel_channels<S: 'static + Send + Sync>() -> Vec<ListItem<S>> {
|
pub fn static_collab_panel_channels<S: 'static>() -> Vec<ListItem<S>> {
|
||||||
vec![
|
vec![
|
||||||
ListEntry::new(Label::new("zed"))
|
ListEntry::new(Label::new("zed"))
|
||||||
.left_icon(Icon::Hash.into())
|
.left_icon(Icon::Hash.into())
|
||||||
|
@ -573,7 +573,7 @@ pub fn static_collab_panel_channels<S: 'static + Send + Sync>() -> Vec<ListItem<
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn example_editor_actions<S: 'static + Send + Sync>() -> Vec<PaletteItem<S>> {
|
pub fn example_editor_actions() -> Vec<PaletteItem> {
|
||||||
vec![
|
vec![
|
||||||
PaletteItem::new("New File").keybinding(Keybinding::new(
|
PaletteItem::new("New File").keybinding(Keybinding::new(
|
||||||
"N".to_string(),
|
"N".to_string(),
|
||||||
|
@ -638,7 +638,7 @@ pub fn empty_editor_example(cx: &mut WindowContext) -> EditorPane {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn empty_buffer_example<S: 'static + Send + Sync + Clone>() -> Buffer<S> {
|
pub fn empty_buffer_example() -> Buffer {
|
||||||
Buffer::new("empty-buffer").set_rows(Some(BufferRows::default()))
|
Buffer::new("empty-buffer").set_rows(Some(BufferRows::default()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -663,9 +663,7 @@ pub fn hello_world_rust_editor_example(cx: &mut WindowContext) -> EditorPane {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn hello_world_rust_buffer_example<S: 'static + Send + Sync + Clone>(
|
pub fn hello_world_rust_buffer_example(theme: &Theme) -> Buffer {
|
||||||
theme: &Theme,
|
|
||||||
) -> Buffer<S> {
|
|
||||||
Buffer::new("hello-world-rust-buffer")
|
Buffer::new("hello-world-rust-buffer")
|
||||||
.set_title("hello_world.rs".to_string())
|
.set_title("hello_world.rs".to_string())
|
||||||
.set_path("src/hello_world.rs".to_string())
|
.set_path("src/hello_world.rs".to_string())
|
||||||
|
@ -804,9 +802,7 @@ pub fn hello_world_rust_editor_with_status_example(cx: &mut WindowContext) -> Ed
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn hello_world_rust_buffer_with_status_example<S: 'static + Send + Sync + Clone>(
|
pub fn hello_world_rust_buffer_with_status_example(theme: &Theme) -> Buffer {
|
||||||
theme: &Theme,
|
|
||||||
) -> Buffer<S> {
|
|
||||||
Buffer::new("hello-world-rust-buffer-with-status")
|
Buffer::new("hello-world-rust-buffer-with-status")
|
||||||
.set_title("hello_world.rs".to_string())
|
.set_title("hello_world.rs".to_string())
|
||||||
.set_path("src/hello_world.rs".to_string())
|
.set_path("src/hello_world.rs".to_string())
|
||||||
|
@ -952,7 +948,7 @@ pub fn hello_world_rust_with_status_buffer_rows(theme: &Theme) -> Vec<BufferRow>
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn terminal_buffer<S: 'static + Send + Sync + Clone>(theme: &Theme) -> Buffer<S> {
|
pub fn terminal_buffer(theme: &Theme) -> Buffer {
|
||||||
Buffer::new("terminal")
|
Buffer::new("terminal")
|
||||||
.set_title("zed — fish".to_string())
|
.set_title("zed — fish".to_string())
|
||||||
.set_rows(Some(BufferRows {
|
.set_rows(Some(BufferRows {
|
||||||
|
|
|
@ -5,7 +5,7 @@ use crate::prelude::*;
|
||||||
pub struct Story {}
|
pub struct Story {}
|
||||||
|
|
||||||
impl Story {
|
impl Story {
|
||||||
pub fn container<S: 'static + Send + Sync>(cx: &mut ViewContext<S>) -> Div<S> {
|
pub fn container<S: 'static>(cx: &mut ViewContext<S>) -> Div<S> {
|
||||||
let theme = theme(cx);
|
let theme = theme(cx);
|
||||||
|
|
||||||
div()
|
div()
|
||||||
|
@ -18,7 +18,7 @@ impl Story {
|
||||||
.bg(theme.background)
|
.bg(theme.background)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn title<S: 'static + Send + Sync>(
|
pub fn title<S: 'static>(
|
||||||
cx: &mut ViewContext<S>,
|
cx: &mut ViewContext<S>,
|
||||||
title: &str,
|
title: &str,
|
||||||
) -> impl Component<S> {
|
) -> impl Component<S> {
|
||||||
|
@ -30,11 +30,11 @@ impl Story {
|
||||||
.child(title.to_owned())
|
.child(title.to_owned())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn title_for<S: 'static + Send + Sync, T>(cx: &mut ViewContext<S>) -> impl Component<S> {
|
pub fn title_for<S: 'static, T>(cx: &mut ViewContext<S>) -> impl Component<S> {
|
||||||
Self::title(cx, std::any::type_name::<T>())
|
Self::title(cx, std::any::type_name::<T>())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn label<S: 'static + Send + Sync>(
|
pub fn label<S: 'static>(
|
||||||
cx: &mut ViewContext<S>,
|
cx: &mut ViewContext<S>,
|
||||||
label: &str,
|
label: &str,
|
||||||
) -> impl Component<S> {
|
) -> impl Component<S> {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue