From 5c0f2e75ea7e1c5391fedd1f211e0e4def636b94 Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Mon, 20 Nov 2023 16:30:14 -0700 Subject: [PATCH] Remove all the settings --- crates/ui2/src/lib.rs | 19 - crates/ui2/src/settings.rs | 74 -- crates/ui2/src/to_extract.rs | 48 - crates/ui2/src/to_extract/assistant_panel.rs | 97 -- crates/ui2/src/to_extract/breadcrumb.rs | 118 -- crates/ui2/src/to_extract/buffer.rs | 281 ----- crates/ui2/src/to_extract/buffer_search.rs | 45 - crates/ui2/src/to_extract/chat_panel.rs | 158 --- crates/ui2/src/to_extract/collab_panel.rs | 118 -- crates/ui2/src/to_extract/command_palette.rs | 53 - crates/ui2/src/to_extract/copilot.rs | 49 - crates/ui2/src/to_extract/editor_pane.rs | 77 -- .../ui2/src/to_extract/language_selector.rs | 83 -- crates/ui2/src/to_extract/multi_buffer.rs | 68 - .../ui2/src/to_extract/notifications_panel.rs | 381 ------ crates/ui2/src/to_extract/panes.rs | 139 -- crates/ui2/src/to_extract/project_panel.rs | 117 -- crates/ui2/src/to_extract/recent_projects.rs | 58 - crates/ui2/src/to_extract/static_data.rs | 1123 ----------------- crates/ui2/src/to_extract/status_bar.rs | 197 --- crates/ui2/src/to_extract/tab_bar.rs | 156 --- crates/ui2/src/to_extract/terminal.rs | 166 --- crates/ui2/src/to_extract/theme_selector.rs | 65 - crates/ui2/src/to_extract/title_bar.rs | 218 ---- crates/ui2/src/to_extract/toolbar.rs | 130 -- crates/ui2/src/to_extract/traffic_lights.rs | 109 -- crates/ui2/src/to_extract/workspace.rs | 398 ------ 27 files changed, 4545 deletions(-) delete mode 100644 crates/ui2/src/settings.rs delete mode 100644 crates/ui2/src/to_extract.rs delete mode 100644 crates/ui2/src/to_extract/assistant_panel.rs delete mode 100644 crates/ui2/src/to_extract/breadcrumb.rs delete mode 100644 crates/ui2/src/to_extract/buffer.rs delete mode 100644 crates/ui2/src/to_extract/buffer_search.rs delete mode 100644 crates/ui2/src/to_extract/chat_panel.rs delete mode 100644 crates/ui2/src/to_extract/collab_panel.rs delete mode 100644 crates/ui2/src/to_extract/command_palette.rs delete mode 100644 crates/ui2/src/to_extract/copilot.rs delete mode 100644 crates/ui2/src/to_extract/editor_pane.rs delete mode 100644 crates/ui2/src/to_extract/language_selector.rs delete mode 100644 crates/ui2/src/to_extract/multi_buffer.rs delete mode 100644 crates/ui2/src/to_extract/notifications_panel.rs delete mode 100644 crates/ui2/src/to_extract/panes.rs delete mode 100644 crates/ui2/src/to_extract/project_panel.rs delete mode 100644 crates/ui2/src/to_extract/recent_projects.rs delete mode 100644 crates/ui2/src/to_extract/static_data.rs delete mode 100644 crates/ui2/src/to_extract/status_bar.rs delete mode 100644 crates/ui2/src/to_extract/tab_bar.rs delete mode 100644 crates/ui2/src/to_extract/terminal.rs delete mode 100644 crates/ui2/src/to_extract/theme_selector.rs delete mode 100644 crates/ui2/src/to_extract/title_bar.rs delete mode 100644 crates/ui2/src/to_extract/toolbar.rs delete mode 100644 crates/ui2/src/to_extract/traffic_lights.rs delete mode 100644 crates/ui2/src/to_extract/workspace.rs diff --git a/crates/ui2/src/lib.rs b/crates/ui2/src/lib.rs index 68409b19eda655dd857579ddfb714356c5e47b05..b0701697665902bed224e29349166264778f7a8d 100644 --- a/crates/ui2/src/lib.rs +++ b/crates/ui2/src/lib.rs @@ -17,34 +17,15 @@ mod components; mod elevation; pub mod prelude; -pub mod settings; -// mod static_data; mod styled_ext; -mod to_extract; pub mod utils; pub use components::*; -use gpui::actions; pub use prelude::*; // pub use static_data::*; pub use styled_ext::*; -pub use to_extract::*; - -// This needs to be fully qualified with `crate::` otherwise we get a panic -// at: -// thread '' panicked at crates/gpui2/src/platform/mac/platform.rs:66:81: -// called `Option::unwrap()` on a `None` value -// -// AFAICT this is something to do with conflicting names between crates and modules that -// interfaces with declaring the `ClassDecl`. -pub use crate::settings::*; #[cfg(feature = "stories")] mod story; #[cfg(feature = "stories")] pub use story::*; -actions!(NoAction); - -pub fn binding(key: &str) -> gpui::KeyBinding { - gpui::KeyBinding::new(key, NoAction {}, None) -} diff --git a/crates/ui2/src/settings.rs b/crates/ui2/src/settings.rs deleted file mode 100644 index c3ac78316e9e6138195225c92cdad96542e808cd..0000000000000000000000000000000000000000 --- a/crates/ui2/src/settings.rs +++ /dev/null @@ -1,74 +0,0 @@ -use std::ops::Deref; - -use gpui::{rems, AbsoluteLength, AppContext, WindowContext}; - -use crate::prelude::*; - -pub fn init(cx: &mut AppContext) { - cx.set_global(FakeSettings::default()); -} - -/// Returns the user settings. -pub fn user_settings(cx: &WindowContext) -> FakeSettings { - cx.global::().clone() -} - -pub fn user_settings_mut<'cx>(cx: &'cx mut WindowContext) -> &'cx mut FakeSettings { - cx.global_mut::() -} - -#[derive(Clone)] -pub enum SettingValue { - UserDefined(T), - Default(T), -} - -impl Deref for SettingValue { - type Target = T; - - fn deref(&self) -> &Self::Target { - match self { - Self::UserDefined(value) => value, - Self::Default(value) => value, - } - } -} - -#[derive(Clone)] -pub struct TitlebarSettings { - pub show_project_owner: SettingValue, - pub show_git_status: SettingValue, - pub show_git_controls: SettingValue, -} - -impl Default for TitlebarSettings { - fn default() -> Self { - Self { - show_project_owner: SettingValue::Default(true), - show_git_status: SettingValue::Default(true), - show_git_controls: SettingValue::Default(true), - } - } -} - -// These should be merged into settings -#[derive(Clone)] -pub struct FakeSettings { - pub default_panel_size: SettingValue, - pub list_disclosure_style: SettingValue, - pub list_indent_depth: SettingValue, - pub titlebar: TitlebarSettings, -} - -impl Default for FakeSettings { - fn default() -> Self { - Self { - titlebar: TitlebarSettings::default(), - list_disclosure_style: SettingValue::Default(DisclosureControlStyle::ChevronOnHover), - list_indent_depth: SettingValue::Default(rems(0.3).into()), - default_panel_size: SettingValue::Default(rems(16.).into()), - } - } -} - -impl FakeSettings {} diff --git a/crates/ui2/src/to_extract.rs b/crates/ui2/src/to_extract.rs deleted file mode 100644 index 5ea9917041b275aa67236c80b02ab1253e2c1bba..0000000000000000000000000000000000000000 --- a/crates/ui2/src/to_extract.rs +++ /dev/null @@ -1,48 +0,0 @@ -//TODO!(Restore later) -// mod assistant_panel; -// mod breadcrumb; -// mod buffer; -// mod buffer_search; -// mod chat_panel; -// mod collab_panel; -// mod command_palette; -// mod copilot; -// mod editor_pane; -// mod language_selector; -// mod multi_buffer; -// mod notifications_panel; -// mod panes; -// mod project_panel; -// mod recent_projects; -// mod status_bar; -// mod tab_bar; -// mod terminal; -// mod theme_selector; -// mod title_bar; -// mod toolbar; -// mod traffic_lights; -// mod workspace; - -// pub use assistant_panel::*; -// pub use breadcrumb::*; -// pub use buffer::*; -// pub use buffer_search::*; -// pub use chat_panel::*; -// pub use collab_panel::*; -// pub use command_palette::*; -// pub use copilot::*; -// pub use editor_pane::*; -// pub use language_selector::*; -// pub use multi_buffer::*; -// pub use notifications_panel::*; -// pub use panes::*; -// pub use project_panel::*; -// pub use recent_projects::*; -// pub use status_bar::*; -// pub use tab_bar::*; -// pub use terminal::*; -// pub use theme_selector::*; -// pub use title_bar::*; -// pub use toolbar::*; -// pub use traffic_lights::*; -// pub use workspace::*; diff --git a/crates/ui2/src/to_extract/assistant_panel.rs b/crates/ui2/src/to_extract/assistant_panel.rs deleted file mode 100644 index 904cbe1a80a7c56c884b95a3d31876953a69be99..0000000000000000000000000000000000000000 --- a/crates/ui2/src/to_extract/assistant_panel.rs +++ /dev/null @@ -1,97 +0,0 @@ -use crate::prelude::*; -use crate::{Icon, IconButton, Label, Panel, PanelSide}; -use gpui::{prelude::*, rems, AbsoluteLength, RenderOnce}; - -#[derive(RenderOnce)] -pub struct AssistantPanel { - id: ElementId, - current_side: PanelSide, -} - -impl Component for AssistantPanel { - type Rendered = Panel; - - fn render(self, cx: &mut WindowContext) -> Self::Rendered { - Panel::new(self.id.clone(), cx) - .children(vec![div() - .flex() - .flex_col() - .h_full() - .px_2() - .gap_2() - // Header - .child( - div() - .flex() - .justify_between() - .gap_2() - .child( - div() - .flex() - .child(IconButton::new("menu", Icon::Menu)) - .child(Label::new("New Conversation")), - ) - .child( - div() - .flex() - .items_center() - .gap_px() - .child(IconButton::new("split_message", Icon::SplitMessage)) - .child(IconButton::new("quote", Icon::Quote)) - .child(IconButton::new("magic_wand", Icon::MagicWand)) - .child(IconButton::new("plus", Icon::Plus)) - .child(IconButton::new("maximize", Icon::Maximize)), - ), - ) - // Chat Body - .child( - div() - .id("chat-body") - .w_full() - .flex() - .flex_col() - .gap_3() - .overflow_y_scroll() - .child(Label::new("Is this thing on?")), - ) - .into_any()]) - .side(self.current_side) - .width(AbsoluteLength::Rems(rems(32.))) - } -} - -impl AssistantPanel { - pub fn new(id: impl Into) -> Self { - Self { - id: id.into(), - current_side: PanelSide::default(), - } - } - - pub fn side(mut self, side: PanelSide) -> Self { - self.current_side = side; - self - } -} - -#[cfg(feature = "stories")] -pub use stories::*; - -#[cfg(feature = "stories")] -mod stories { - use super::*; - use crate::Story; - use gpui::{Div, Render}; - pub struct AssistantPanelStory; - - impl Render for AssistantPanelStory { - type Element = Div; - - fn render(&mut self, cx: &mut ViewContext) -> Self::Element { - Story::container(cx) - .child(Story::title_for::<_, AssistantPanel>(cx)) - .child(Story::label(cx, "Default")) - .child(AssistantPanel::new("assistant-panel")) - } - } -} diff --git a/crates/ui2/src/to_extract/breadcrumb.rs b/crates/ui2/src/to_extract/breadcrumb.rs deleted file mode 100644 index 24f3ed5bbd1f80a2e4bee1a4c97693323e0f8d4b..0000000000000000000000000000000000000000 --- a/crates/ui2/src/to_extract/breadcrumb.rs +++ /dev/null @@ -1,118 +0,0 @@ -use crate::{h_stack, prelude::*, HighlightedText}; -use gpui::{prelude::*, Div, Stateful}; -use std::path::PathBuf; - -#[derive(Clone)] -pub struct Symbol(pub Vec); - -#[derive(RenderOnce)] -pub struct Breadcrumb { - path: PathBuf, - symbols: Vec, -} - -impl Component for Breadcrumb { - type Rendered = gpui::Stateful
; - - fn render(self, cx: &mut WindowContext) -> Self::Rendered { - let symbols_len = self.symbols.len(); - h_stack() - .id("breadcrumb") - .px_1() - .text_ui_sm() - .text_color(cx.theme().colors().text_muted) - .rounded_md() - .hover(|style| style.bg(cx.theme().colors().ghost_element_hover)) - .active(|style| style.bg(cx.theme().colors().ghost_element_active)) - .child(SharedString::from( - self.path.clone().to_str().unwrap().to_string(), - )) - .child(if !self.symbols.is_empty() { - self.render_separator(cx) - } else { - div() - }) - .child( - div().flex().children( - self.symbols - .iter() - .enumerate() - // TODO: Could use something like `intersperse` here instead. - .flat_map(|(ix, symbol)| { - let mut items = - vec![div().flex().children(symbol.0.iter().map(|segment| { - div().child(segment.text.clone()).text_color(segment.color) - }))]; - - let is_last_segment = ix == symbols_len - 1; - if !is_last_segment { - items.push(self.render_separator(cx)); - } - - items - }) - .collect::>(), - ), - ) - } -} - -impl Breadcrumb { - pub fn new(path: PathBuf, symbols: Vec) -> Self { - Self { path, symbols } - } - - fn render_separator(&self, cx: &WindowContext) -> Div { - div() - .child(" › ") - .text_color(cx.theme().colors().text_muted) - } -} - -#[cfg(feature = "stories")] -pub use stories::*; - -#[cfg(feature = "stories")] -mod stories { - use super::*; - use crate::Story; - use gpui::Render; - use std::str::FromStr; - - pub struct BreadcrumbStory; - - impl Render for BreadcrumbStory { - type Element = Div; - - fn render(&mut self, cx: &mut ViewContext) -> Self::Element { - Story::container(cx) - .child(Story::title_for::<_, Breadcrumb>(cx)) - .child(Story::label(cx, "Default")) - .child(Breadcrumb::new( - PathBuf::from_str("crates/ui/src/components/toolbar.rs").unwrap(), - vec![ - Symbol(vec![ - HighlightedText { - text: "impl ".into(), - color: cx.theme().syntax_color("keyword"), - }, - HighlightedText { - text: "BreadcrumbStory".into(), - color: cx.theme().syntax_color("function"), - }, - ]), - Symbol(vec![ - HighlightedText { - text: "fn ".into(), - color: cx.theme().syntax_color("keyword"), - }, - HighlightedText { - text: "render".into(), - color: cx.theme().syntax_color("function"), - }, - ]), - ], - )) - } - } -} diff --git a/crates/ui2/src/to_extract/buffer.rs b/crates/ui2/src/to_extract/buffer.rs deleted file mode 100644 index 0955d9d3574114200c983117fe0dbb565db123b5..0000000000000000000000000000000000000000 --- a/crates/ui2/src/to_extract/buffer.rs +++ /dev/null @@ -1,281 +0,0 @@ -use gpui::{Div, Hsla, RenderOnce, WindowContext}; - -use crate::prelude::*; -use crate::{h_stack, v_stack, Icon, IconElement}; - -#[derive(Default, PartialEq, Copy, Clone)] -pub struct PlayerCursor { - color: Hsla, - index: usize, -} - -#[derive(Default, PartialEq, Clone)] -pub struct HighlightedText { - pub text: SharedString, - pub color: Hsla, -} - -#[derive(Default, PartialEq, Clone)] -pub struct HighlightedLine { - pub highlighted_texts: Vec, -} - -#[derive(Default, PartialEq, Clone)] -pub struct BufferRow { - pub line_number: usize, - pub code_action: bool, - pub current: bool, - pub line: Option, - pub cursors: Option>, - pub status: GitStatus, - pub show_line_number: bool, -} - -#[derive(Clone)] -pub struct BufferRows { - pub show_line_numbers: bool, - pub rows: Vec, -} - -impl Default for BufferRows { - fn default() -> Self { - Self { - show_line_numbers: true, - rows: vec![BufferRow { - line_number: 1, - code_action: false, - current: true, - line: None, - cursors: None, - status: GitStatus::None, - show_line_number: true, - }], - } - } -} - -impl BufferRow { - pub fn new(line_number: usize) -> Self { - Self { - line_number, - code_action: false, - current: false, - line: None, - cursors: None, - status: GitStatus::None, - show_line_number: true, - } - } - - pub fn set_line(mut self, line: Option) -> Self { - self.line = line; - self - } - - pub fn set_cursors(mut self, cursors: Option>) -> Self { - self.cursors = cursors; - self - } - - pub fn add_cursor(mut self, cursor: PlayerCursor) -> Self { - if let Some(cursors) = &mut self.cursors { - cursors.push(cursor); - } else { - self.cursors = Some(vec![cursor]); - } - self - } - - pub fn set_status(mut self, status: GitStatus) -> Self { - self.status = status; - self - } - - pub fn set_show_line_number(mut self, show_line_number: bool) -> Self { - self.show_line_number = show_line_number; - self - } - - pub fn set_code_action(mut self, code_action: bool) -> Self { - self.code_action = code_action; - self - } - - pub fn set_current(mut self, current: bool) -> Self { - self.current = current; - self - } -} - -#[derive(RenderOnce, Clone)] -pub struct Buffer { - id: ElementId, - rows: Option, - readonly: bool, - language: Option, - title: Option, - path: Option, -} - -impl Component for Buffer { - type Rendered = Div; - - fn render(self, cx: &mut WindowContext) -> Self::Rendered { - let rows = self.render_rows(cx); - - v_stack() - .flex_1() - .w_full() - .h_full() - .bg(cx.theme().colors().editor_background) - .children(rows) - } -} - -impl Buffer { - pub fn new(id: impl Into) -> Self { - Self { - id: id.into(), - rows: Some(BufferRows::default()), - readonly: false, - language: None, - title: Some("untitled".to_string()), - path: None, - } - } - - pub fn set_title>>(mut self, title: T) -> Self { - self.title = title.into(); - self - } - - pub fn set_path>>(mut self, path: P) -> Self { - self.path = path.into(); - self - } - - pub fn set_readonly(mut self, readonly: bool) -> Self { - self.readonly = readonly; - self - } - - pub fn set_rows>>(mut self, rows: R) -> Self { - self.rows = rows.into(); - self - } - - pub fn set_language>>(mut self, language: L) -> Self { - self.language = language.into(); - self - } - - fn render_row(row: BufferRow, cx: &WindowContext) -> impl Element { - let line_background = if row.current { - cx.theme().colors().editor_active_line_background - } else { - cx.theme().styles.system.transparent - }; - - let line_number_color = if row.current { - cx.theme().colors().text - } else { - cx.theme().syntax_color("comment") - }; - - h_stack() - .bg(line_background) - .w_full() - .gap_2() - .px_1() - .child( - h_stack() - .w_4() - .h_full() - .px_0p5() - .when(row.code_action, |c| { - div().child(IconElement::new(Icon::Bolt)) - }), - ) - .when(row.show_line_number, |this| { - this.child( - h_stack().justify_end().px_0p5().w_3().child( - div() - .text_color(line_number_color) - .child(SharedString::from(row.line_number.to_string())), - ), - ) - }) - .child(div().mx_0p5().w_1().h_full().bg(row.status.hsla(cx))) - .children(row.line.map(|line| { - div() - .flex() - .children(line.highlighted_texts.iter().map(|highlighted_text| { - div() - .text_color(highlighted_text.color) - .child(highlighted_text.text.clone()) - })) - })) - } - - fn render_rows(&self, cx: &WindowContext) -> Vec { - match &self.rows { - Some(rows) => rows - .rows - .iter() - .map(|row| Self::render_row(row.clone(), cx)) - .collect(), - None => vec![], - } - } - - fn render(self, cx: &mut WindowContext) -> impl Element { - let rows = self.render_rows(cx); - - v_stack() - .flex_1() - .w_full() - .h_full() - .bg(cx.theme().colors().editor_background) - .children(rows) - } -} - -#[cfg(feature = "stories")] -pub use stories::*; - -#[cfg(feature = "stories")] -mod stories { - use super::*; - use crate::{ - empty_buffer_example, hello_world_rust_buffer_example, - hello_world_rust_buffer_with_status_example, Story, - }; - use gpui::{rems, Div, Render}; - - pub struct BufferStory; - - impl Render for BufferStory { - type Element = Div; - - fn render(&mut self, cx: &mut ViewContext) -> Self::Element { - Story::container(cx) - .child(Story::title_for::<_, Buffer>(cx)) - .child(Story::label(cx, "Default")) - .child(div().w(rems(64.)).h_96().child(empty_buffer_example())) - .child(Story::label(cx, "Hello World (Rust)")) - .child( - div() - .w(rems(64.)) - .h_96() - .child(hello_world_rust_buffer_example(cx)), - ) - .child(Story::label(cx, "Hello World (Rust) with Status")) - .child( - div() - .w(rems(64.)) - .h_96() - .child(hello_world_rust_buffer_with_status_example(cx)), - ) - } - } -} diff --git a/crates/ui2/src/to_extract/buffer_search.rs b/crates/ui2/src/to_extract/buffer_search.rs deleted file mode 100644 index fc0a5af607d3417efe0b6271ed99fa9239bc7f7e..0000000000000000000000000000000000000000 --- a/crates/ui2/src/to_extract/buffer_search.rs +++ /dev/null @@ -1,45 +0,0 @@ -use crate::prelude::*; -use crate::{h_stack, Icon, IconButton, Input, TextColor}; -use gpui::{Div, Render, RenderOnce, View, VisualContext}; - -#[derive(Clone)] -pub struct BufferSearch { - is_replace_open: bool, -} - -impl BufferSearch { - pub fn new() -> Self { - Self { - is_replace_open: false, - } - } - - fn toggle_replace(&mut self, cx: &mut ViewContext) { - self.is_replace_open = !self.is_replace_open; - - cx.notify(); - } - - pub fn view(cx: &mut WindowContext) -> View { - cx.build_view(|cx| Self::new()) - } -} - -impl Render for BufferSearch { - type Element = Div; - - fn render(&mut self, cx: &mut WindowContext) -> Div { - h_stack() - .bg(cx.theme().colors().toolbar_background) - .p_2() - .child( - h_stack().child(Input::new("Search")).child( - IconButton::::new("replace", Icon::Replace) - .when(self.is_replace_open, |this| this.color(TextColor::Accent)) - .on_click(|buffer_search, cx| { - buffer_search.toggle_replace(cx); - }), - ), - ) - } -} diff --git a/crates/ui2/src/to_extract/chat_panel.rs b/crates/ui2/src/to_extract/chat_panel.rs deleted file mode 100644 index 71f23f0ca8a691609e8c2e9a235003aa96cbc49c..0000000000000000000000000000000000000000 --- a/crates/ui2/src/to_extract/chat_panel.rs +++ /dev/null @@ -1,158 +0,0 @@ -use crate::{prelude::*, Icon, IconButton, Input, Label}; -use chrono::NaiveDateTime; -use gpui::{prelude::*, Div, Stateful}; - -#[derive(RenderOnce)] -pub struct ChatPanel { - element_id: ElementId, - messages: Vec, -} - -impl Component for ChatPanel { - type Rendered = gpui::Stateful
; - - fn render(self, cx: &mut WindowContext) -> Self::Rendered { - div() - .id(self.element_id.clone()) - .flex() - .flex_col() - .justify_between() - .h_full() - .px_2() - .gap_2() - // Header - .child( - div() - .flex() - .justify_between() - .py_2() - .child(div().flex().child(Label::new("#design"))) - .child( - div() - .flex() - .items_center() - .gap_px() - .child(IconButton::new("file", Icon::File)) - .child(IconButton::new("audio_on", Icon::AudioOn)), - ), - ) - .child( - div() - .flex() - .flex_col() - // Chat Body - .child( - div() - .id("chat-body") - .w_full() - .flex() - .flex_col() - .gap_3() - .overflow_y_scroll() - .children(self.messages), - ) - // Composer - .child(div().flex().my_2().child(Input::new("Message #design"))), - ) - } -} - -impl ChatPanel { - pub fn new(element_id: impl Into) -> Self { - Self { - element_id: element_id.into(), - messages: Vec::new(), - } - } - - pub fn messages(mut self, messages: Vec) -> Self { - self.messages = messages; - self - } -} - -#[derive(RenderOnce)] -pub struct ChatMessage { - author: String, - text: String, - sent_at: NaiveDateTime, -} - -impl Component for ChatMessage { - type Rendered = Div; - - fn render(self, cx: &mut WindowContext) -> Self::Rendered { - div() - .flex() - .flex_col() - .child( - div() - .flex() - .gap_2() - .child(Label::new(self.author.clone())) - .child( - Label::new(self.sent_at.format("%m/%d/%Y").to_string()) - .color(TextColor::Muted), - ), - ) - .child(div().child(Label::new(self.text.clone()))) - } -} - -impl ChatMessage { - pub fn new(author: String, text: String, sent_at: NaiveDateTime) -> Self { - Self { - author, - text, - sent_at, - } - } -} - -#[cfg(feature = "stories")] -pub use stories::*; - -#[cfg(feature = "stories")] -mod stories { - use chrono::DateTime; - use gpui::{Div, Render}; - - use crate::{Panel, Story}; - - use super::*; - - pub struct ChatPanelStory; - - impl Render for ChatPanelStory { - type Element = Div; - - fn render(&mut self, cx: &mut ViewContext) -> Self::Element { - Story::container(cx) - .child(Story::title_for::<_, ChatPanel>(cx)) - .child(Story::label(cx, "Default")) - .child( - Panel::new("chat-panel-1-outer", cx) - .child(ChatPanel::new("chat-panel-1-inner")), - ) - .child(Story::label(cx, "With Mesages")) - .child(Panel::new("chat-panel-2-outer", cx).child( - ChatPanel::new("chat-panel-2-inner").messages(vec![ - ChatMessage::new( - "osiewicz".to_string(), - "is this thing on?".to_string(), - DateTime::parse_from_rfc3339("2023-09-27T15:40:52.707Z") - .unwrap() - .naive_local(), - ), - ChatMessage::new( - "maxdeviant".to_string(), - "Reading you loud and clear!".to_string(), - DateTime::parse_from_rfc3339("2023-09-28T15:40:52.707Z") - .unwrap() - .naive_local(), - ), - ]), - )) - } - } -} diff --git a/crates/ui2/src/to_extract/collab_panel.rs b/crates/ui2/src/to_extract/collab_panel.rs deleted file mode 100644 index 4cfe96790acc9af80a69d4b9caa081c5988a58e6..0000000000000000000000000000000000000000 --- a/crates/ui2/src/to_extract/collab_panel.rs +++ /dev/null @@ -1,118 +0,0 @@ -use crate::{ - prelude::*, static_collab_panel_channels, static_collab_panel_current_call, v_stack, Icon, - List, ListHeader, Toggle, -}; -use gpui::{prelude::*, Div, Stateful}; - -#[derive(RenderOnce)] -pub struct CollabPanel { - id: ElementId, -} - -impl Component for CollabPanel { - type Rendered = gpui::Stateful
; - - fn render(self, cx: &mut WindowContext) -> Self::Rendered { - v_stack() - .id(self.id.clone()) - .h_full() - .bg(cx.theme().colors().surface_background) - .child( - v_stack() - .id("crdb") - .w_full() - .overflow_y_scroll() - .child( - div() - .pb_1() - .border_color(cx.theme().colors().border) - .border_b() - .child( - List::new() - .header( - ListHeader::new("CRDB") - .left_icon(Icon::Hash.into()) - .toggle(Toggle::Toggled(true)), - ) - .toggle(Toggle::Toggled(true)) - .children(static_collab_panel_current_call()), - ), - ) - .child( - v_stack().id("channels").py_1().child( - List::new() - .header(ListHeader::new("CHANNELS").toggle(Toggle::Toggled(true))) - .empty_message("No channels yet. Add a channel to get started.") - .toggle(Toggle::Toggled(true)) - .children(static_collab_panel_channels()), - ), - ) - .child( - v_stack().id("contacts-online").py_1().child( - List::new() - .header( - ListHeader::new("CONTACTS – ONLINE") - .toggle(Toggle::Toggled(true)), - ) - .toggle(Toggle::Toggled(true)) - .children(static_collab_panel_current_call()), - ), - ) - .child( - v_stack().id("contacts-offline").py_1().child( - List::new() - .header( - ListHeader::new("CONTACTS – OFFLINE") - .toggle(Toggle::Toggled(false)), - ) - .toggle(Toggle::Toggled(false)) - .children(static_collab_panel_current_call()), - ), - ), - ) - .child( - div() - .h_7() - .px_2() - .border_t() - .border_color(cx.theme().colors().border) - .flex() - .items_center() - .child( - div() - .text_ui_sm() - .text_color(cx.theme().colors().text_placeholder) - .child("Find..."), - ), - ) - } -} - -impl CollabPanel { - pub fn new(id: impl Into) -> Self { - Self { id: id.into() } - } -} - -#[cfg(feature = "stories")] -pub use stories::*; - -#[cfg(feature = "stories")] -mod stories { - use super::*; - use crate::Story; - use gpui::{Div, Render}; - - pub struct CollabPanelStory; - - impl Render for CollabPanelStory { - type Element = Div; - - fn render(&mut self, cx: &mut ViewContext) -> Self::Element { - Story::container(cx) - .child(Story::title_for::<_, CollabPanel>(cx)) - .child(Story::label(cx, "Default")) - .child(CollabPanel::new("collab-panel")) - } - } -} diff --git a/crates/ui2/src/to_extract/command_palette.rs b/crates/ui2/src/to_extract/command_palette.rs deleted file mode 100644 index 64bd8be86acae394f4e55d42ac608f64212ba439..0000000000000000000000000000000000000000 --- a/crates/ui2/src/to_extract/command_palette.rs +++ /dev/null @@ -1,53 +0,0 @@ -use crate::prelude::*; -use crate::{example_editor_actions, OrderMethod, Palette}; - -#[derive(RenderOnce)] -pub struct CommandPalette { - id: ElementId, -} - -impl Component for CommandPalette { - type Rendered = gpui::Stateful
; - - fn render(self, cx: &mut WindowContext) -> Self::Rendered { - div().id(self.id.clone()).child( - Palette::new("palette") - .items(example_editor_actions()) - .placeholder("Execute a command...") - .empty_string("No items found.") - .default_order(OrderMethod::Ascending), - ) - } -} - -impl CommandPalette { - pub fn new(id: impl Into) -> Self { - Self { id: id.into() } - } -} - -use gpui::{Div, RenderOnce, Stateful}; -#[cfg(feature = "stories")] -pub use stories::*; - -#[cfg(feature = "stories")] -mod stories { - use gpui::{Div, Render}; - - use crate::Story; - - use super::*; - - pub struct CommandPaletteStory; - - impl Render for CommandPaletteStory { - type Element = Div; - - fn render(&mut self, cx: &mut ViewContext) -> Self::Element { - Story::container(cx) - .child(Story::title_for::<_, CommandPalette>(cx)) - .child(Story::label(cx, "Default")) - .child(CommandPalette::new("command-palette")) - } - } -} diff --git a/crates/ui2/src/to_extract/copilot.rs b/crates/ui2/src/to_extract/copilot.rs deleted file mode 100644 index ebd4b734806538c9bc66c1a3e18f83f0d59f1698..0000000000000000000000000000000000000000 --- a/crates/ui2/src/to_extract/copilot.rs +++ /dev/null @@ -1,49 +0,0 @@ -use crate::{prelude::*, Button, Label, Modal, TextColor}; - -#[derive(RenderOnce)] -pub struct CopilotModal { - id: ElementId, -} - -impl Component for CopilotModal { - type Rendered = gpui::Stateful
; - - fn render(self, cx: &mut WindowContext) -> Self::Rendered { - div().id(self.id.clone()).child( - Modal::new("some-id") - .title("Connect Copilot to Zed") - .child(Label::new("You can update your settings or sign out from the Copilot menu in the status bar.").color(TextColor::Muted)) - .primary_action(Button::new("Connect to Github").variant(ButtonVariant::Filled)), - ) - } -} - -impl CopilotModal { - pub fn new(id: impl Into) -> Self { - Self { id: id.into() } - } -} - -use gpui::{Div, RenderOnce, Stateful}; -#[cfg(feature = "stories")] -pub use stories::*; - -#[cfg(feature = "stories")] -mod stories { - use super::*; - use crate::Story; - use gpui::{Div, Render}; - - pub struct CopilotModalStory; - - impl Render for CopilotModalStory { - type Element = Div; - - fn render(&mut self, cx: &mut ViewContext) -> Self::Element { - Story::container(cx) - .child(Story::title_for::<_, CopilotModal>(cx)) - .child(Story::label(cx, "Default")) - .child(CopilotModal::new("copilot-modal")) - } - } -} diff --git a/crates/ui2/src/to_extract/editor_pane.rs b/crates/ui2/src/to_extract/editor_pane.rs deleted file mode 100644 index 7da558b3f8e4481a447651a8ef0ee42e85d996a5..0000000000000000000000000000000000000000 --- a/crates/ui2/src/to_extract/editor_pane.rs +++ /dev/null @@ -1,77 +0,0 @@ -use std::path::PathBuf; - -use gpui::{Div, Render, RenderOnce, View, VisualContext}; - -use crate::prelude::*; -use crate::{ - hello_world_rust_editor_with_status_example, v_stack, Breadcrumb, Buffer, BufferSearch, Icon, - IconButton, Symbol, Tab, TabBar, TextColor, Toolbar, -}; - -#[derive(Clone)] -pub struct EditorPane { - tabs: Vec, - path: PathBuf, - symbols: Vec, - buffer: Buffer, - buffer_search: View, - is_buffer_search_open: bool, -} - -impl EditorPane { - pub fn new( - cx: &mut ViewContext, - tabs: Vec, - path: PathBuf, - symbols: Vec, - buffer: Buffer, - ) -> Self { - Self { - tabs, - path, - symbols, - buffer, - buffer_search: BufferSearch::view(cx), - is_buffer_search_open: false, - } - } - - pub fn toggle_buffer_search(&mut self, cx: &mut ViewContext) { - self.is_buffer_search_open = !self.is_buffer_search_open; - - cx.notify(); - } - - pub fn view(cx: &mut WindowContext) -> View { - cx.build_view(|cx| hello_world_rust_editor_with_status_example(cx)) - } -} - -impl Render for EditorPane { - type Element = Div; - - fn render(&mut self, cx: &mut WindowContext) -> Div { - v_stack() - .w_full() - .h_full() - .flex_1() - .child(TabBar::new("editor-pane-tabs", self.tabs.clone()).can_navigate((false, true))) - .child( - Toolbar::new() - .left_item(Breadcrumb::new(self.path.clone(), self.symbols.clone())) - .right_items(vec![ - IconButton::::new("toggle_inlay_hints", Icon::InlayHint), - IconButton::::new("buffer_search", Icon::MagnifyingGlass) - .when(self.is_buffer_search_open, |this| { - this.color(TextColor::Accent) - }) - .on_click(|editor: &mut Self, cx| { - editor.toggle_buffer_search(cx); - }), - IconButton::new("inline_assist", Icon::MagicWand), - ]), - ) - .children(Some(self.buffer_search.clone()).filter(|_| self.is_buffer_search_open)) - .child(self.buffer.clone()) - } -} diff --git a/crates/ui2/src/to_extract/language_selector.rs b/crates/ui2/src/to_extract/language_selector.rs deleted file mode 100644 index 486c894b932cea65acb0693172ce2fa1b3c8e30c..0000000000000000000000000000000000000000 --- a/crates/ui2/src/to_extract/language_selector.rs +++ /dev/null @@ -1,83 +0,0 @@ -use crate::prelude::*; -use crate::{OrderMethod, Palette, PaletteItem}; - -#[derive(RenderOnce)] -pub struct LanguageSelector { - id: ElementId, -} - -impl Component for LanguageSelector { - type Rendered = gpui::Stateful
; - - fn render(self, cx: &mut WindowContext) -> Self::Rendered { - div().id(self.id.clone()).child( - Palette::new("palette") - .items(vec![ - PaletteItem::new("C"), - PaletteItem::new("C++"), - PaletteItem::new("CSS"), - PaletteItem::new("Elixir"), - PaletteItem::new("Elm"), - PaletteItem::new("ERB"), - PaletteItem::new("Rust (current)"), - PaletteItem::new("Scheme"), - PaletteItem::new("TOML"), - PaletteItem::new("TypeScript"), - ]) - .placeholder("Select a language...") - .empty_string("No matches") - .default_order(OrderMethod::Ascending), - ) - } -} - -impl LanguageSelector { - pub fn new(id: impl Into) -> Self { - Self { id: id.into() } - } - - fn render(self, cx: &mut WindowContext) -> impl Element { - div().id(self.id.clone()).child( - Palette::new("palette") - .items(vec![ - PaletteItem::new("C"), - PaletteItem::new("C++"), - PaletteItem::new("CSS"), - PaletteItem::new("Elixir"), - PaletteItem::new("Elm"), - PaletteItem::new("ERB"), - PaletteItem::new("Rust (current)"), - PaletteItem::new("Scheme"), - PaletteItem::new("TOML"), - PaletteItem::new("TypeScript"), - ]) - .placeholder("Select a language...") - .empty_string("No matches") - .default_order(OrderMethod::Ascending), - ) - } -} - -use gpui::{Div, RenderOnce}; -#[cfg(feature = "stories")] -pub use stories::*; - -#[cfg(feature = "stories")] -mod stories { - use super::*; - use crate::Story; - use gpui::{Div, Render}; - - pub struct LanguageSelectorStory; - - impl Render for LanguageSelectorStory { - type Element = Div; - - fn render(&mut self, cx: &mut ViewContext) -> Self::Element { - Story::container(cx) - .child(Story::title_for::<_, LanguageSelector>(cx)) - .child(Story::label(cx, "Default")) - .child(LanguageSelector::new("language-selector")) - } - } -} diff --git a/crates/ui2/src/to_extract/multi_buffer.rs b/crates/ui2/src/to_extract/multi_buffer.rs deleted file mode 100644 index b92fbc6fcc9f7b738783e51d8d48def4aa5311c4..0000000000000000000000000000000000000000 --- a/crates/ui2/src/to_extract/multi_buffer.rs +++ /dev/null @@ -1,68 +0,0 @@ -use crate::prelude::*; -use crate::{v_stack, Buffer, Icon, IconButton, Label}; - -#[derive(RenderOnce)] -pub struct MultiBuffer { - buffers: Vec, -} - -impl Component for MultiBuffer { - type Rendered = Div; - - fn render(self, cx: &mut WindowContext) -> Self::Rendered { - v_stack() - .w_full() - .h_full() - .flex_1() - .children(self.buffers.clone().into_iter().map(|buffer| { - v_stack() - .child( - div() - .flex() - .items_center() - .justify_between() - .p_4() - .bg(cx.theme().colors().editor_subheader_background) - .child(Label::new("main.rs")) - .child(IconButton::new("arrow_up_right", Icon::ArrowUpRight)), - ) - .child(buffer) - })) - } -} - -impl MultiBuffer { - pub fn new(buffers: Vec) -> Self { - Self { buffers } - } -} - -use gpui::{Div, RenderOnce}; -#[cfg(feature = "stories")] -pub use stories::*; - -#[cfg(feature = "stories")] -mod stories { - use super::*; - use crate::{hello_world_rust_buffer_example, Story}; - use gpui::{Div, Render}; - - pub struct MultiBufferStory; - - impl Render for MultiBufferStory { - type Element = Div; - - fn render(&mut self, cx: &mut ViewContext) -> Self::Element { - Story::container(cx) - .child(Story::title_for::<_, MultiBuffer>(cx)) - .child(Story::label(cx, "Default")) - .child(MultiBuffer::new(vec![ - hello_world_rust_buffer_example(cx), - hello_world_rust_buffer_example(cx), - hello_world_rust_buffer_example(cx), - hello_world_rust_buffer_example(cx), - hello_world_rust_buffer_example(cx), - ])) - } - } -} diff --git a/crates/ui2/src/to_extract/notifications_panel.rs b/crates/ui2/src/to_extract/notifications_panel.rs deleted file mode 100644 index b4074f314b0c3bbde4ce3c2d7932a5e6e980a257..0000000000000000000000000000000000000000 --- a/crates/ui2/src/to_extract/notifications_panel.rs +++ /dev/null @@ -1,381 +0,0 @@ -use crate::{ - h_stack, prelude::*, static_new_notification_items_2, utils::naive_format_distance_from_now, - v_stack, Avatar, ButtonOrIconButton, Icon, IconElement, Label, LineHeightStyle, ListHeader, - ListHeaderMeta, ListSeparator, PublicPlayer, TextColor, UnreadIndicator, -}; -use gpui::{prelude::*, ClickEvent, Div}; - -#[derive(RenderOnce)] -pub struct NotificationsPanel { - id: ElementId, -} - -impl Component for NotificationsPanel { - type Rendered = gpui::Stateful
; - - fn render(self, cx: &mut WindowContext) -> Self::Rendered { - div() - .id(self.id.clone()) - .flex() - .flex_col() - .size_full() - .bg(cx.theme().colors().surface_background) - .child( - ListHeader::new("Notifications").meta(Some(ListHeaderMeta::Tools(vec![ - Icon::AtSign, - Icon::BellOff, - Icon::MailOpen, - ]))), - ) - .child(ListSeparator::new()) - .child( - v_stack() - .id("notifications-panel-scroll-view") - .py_1() - .overflow_y_scroll() - .flex_1() - .child( - div() - .mx_2() - .p_1() - // TODO: Add cursor style - // .cursor(Cursor::IBeam) - .bg(cx.theme().colors().element_background) - .border() - .border_color(cx.theme().colors().border_variant) - .child( - Label::new("Search...") - .color(TextColor::Placeholder) - .line_height_style(LineHeightStyle::UILabel), - ), - ) - .child(v_stack().px_1().children(static_new_notification_items_2())), - ) - } -} - -impl NotificationsPanel { - pub fn new(id: impl Into) -> Self { - Self { id: id.into() } - } -} - -pub struct NotificationAction { - button: ButtonOrIconButton, - tooltip: SharedString, - /// Shows after action is chosen - /// - /// For example, if the action is "Accept" the taken message could be: - /// - /// - `(None,"Accepted")` - "Accepted" - /// - /// - `(Some(Icon::Check),"Accepted")` - ✓ "Accepted" - taken_message: (Option, SharedString), -} - -impl NotificationAction { - pub fn new( - button: impl Into, - tooltip: impl Into, - (icon, taken_message): (Option, impl Into), - ) -> Self { - Self { - button: button.into(), - tooltip: tooltip.into(), - taken_message: (icon, taken_message.into()), - } - } -} - -pub enum ActorOrIcon { - Actor(PublicPlayer), - Icon(Icon), -} - -pub type ClickHandler = Box; - -pub struct NotificationMeta { - items: Vec<(Option, SharedString, Option)>, -} - -struct NotificationHandlers { - click: Option, -} - -impl Default for NotificationHandlers { - fn default() -> Self { - Self { click: None } - } -} - -#[derive(RenderOnce)] -pub struct Notification { - id: ElementId, - slot: ActorOrIcon, - message: SharedString, - date_received: NaiveDateTime, - meta: Option, - actions: Option<[NotificationAction; 2]>, - unread: bool, - new: bool, - action_taken: Option, - handlers: NotificationHandlers, -} - -impl Component for Notification { - type Rendered = gpui::Stateful
; - - fn render(self, cx: &mut WindowContext) -> Self::Rendered { - div() - .relative() - .id(self.id.clone()) - .p_1() - .flex() - .flex_col() - .w_full() - .children( - Some( - div() - .absolute() - .left(px(3.0)) - .top_3() - .z_index(2) - .child(UnreadIndicator::new()), - ) - .filter(|_| self.unread), - ) - .child( - v_stack() - .z_index(1) - .gap_1() - .w_full() - .child( - h_stack() - .w_full() - .gap_2() - .child(self.render_slot(cx)) - .child(div().flex_1().child(Label::new(self.message.clone()))), - ) - .child( - h_stack() - .justify_between() - .child( - h_stack() - .gap_1() - .child( - Label::new(naive_format_distance_from_now( - self.date_received, - true, - true, - )) - .color(TextColor::Muted), - ) - .child(self.render_meta_items(cx)), - ) - .child(match (self.actions, self.action_taken) { - // Show nothing - (None, _) => div(), - // Show the taken_message - (Some(_), Some(action_taken)) => h_stack() - .children(action_taken.taken_message.0.map(|icon| { - IconElement::new(icon).color(crate::TextColor::Muted) - })) - .child( - Label::new(action_taken.taken_message.1.clone()) - .color(TextColor::Muted), - ), - // Show the actions - (Some(actions), None) => { - h_stack().children(actions.map(|action| match action.button { - ButtonOrIconButton::Button(button) => { - button.render_into_any() - } - ButtonOrIconButton::IconButton(icon_button) => { - icon_button.render_into_any() - } - })) - } - }), - ), - ) - } -} - -impl Notification { - fn new( - id: ElementId, - message: SharedString, - date_received: NaiveDateTime, - slot: ActorOrIcon, - click_action: Option, - ) -> Self { - let handlers = if click_action.is_some() { - NotificationHandlers { - click: click_action, - } - } else { - NotificationHandlers::default() - }; - - Self { - id, - date_received, - message, - meta: None, - slot, - actions: None, - unread: true, - new: false, - action_taken: None, - handlers, - } - } - - /// Creates a new notification with an actor slot. - /// - /// Requires a click action. - pub fn new_actor_message( - id: impl Into, - message: impl Into, - date_received: NaiveDateTime, - actor: PublicPlayer, - click_action: ClickHandler, - ) -> Self { - Self::new( - id.into(), - message.into(), - date_received, - ActorOrIcon::Actor(actor), - Some(click_action), - ) - } - - /// Creates a new notification with an icon slot. - /// - /// Requires a click action. - pub fn new_icon_message( - id: impl Into, - message: impl Into, - date_received: NaiveDateTime, - icon: Icon, - click_action: ClickHandler, - ) -> Self { - Self::new( - id.into(), - message.into(), - date_received, - ActorOrIcon::Icon(icon), - Some(click_action), - ) - } - - /// Creates a new notification with an actor slot - /// and a Call To Action row. - /// - /// Cannot take a click action due to required actions. - pub fn new_actor_with_actions( - id: impl Into, - message: impl Into, - date_received: NaiveDateTime, - actor: PublicPlayer, - actions: [NotificationAction; 2], - ) -> Self { - Self::new( - id.into(), - message.into(), - date_received, - ActorOrIcon::Actor(actor), - None, - ) - .actions(actions) - } - - /// Creates a new notification with an icon slot - /// and a Call To Action row. - /// - /// Cannot take a click action due to required actions. - pub fn new_icon_with_actions( - id: impl Into, - message: impl Into, - date_received: NaiveDateTime, - icon: Icon, - actions: [NotificationAction; 2], - ) -> Self { - Self::new( - id.into(), - message.into(), - date_received, - ActorOrIcon::Icon(icon), - None, - ) - .actions(actions) - } - - fn on_click(mut self, handler: ClickHandler) -> Self { - self.handlers.click = Some(handler); - self - } - - pub fn actions(mut self, actions: [NotificationAction; 2]) -> Self { - self.actions = Some(actions); - self - } - - pub fn meta(mut self, meta: NotificationMeta) -> Self { - self.meta = Some(meta); - self - } - - fn render_meta_items(&self, cx: &mut WindowContext) -> impl Element { - if let Some(meta) = &self.meta { - h_stack().children( - meta.items - .iter() - .map(|(icon, text, _)| { - let mut meta_el = div(); - if let Some(icon) = icon { - meta_el = meta_el.child(IconElement::new(icon.clone())); - } - meta_el.child(Label::new(text.clone()).color(TextColor::Muted)) - }) - .collect::>(), - ) - } else { - div() - } - } - - fn render_slot(&self, cx: &mut WindowContext) -> impl Element { - match &self.slot { - ActorOrIcon::Actor(actor) => Avatar::new(actor.avatar.clone()).render_into_any(), - ActorOrIcon::Icon(icon) => IconElement::new(icon.clone()).render_into_any(), - } - } -} - -use chrono::NaiveDateTime; -use gpui::{px, Styled}; -#[cfg(feature = "stories")] -pub use stories::*; - -#[cfg(feature = "stories")] -mod stories { - use super::*; - use crate::{Panel, Story}; - use gpui::{Div, Render}; - - pub struct NotificationsPanelStory; - - impl Render for NotificationsPanelStory { - type Element = Div; - - fn render(&mut self, cx: &mut ViewContext) -> Self::Element { - Story::container(cx) - .child(Story::title_for::(cx)) - .child(Story::label(cx, "Default")) - .child( - Panel::new("panel", cx).child(NotificationsPanel::new("notifications_panel")), - ) - } - } -} diff --git a/crates/ui2/src/to_extract/panes.rs b/crates/ui2/src/to_extract/panes.rs deleted file mode 100644 index f0116379910e3812f337c3b06ba6d71a38448621..0000000000000000000000000000000000000000 --- a/crates/ui2/src/to_extract/panes.rs +++ /dev/null @@ -1,139 +0,0 @@ -use gpui::{ - hsla, red, AnyElement, Div, ElementId, ExternalPaths, Hsla, Length, RenderOnce, Size, Stateful, - View, -}; -use smallvec::SmallVec; - -use crate::prelude::*; - -#[derive(Default, PartialEq)] -pub enum SplitDirection { - #[default] - Horizontal, - Vertical, -} - -#[derive(RenderOnce)] -pub struct Pane { - id: ElementId, - size: Size, - fill: Hsla, - children: SmallVec<[AnyElement; 2]>, -} - -impl Component for Pane { - type Rendered = gpui::Stateful
; - - fn render(self, cx: &mut WindowContext) -> Self::Rendered { - div() - .id(self.id.clone()) - .flex() - .flex_initial() - .bg(self.fill) - .w(self.size.width) - .h(self.size.height) - .relative() - .child(div().z_index(0).size_full().children(self.children)) - .child( - div() - .z_index(1) - .id("drag-target") - .drag_over::(|d| d.bg(red())) - .on_drop(|_, files: View, cx| { - eprintln!("dropped files! {:?}", files.read(cx)); - }) - .absolute() - .inset_0(), - ) - } -} - -impl Pane { - pub fn new(id: impl Into, size: Size) -> Self { - // Fill is only here for debugging purposes, remove before release - - Self { - id: id.into(), - size, - fill: hsla(0.3, 0.3, 0.3, 1.), - children: SmallVec::new(), - } - } - - pub fn fill(mut self, fill: Hsla) -> Self { - self.fill = fill; - self - } -} - -impl ParentElement for Pane { - fn children_mut(&mut self) -> &mut SmallVec<[AnyElement; 2]> { - &mut self.children - } -} - -#[derive(RenderOnce)] -pub struct PaneGroup { - groups: Vec, - panes: Vec, - split_direction: SplitDirection, -} - -impl Component for PaneGroup { - type Rendered = Div; - - fn render(self, cx: &mut WindowContext) -> Self::Rendered { - if !self.panes.is_empty() { - let el = div() - .flex() - .flex_1() - .gap_px() - .w_full() - .h_full() - .children(self.panes.into_iter().map(|pane| pane.render(cx))); - - if self.split_direction == SplitDirection::Horizontal { - return el; - } else { - return el.flex_col(); - } - } - - if !self.groups.is_empty() { - let el = div() - .flex() - .flex_1() - .gap_px() - .w_full() - .h_full() - .bg(cx.theme().colors().editor_background) - .children(self.groups.into_iter().map(|group| group.render(cx))); - - if self.split_direction == SplitDirection::Horizontal { - return el; - } else { - return el.flex_col(); - } - } - - unreachable!() - } -} - -impl PaneGroup { - pub fn new_groups(groups: Vec, split_direction: SplitDirection) -> Self { - Self { - groups, - panes: Vec::new(), - split_direction, - } - } - - pub fn new_panes(panes: Vec, split_direction: SplitDirection) -> Self { - Self { - groups: Vec::new(), - panes, - split_direction, - } - } -} diff --git a/crates/ui2/src/to_extract/project_panel.rs b/crates/ui2/src/to_extract/project_panel.rs deleted file mode 100644 index 705a85776bc510f2b8cbd06479e4281b3102d2d3..0000000000000000000000000000000000000000 --- a/crates/ui2/src/to_extract/project_panel.rs +++ /dev/null @@ -1,117 +0,0 @@ -use crate::{ - prelude::*, static_project_panel_project_items, static_project_panel_single_items, Input, List, - ListHeader, -}; -use gpui::prelude::*; -use gpui::Div; -use gpui::Stateful; - -#[derive(RenderOnce)] -pub struct ProjectPanel { - id: ElementId, -} - -impl Component for ProjectPanel { - type Rendered = gpui::Stateful
; - - fn render(self, cx: &mut WindowContext) -> Self::Rendered { - div() - .id(self.id.clone()) - .flex() - .flex_col() - .size_full() - .bg(cx.theme().colors().surface_background) - .child( - div() - .id("project-panel-contents") - .w_full() - .flex() - .flex_col() - .overflow_y_scroll() - .child( - List::new() - .header(ListHeader::new("FILES")) - .empty_message("No files in directory") - .children(static_project_panel_single_items()), - ) - .child( - List::new() - .header(ListHeader::new("PROJECT")) - .empty_message("No folders in directory") - .children(static_project_panel_project_items()), - ), - ) - .child( - Input::new("Find something...") - .value("buffe".to_string()) - .state(InteractionState::Focused), - ) - } -} - -impl ProjectPanel { - pub fn new(id: impl Into) -> Self { - Self { id: id.into() } - } - - fn render(self, cx: &mut WindowContext) -> impl Element { - div() - .id(self.id.clone()) - .flex() - .flex_col() - .size_full() - .bg(cx.theme().colors().surface_background) - .child( - div() - .id("project-panel-contents") - .w_full() - .flex() - .flex_col() - .overflow_y_scroll() - .child( - List::new() - .header(ListHeader::new("FILES")) - .empty_message("No files in directory") - .children(static_project_panel_single_items()), - ) - .child( - List::new() - .header(ListHeader::new("PROJECT")) - .empty_message("No folders in directory") - .children(static_project_panel_project_items()), - ), - ) - .child( - Input::new("Find something...") - .value("buffe".to_string()) - .state(InteractionState::Focused), - ) - } -} - -use gpui::ElementId; -#[cfg(feature = "stories")] -pub use stories::*; - -#[cfg(feature = "stories")] -mod stories { - use super::*; - use crate::{Panel, Story}; - use gpui::{Div, Render}; - - pub struct ProjectPanelStory; - - impl Render for ProjectPanelStory { - type Element = Div; - - fn render(&mut self, cx: &mut ViewContext) -> Self::Element { - Story::container(cx) - .child(Story::title_for::<_, ProjectPanel>(cx)) - .child(Story::label(cx, "Default")) - .child( - Panel::new("project-panel-outer", cx) - .child(ProjectPanel::new("project-panel-inner")), - ) - } - } -} diff --git a/crates/ui2/src/to_extract/recent_projects.rs b/crates/ui2/src/to_extract/recent_projects.rs deleted file mode 100644 index cecb0d2228db4c5a209c0ca55ce00873f9e5c4b1..0000000000000000000000000000000000000000 --- a/crates/ui2/src/to_extract/recent_projects.rs +++ /dev/null @@ -1,58 +0,0 @@ -use crate::prelude::*; -use crate::{OrderMethod, Palette, PaletteItem}; - -#[derive(RenderOnce)] -pub struct RecentProjects { - id: ElementId, -} - -impl Component for RecentProjects { - type Rendered = Stateful
; - - fn render(self, cx: &mut WindowContext) -> Self::Rendered { - div().id(self.id.clone()).child( - Palette::new("palette") - .items(vec![ - PaletteItem::new("zed").sublabel(SharedString::from("~/projects/zed")), - PaletteItem::new("saga").sublabel(SharedString::from("~/projects/saga")), - PaletteItem::new("journal").sublabel(SharedString::from("~/journal")), - PaletteItem::new("dotfiles").sublabel(SharedString::from("~/dotfiles")), - PaletteItem::new("zed.dev").sublabel(SharedString::from("~/projects/zed.dev")), - PaletteItem::new("laminar").sublabel(SharedString::from("~/projects/laminar")), - ]) - .placeholder("Recent Projects...") - .empty_string("No matches") - .default_order(OrderMethod::Ascending), - ) - } -} - -impl RecentProjects { - pub fn new(id: impl Into) -> Self { - Self { id: id.into() } - } -} - -use gpui::{Div, RenderOnce, Stateful}; -#[cfg(feature = "stories")] -pub use stories::*; - -#[cfg(feature = "stories")] -mod stories { - use super::*; - use crate::Story; - use gpui::{Div, Render}; - - pub struct RecentProjectsStory; - - impl Render for RecentProjectsStory { - type Element = Div; - - fn render(&mut self, cx: &mut WindowContext) -> Self::Element { - Story::container(cx) - .child(Story::title_for::<_, RecentProjects>(cx)) - .child(Story::label(cx, "Default")) - .child(RecentProjects::new("recent-projects")) - } - } -} diff --git a/crates/ui2/src/to_extract/static_data.rs b/crates/ui2/src/to_extract/static_data.rs deleted file mode 100644 index 9d752d3fcaef6c8e7a66f4150e47bb64a7ae12d0..0000000000000000000000000000000000000000 --- a/crates/ui2/src/to_extract/static_data.rs +++ /dev/null @@ -1,1123 +0,0 @@ -use std::path::PathBuf; -use std::str::FromStr; -use std::sync::Arc; - -use chrono::DateTime; -use gpui::{AppContext, ViewContext}; -use rand::Rng; -use theme2::ActiveTheme; - -use crate::{ - binding, Buffer, BufferRow, BufferRows, Button, EditorPane, FileSystemStatus, GitStatus, - HighlightedLine, HighlightedText, Icon, KeyBinding, Label, ListEntrySize, ListItem, Livestream, - MicStatus, Notification, NotificationAction, PaletteItem, Player, PlayerCallStatus, - PlayerWithCallStatus, PublicPlayer, ScreenShareStatus, Symbol, Tab, TextColor, Toggle, - VideoStatus, -}; - -pub fn static_tabs_example() -> Vec { - vec![ - Tab::new("wip.rs") - .title("wip.rs".to_string()) - .icon(Icon::FileRust) - .current(false) - .fs_status(FileSystemStatus::Deleted), - Tab::new("Cargo.toml") - .title("Cargo.toml".to_string()) - .icon(Icon::FileToml) - .current(false) - .git_status(GitStatus::Modified), - Tab::new("Channels Panel") - .title("Channels Panel".to_string()) - .icon(Icon::Hash) - .current(false), - Tab::new("channels_panel.rs") - .title("channels_panel.rs".to_string()) - .icon(Icon::FileRust) - .current(true) - .git_status(GitStatus::Modified), - Tab::new("workspace.rs") - .title("workspace.rs".to_string()) - .current(false) - .icon(Icon::FileRust) - .git_status(GitStatus::Modified), - Tab::new("icon_button.rs") - .title("icon_button.rs".to_string()) - .icon(Icon::FileRust) - .current(false), - Tab::new("storybook.rs") - .title("storybook.rs".to_string()) - .icon(Icon::FileRust) - .current(false) - .git_status(GitStatus::Created), - Tab::new("theme.rs") - .title("theme.rs".to_string()) - .icon(Icon::FileRust) - .current(false), - Tab::new("theme_registry.rs") - .title("theme_registry.rs".to_string()) - .icon(Icon::FileRust) - .current(false), - Tab::new("styleable_helpers.rs") - .title("styleable_helpers.rs".to_string()) - .icon(Icon::FileRust) - .current(false), - ] -} - -pub fn static_tabs_1() -> Vec { - vec![ - Tab::new("project_panel.rs") - .title("project_panel.rs".to_string()) - .icon(Icon::FileRust) - .current(false) - .fs_status(FileSystemStatus::Deleted), - Tab::new("tab_bar.rs") - .title("tab_bar.rs".to_string()) - .icon(Icon::FileRust) - .current(false) - .git_status(GitStatus::Modified), - Tab::new("workspace.rs") - .title("workspace.rs".to_string()) - .icon(Icon::FileRust) - .current(false), - Tab::new("tab.rs") - .title("tab.rs".to_string()) - .icon(Icon::FileRust) - .current(true) - .git_status(GitStatus::Modified), - ] -} - -pub fn static_tabs_2() -> Vec { - vec![ - Tab::new("tab_bar.rs") - .title("tab_bar.rs".to_string()) - .icon(Icon::FileRust) - .current(false) - .fs_status(FileSystemStatus::Deleted), - Tab::new("static_data.rs") - .title("static_data.rs".to_string()) - .icon(Icon::FileRust) - .current(true) - .git_status(GitStatus::Modified), - ] -} - -pub fn static_tabs_3() -> Vec { - vec![Tab::new("static_tabs_3") - .git_status(GitStatus::Created) - .current(true)] -} - -pub fn static_players() -> Vec { - vec![ - Player::new( - 0, - "https://avatars.githubusercontent.com/u/1714999?v=4".into(), - "nathansobo".into(), - ), - Player::new( - 1, - "https://avatars.githubusercontent.com/u/326587?v=4".into(), - "maxbrunsfeld".into(), - ), - Player::new( - 2, - "https://avatars.githubusercontent.com/u/482957?v=4".into(), - "as-cii".into(), - ), - Player::new( - 3, - "https://avatars.githubusercontent.com/u/1714999?v=4".into(), - "iamnbutler".into(), - ), - Player::new( - 4, - "https://avatars.githubusercontent.com/u/1486634?v=4".into(), - "maxdeviant".into(), - ), - ] -} - -#[derive(Debug)] -pub struct PlayerData { - pub url: String, - pub name: String, -} - -pub fn static_player_data() -> Vec { - vec![ - PlayerData { - url: "https://avatars.githubusercontent.com/u/1714999?v=4".into(), - name: "iamnbutler".into(), - }, - PlayerData { - url: "https://avatars.githubusercontent.com/u/326587?v=4".into(), - name: "maxbrunsfeld".into(), - }, - PlayerData { - url: "https://avatars.githubusercontent.com/u/482957?v=4".into(), - name: "as-cii".into(), - }, - PlayerData { - url: "https://avatars.githubusercontent.com/u/1789?v=4".into(), - name: "nathansobo".into(), - }, - PlayerData { - url: "https://avatars.githubusercontent.com/u/1486634?v=4".into(), - name: "ForLoveOfCats".into(), - }, - PlayerData { - url: "https://avatars.githubusercontent.com/u/2690773?v=4".into(), - name: "SomeoneToIgnore".into(), - }, - PlayerData { - url: "https://avatars.githubusercontent.com/u/19867440?v=4".into(), - name: "JosephTLyons".into(), - }, - PlayerData { - url: "https://avatars.githubusercontent.com/u/24362066?v=4".into(), - name: "osiewicz".into(), - }, - PlayerData { - url: "https://avatars.githubusercontent.com/u/22121886?v=4".into(), - name: "KCaverly".into(), - }, - PlayerData { - url: "https://avatars.githubusercontent.com/u/1486634?v=4".into(), - name: "maxdeviant".into(), - }, - ] -} - -pub fn create_static_players(player_data: Vec) -> Vec { - let mut players = Vec::new(); - for data in player_data { - players.push(Player::new(players.len(), data.url, data.name)); - } - players -} - -pub fn static_player_1(data: &Vec) -> Player { - Player::new(1, data[0].url.clone(), data[0].name.clone()) -} - -pub fn static_player_2(data: &Vec) -> Player { - Player::new(2, data[1].url.clone(), data[1].name.clone()) -} - -pub fn static_player_3(data: &Vec) -> Player { - Player::new(3, data[2].url.clone(), data[2].name.clone()) -} - -pub fn static_player_4(data: &Vec) -> Player { - Player::new(4, data[3].url.clone(), data[3].name.clone()) -} - -pub fn static_player_5(data: &Vec) -> Player { - Player::new(5, data[4].url.clone(), data[4].name.clone()) -} - -pub fn static_player_6(data: &Vec) -> Player { - Player::new(6, data[5].url.clone(), data[5].name.clone()) -} - -pub fn static_player_7(data: &Vec) -> Player { - Player::new(7, data[6].url.clone(), data[6].name.clone()) -} - -pub fn static_player_8(data: &Vec) -> Player { - Player::new(8, data[7].url.clone(), data[7].name.clone()) -} - -pub fn static_player_9(data: &Vec) -> Player { - Player::new(9, data[8].url.clone(), data[8].name.clone()) -} - -pub fn static_player_10(data: &Vec) -> Player { - Player::new(10, data[9].url.clone(), data[9].name.clone()) -} - -pub fn static_livestream() -> Livestream { - Livestream { - players: random_players_with_call_status(7), - channel: Some("gpui2-ui".to_string()), - } -} - -pub fn populate_player_call_status( - player: Player, - followers: Option>, -) -> PlayerCallStatus { - let mut rng = rand::thread_rng(); - let in_current_project: bool = rng.gen(); - let disconnected: bool = rng.gen(); - let voice_activity: f32 = rng.gen(); - let mic_status = if rng.gen_bool(0.5) { - MicStatus::Muted - } else { - MicStatus::Unmuted - }; - let video_status = if rng.gen_bool(0.5) { - VideoStatus::On - } else { - VideoStatus::Off - }; - let screen_share_status = if rng.gen_bool(0.5) { - ScreenShareStatus::Shared - } else { - ScreenShareStatus::NotShared - }; - PlayerCallStatus { - mic_status, - voice_activity, - video_status, - screen_share_status, - in_current_project, - disconnected, - following: None, - followers, - } -} - -pub fn random_players_with_call_status(number_of_players: usize) -> Vec { - let players = create_static_players(static_player_data()); - let mut player_status = vec![]; - for i in 0..number_of_players { - let followers = if i == 0 { - Some(vec![ - players[1].clone(), - players[3].clone(), - players[5].clone(), - players[6].clone(), - ]) - } else if i == 1 { - Some(vec![players[2].clone(), players[6].clone()]) - } else { - None - }; - let call_status = populate_player_call_status(players[i].clone(), followers); - player_status.push(PlayerWithCallStatus::new(players[i].clone(), call_status)); - } - player_status -} - -pub fn static_players_with_call_status() -> Vec { - let players = static_players(); - let mut player_0_status = PlayerCallStatus::new(); - let player_1_status = PlayerCallStatus::new(); - let player_2_status = PlayerCallStatus::new(); - let mut player_3_status = PlayerCallStatus::new(); - let mut player_4_status = PlayerCallStatus::new(); - - player_0_status.screen_share_status = ScreenShareStatus::Shared; - player_0_status.followers = Some(vec![players[1].clone(), players[3].clone()]); - - player_3_status.voice_activity = 0.5; - player_4_status.mic_status = MicStatus::Muted; - player_4_status.in_current_project = false; - - vec![ - PlayerWithCallStatus::new(players[0].clone(), player_0_status), - PlayerWithCallStatus::new(players[1].clone(), player_1_status), - PlayerWithCallStatus::new(players[2].clone(), player_2_status), - PlayerWithCallStatus::new(players[3].clone(), player_3_status), - PlayerWithCallStatus::new(players[4].clone(), player_4_status), - ] -} - -pub fn static_new_notification_items_2() -> Vec { - vec![ - Notification::new_icon_message( - "notif-1", - "You were mentioned in a note.", - DateTime::parse_from_rfc3339("2023-11-02T11:59:57Z") - .unwrap() - .naive_local(), - Icon::AtSign, - Arc::new(|_, _| {}), - ), - Notification::new_actor_with_actions( - "notif-2", - "as-cii sent you a contact request.", - DateTime::parse_from_rfc3339("2023-11-02T12:09:07Z") - .unwrap() - .naive_local(), - PublicPlayer::new("as-cii", "http://github.com/as-cii.png?s=50"), - [ - NotificationAction::new( - Button::new("Decline"), - "Decline Request", - (Some(Icon::XCircle), "Declined"), - ), - NotificationAction::new( - Button::new("Accept").variant(crate::ButtonVariant::Filled), - "Accept Request", - (Some(Icon::Check), "Accepted"), - ), - ], - ), - Notification::new_icon_message( - "notif-3", - "You were mentioned #design.", - DateTime::parse_from_rfc3339("2023-11-02T12:09:07Z") - .unwrap() - .naive_local(), - Icon::MessageBubbles, - Arc::new(|_, _| {}), - ), - Notification::new_actor_with_actions( - "notif-4", - "as-cii sent you a contact request.", - DateTime::parse_from_rfc3339("2023-11-01T12:09:07Z") - .unwrap() - .naive_local(), - PublicPlayer::new("as-cii", "http://github.com/as-cii.png?s=50"), - [ - NotificationAction::new( - Button::new("Decline"), - "Decline Request", - (Some(Icon::XCircle), "Declined"), - ), - NotificationAction::new( - Button::new("Accept").variant(crate::ButtonVariant::Filled), - "Accept Request", - (Some(Icon::Check), "Accepted"), - ), - ], - ), - Notification::new_icon_message( - "notif-5", - "You were mentioned in a note.", - DateTime::parse_from_rfc3339("2023-10-28T12:09:07Z") - .unwrap() - .naive_local(), - Icon::AtSign, - Arc::new(|_, _| {}), - ), - Notification::new_actor_with_actions( - "notif-6", - "as-cii sent you a contact request.", - DateTime::parse_from_rfc3339("2022-10-25T12:09:07Z") - .unwrap() - .naive_local(), - PublicPlayer::new("as-cii", "http://github.com/as-cii.png?s=50"), - [ - NotificationAction::new( - Button::new("Decline"), - "Decline Request", - (Some(Icon::XCircle), "Declined"), - ), - NotificationAction::new( - Button::new("Accept").variant(crate::ButtonVariant::Filled), - "Accept Request", - (Some(Icon::Check), "Accepted"), - ), - ], - ), - Notification::new_icon_message( - "notif-7", - "You were mentioned in a note.", - DateTime::parse_from_rfc3339("2022-10-14T12:09:07Z") - .unwrap() - .naive_local(), - Icon::AtSign, - Arc::new(|_, _| {}), - ), - Notification::new_actor_with_actions( - "notif-8", - "as-cii sent you a contact request.", - DateTime::parse_from_rfc3339("2021-10-12T12:09:07Z") - .unwrap() - .naive_local(), - PublicPlayer::new("as-cii", "http://github.com/as-cii.png?s=50"), - [ - NotificationAction::new( - Button::new("Decline"), - "Decline Request", - (Some(Icon::XCircle), "Declined"), - ), - NotificationAction::new( - Button::new("Accept").variant(crate::ButtonVariant::Filled), - "Accept Request", - (Some(Icon::Check), "Accepted"), - ), - ], - ), - Notification::new_icon_message( - "notif-9", - "You were mentioned in a note.", - DateTime::parse_from_rfc3339("2021-02-02T12:09:07Z") - .unwrap() - .naive_local(), - Icon::AtSign, - Arc::new(|_, _| {}), - ), - Notification::new_actor_with_actions( - "notif-10", - "as-cii sent you a contact request.", - DateTime::parse_from_rfc3339("1969-07-20T00:00:00Z") - .unwrap() - .naive_local(), - PublicPlayer::new("as-cii", "http://github.com/as-cii.png?s=50"), - [ - NotificationAction::new( - Button::new("Decline"), - "Decline Request", - (Some(Icon::XCircle), "Declined"), - ), - NotificationAction::new( - Button::new("Accept").variant(crate::ButtonVariant::Filled), - "Accept Request", - (Some(Icon::Check), "Accepted"), - ), - ], - ), - ] -} - -pub fn static_project_panel_project_items() -> Vec { - vec![ - ListItem::new("zed", Label::new("zed")) - .left_icon(Icon::FolderOpen.into()) - .indent_level(0) - .toggle(Toggle::Toggled(true)), - ListItem::new(".cargo", Label::new(".cargo")) - .left_icon(Icon::Folder.into()) - .indent_level(1), - ListItem::new(".config", Label::new(".config")) - .left_icon(Icon::Folder.into()) - .indent_level(1), - ListItem::new(".git", Label::new(".git").color(TextColor::Hidden)) - .left_icon(Icon::Folder.into()) - .indent_level(1), - ListItem::new(".cargo", Label::new(".cargo")) - .left_icon(Icon::Folder.into()) - .indent_level(1), - ListItem::new(".idea", Label::new(".idea").color(TextColor::Hidden)) - .left_icon(Icon::Folder.into()) - .indent_level(1), - ListItem::new("assets", Label::new("assets")) - .left_icon(Icon::Folder.into()) - .indent_level(1) - .toggle(Toggle::Toggled(true)), - ListItem::new( - "cargo-target", - Label::new("cargo-target").color(TextColor::Hidden), - ) - .left_icon(Icon::Folder.into()) - .indent_level(1), - ListItem::new("crates", Label::new("crates")) - .left_icon(Icon::FolderOpen.into()) - .indent_level(1) - .toggle(Toggle::Toggled(true)), - ListItem::new("activity_indicator", Label::new("activity_indicator")) - .left_icon(Icon::Folder.into()) - .indent_level(2), - ListItem::new("ai", Label::new("ai")) - .left_icon(Icon::Folder.into()) - .indent_level(2), - ListItem::new("audio", Label::new("audio")) - .left_icon(Icon::Folder.into()) - .indent_level(2), - ListItem::new("auto_update", Label::new("auto_update")) - .left_icon(Icon::Folder.into()) - .indent_level(2), - ListItem::new("breadcrumbs", Label::new("breadcrumbs")) - .left_icon(Icon::Folder.into()) - .indent_level(2), - ListItem::new("call", Label::new("call")) - .left_icon(Icon::Folder.into()) - .indent_level(2), - ListItem::new("sqlez", Label::new("sqlez").color(TextColor::Modified)) - .left_icon(Icon::Folder.into()) - .indent_level(2) - .toggle(Toggle::Toggled(false)), - ListItem::new("gpui2", Label::new("gpui2")) - .left_icon(Icon::FolderOpen.into()) - .indent_level(2) - .toggle(Toggle::Toggled(true)), - ListItem::new("src", Label::new("src")) - .left_icon(Icon::FolderOpen.into()) - .indent_level(3) - .toggle(Toggle::Toggled(true)), - ListItem::new("derive_element.rs", Label::new("derive_element.rs")) - .left_icon(Icon::FileRust.into()) - .indent_level(4), - ListItem::new( - "storybook", - Label::new("storybook").color(TextColor::Modified), - ) - .left_icon(Icon::FolderOpen.into()) - .indent_level(1) - .toggle(Toggle::Toggled(true)), - ListItem::new("docs", Label::new("docs").color(TextColor::Default)) - .left_icon(Icon::Folder.into()) - .indent_level(2) - .toggle(Toggle::Toggled(true)), - ListItem::new("src", Label::new("src").color(TextColor::Modified)) - .left_icon(Icon::FolderOpen.into()) - .indent_level(3) - .toggle(Toggle::Toggled(true)), - ListItem::new("ui", Label::new("ui").color(TextColor::Modified)) - .left_icon(Icon::FolderOpen.into()) - .indent_level(4) - .toggle(Toggle::Toggled(true)), - ListItem::new( - "component", - Label::new("component").color(TextColor::Created), - ) - .left_icon(Icon::FolderOpen.into()) - .indent_level(5) - .toggle(Toggle::Toggled(true)), - ListItem::new( - "facepile.rs", - Label::new("facepile.rs").color(TextColor::Default), - ) - .left_icon(Icon::FileRust.into()) - .indent_level(6), - ListItem::new( - "follow_group.rs", - Label::new("follow_group.rs").color(TextColor::Default), - ) - .left_icon(Icon::FileRust.into()) - .indent_level(6), - ListItem::new( - "list_item.rs", - Label::new("list_item.rs").color(TextColor::Created), - ) - .left_icon(Icon::FileRust.into()) - .indent_level(6), - ListItem::new("tab.rs", Label::new("tab.rs").color(TextColor::Default)) - .left_icon(Icon::FileRust.into()) - .indent_level(6), - ListItem::new("target", Label::new("target").color(TextColor::Hidden)) - .left_icon(Icon::Folder.into()) - .indent_level(1), - ListItem::new(".dockerignore", Label::new(".dockerignore")) - .left_icon(Icon::FileGeneric.into()) - .indent_level(1), - ListItem::new( - ".DS_Store", - Label::new(".DS_Store").color(TextColor::Hidden), - ) - .left_icon(Icon::FileGeneric.into()) - .indent_level(1), - ListItem::new("Cargo.lock", Label::new("Cargo.lock")) - .left_icon(Icon::FileLock.into()) - .indent_level(1), - ListItem::new("Cargo.toml", Label::new("Cargo.toml")) - .left_icon(Icon::FileToml.into()) - .indent_level(1), - ListItem::new("Dockerfile", Label::new("Dockerfile")) - .left_icon(Icon::FileGeneric.into()) - .indent_level(1), - ListItem::new("Procfile", Label::new("Procfile")) - .left_icon(Icon::FileGeneric.into()) - .indent_level(1), - ListItem::new("README.md", Label::new("README.md")) - .left_icon(Icon::FileDoc.into()) - .indent_level(1), - ] -} - -pub fn static_project_panel_single_items() -> Vec { - vec![ - ListItem::new("todo.md", Label::new("todo.md")) - .left_icon(Icon::FileDoc.into()) - .indent_level(0), - ListItem::new("README.md", Label::new("README.md")) - .left_icon(Icon::FileDoc.into()) - .indent_level(0), - ListItem::new("config.json", Label::new("config.json")) - .left_icon(Icon::FileGeneric.into()) - .indent_level(0), - ] -} - -pub fn static_collab_panel_current_call() -> Vec { - vec![ - ListItem::new("as-cii", Label::new("as-cii")) - .left_avatar("http://github.com/as-cii.png?s=50"), - ListItem::new("nathansobo", Label::new("nathansobo")) - .left_avatar("http://github.com/nathansobo.png?s=50"), - ListItem::new("maxbrunsfeld", Label::new("maxbrunsfeld")) - .left_avatar("http://github.com/maxbrunsfeld.png?s=50"), - ] -} - -pub fn static_collab_panel_channels() -> Vec { - vec![ - ListItem::new("zed", Label::new("zed")) - .left_icon(Icon::Hash.into()) - .size(ListEntrySize::Medium) - .indent_level(0), - ListItem::new("community", Label::new("community")) - .left_icon(Icon::Hash.into()) - .size(ListEntrySize::Medium) - .indent_level(1), - ListItem::new("dashboards", Label::new("dashboards")) - .left_icon(Icon::Hash.into()) - .size(ListEntrySize::Medium) - .indent_level(2), - ListItem::new("feedback", Label::new("feedback")) - .left_icon(Icon::Hash.into()) - .size(ListEntrySize::Medium) - .indent_level(2), - ListItem::new( - "teams-in-channels-alpha", - Label::new("teams-in-channels-alpha"), - ) - .left_icon(Icon::Hash.into()) - .size(ListEntrySize::Medium) - .indent_level(2), - ListItem::new("current-projects", Label::new("current-projects")) - .left_icon(Icon::Hash.into()) - .size(ListEntrySize::Medium) - .indent_level(1), - ListItem::new("codegen", Label::new("codegen")) - .left_icon(Icon::Hash.into()) - .size(ListEntrySize::Medium) - .indent_level(2), - ListItem::new("gpui2", Label::new("gpui2")) - .left_icon(Icon::Hash.into()) - .size(ListEntrySize::Medium) - .indent_level(2), - ListItem::new("livestreaming", Label::new("livestreaming")) - .left_icon(Icon::Hash.into()) - .size(ListEntrySize::Medium) - .indent_level(2), - ListItem::new("open-source", Label::new("open-source")) - .left_icon(Icon::Hash.into()) - .size(ListEntrySize::Medium) - .indent_level(2), - ListItem::new("replace", Label::new("replace")) - .left_icon(Icon::Hash.into()) - .size(ListEntrySize::Medium) - .indent_level(2), - ListItem::new("semantic-index", Label::new("semantic-index")) - .left_icon(Icon::Hash.into()) - .size(ListEntrySize::Medium) - .indent_level(2), - ListItem::new("vim", Label::new("vim")) - .left_icon(Icon::Hash.into()) - .size(ListEntrySize::Medium) - .indent_level(2), - ListItem::new("web-tech", Label::new("web-tech")) - .left_icon(Icon::Hash.into()) - .size(ListEntrySize::Medium) - .indent_level(2), - ] -} - -pub fn example_editor_actions() -> Vec { - vec![ - PaletteItem::new("New File").key_binding(KeyBinding::new(binding("cmd-n"))), - PaletteItem::new("Open File").key_binding(KeyBinding::new(binding("cmd-o"))), - PaletteItem::new("Save File").key_binding(KeyBinding::new(binding("cmd-s"))), - PaletteItem::new("Cut").key_binding(KeyBinding::new(binding("cmd-x"))), - PaletteItem::new("Copy").key_binding(KeyBinding::new(binding("cmd-c"))), - PaletteItem::new("Paste").key_binding(KeyBinding::new(binding("cmd-v"))), - PaletteItem::new("Undo").key_binding(KeyBinding::new(binding("cmd-z"))), - PaletteItem::new("Redo").key_binding(KeyBinding::new(binding("cmd-shift-z"))), - PaletteItem::new("Find").key_binding(KeyBinding::new(binding("cmd-f"))), - PaletteItem::new("Replace").key_binding(KeyBinding::new(binding("cmd-r"))), - PaletteItem::new("Jump to Line"), - PaletteItem::new("Select All"), - PaletteItem::new("Deselect All"), - PaletteItem::new("Switch Document"), - PaletteItem::new("Insert Line Below"), - PaletteItem::new("Insert Line Above"), - PaletteItem::new("Move Line Up"), - PaletteItem::new("Move Line Down"), - PaletteItem::new("Toggle Comment"), - PaletteItem::new("Delete Line"), - ] -} - -pub fn empty_editor_example(cx: &mut ViewContext) -> EditorPane { - EditorPane::new( - cx, - static_tabs_example(), - PathBuf::from_str("crates/ui/src/static_data.rs").unwrap(), - vec![], - empty_buffer_example(), - ) -} - -pub fn empty_buffer_example() -> Buffer { - Buffer::new("empty-buffer").set_rows(Some(BufferRows::default())) -} - -pub fn hello_world_rust_editor_example(cx: &mut ViewContext) -> EditorPane { - EditorPane::new( - cx, - static_tabs_example(), - PathBuf::from_str("crates/ui/src/static_data.rs").unwrap(), - vec![Symbol(vec![ - HighlightedText { - text: "fn ".into(), - color: cx.theme().syntax_color("keyword"), - }, - HighlightedText { - text: "main".into(), - color: cx.theme().syntax_color("function"), - }, - ])], - hello_world_rust_buffer_example(cx), - ) -} - -pub fn hello_world_rust_buffer_example(cx: &AppContext) -> Buffer { - Buffer::new("hello-world-rust-buffer") - .set_title("hello_world.rs".to_string()) - .set_path("src/hello_world.rs".to_string()) - .set_language("rust".to_string()) - .set_rows(Some(BufferRows { - show_line_numbers: true, - rows: hello_world_rust_buffer_rows(cx), - })) -} - -pub fn hello_world_rust_buffer_rows(cx: &AppContext) -> Vec { - let show_line_number = true; - - vec![ - BufferRow { - line_number: 1, - code_action: false, - current: true, - line: Some(HighlightedLine { - highlighted_texts: vec![ - HighlightedText { - text: "fn ".into(), - color: cx.theme().syntax_color("keyword"), - }, - HighlightedText { - text: "main".into(), - color: cx.theme().syntax_color("function"), - }, - HighlightedText { - text: "() {".into(), - color: cx.theme().colors().text, - }, - ], - }), - cursors: None, - status: GitStatus::None, - show_line_number, - }, - BufferRow { - line_number: 2, - code_action: false, - current: false, - line: Some(HighlightedLine { - highlighted_texts: vec![HighlightedText { - text: " // Statements here are executed when the compiled binary is called." - .into(), - color: cx.theme().syntax_color("comment"), - }], - }), - cursors: None, - status: GitStatus::None, - show_line_number, - }, - BufferRow { - line_number: 3, - code_action: false, - current: false, - line: None, - cursors: None, - status: GitStatus::None, - show_line_number, - }, - BufferRow { - line_number: 4, - code_action: false, - current: false, - line: Some(HighlightedLine { - highlighted_texts: vec![HighlightedText { - text: " // Print text to the console.".into(), - color: cx.theme().syntax_color("comment"), - }], - }), - cursors: None, - status: GitStatus::None, - show_line_number, - }, - BufferRow { - line_number: 5, - code_action: false, - current: false, - line: Some(HighlightedLine { - highlighted_texts: vec![ - HighlightedText { - text: " println!(".into(), - color: cx.theme().colors().text, - }, - HighlightedText { - text: "\"Hello, world!\"".into(), - color: cx.theme().syntax_color("string"), - }, - HighlightedText { - text: ");".into(), - color: cx.theme().colors().text, - }, - ], - }), - cursors: None, - status: GitStatus::None, - show_line_number, - }, - BufferRow { - line_number: 6, - code_action: false, - current: false, - line: Some(HighlightedLine { - highlighted_texts: vec![HighlightedText { - text: "}".into(), - color: cx.theme().colors().text, - }], - }), - cursors: None, - status: GitStatus::None, - show_line_number, - }, - ] -} - -pub fn hello_world_rust_editor_with_status_example(cx: &mut ViewContext) -> EditorPane { - EditorPane::new( - cx, - static_tabs_example(), - PathBuf::from_str("crates/ui/src/static_data.rs").unwrap(), - vec![Symbol(vec![ - HighlightedText { - text: "fn ".into(), - color: cx.theme().syntax_color("keyword"), - }, - HighlightedText { - text: "main".into(), - color: cx.theme().syntax_color("function"), - }, - ])], - hello_world_rust_buffer_with_status_example(cx), - ) -} - -pub fn hello_world_rust_buffer_with_status_example(cx: &AppContext) -> Buffer { - Buffer::new("hello-world-rust-buffer-with-status") - .set_title("hello_world.rs".to_string()) - .set_path("src/hello_world.rs".to_string()) - .set_language("rust".to_string()) - .set_rows(Some(BufferRows { - show_line_numbers: true, - rows: hello_world_rust_with_status_buffer_rows(cx), - })) -} - -pub fn hello_world_rust_with_status_buffer_rows(cx: &AppContext) -> Vec { - let show_line_number = true; - - vec![ - BufferRow { - line_number: 1, - code_action: false, - current: true, - line: Some(HighlightedLine { - highlighted_texts: vec![ - HighlightedText { - text: "fn ".into(), - color: cx.theme().syntax_color("keyword"), - }, - HighlightedText { - text: "main".into(), - color: cx.theme().syntax_color("function"), - }, - HighlightedText { - text: "() {".into(), - color: cx.theme().colors().text, - }, - ], - }), - cursors: None, - status: GitStatus::None, - show_line_number, - }, - BufferRow { - line_number: 2, - code_action: false, - current: false, - line: Some(HighlightedLine { - highlighted_texts: vec![HighlightedText { - text: "// Statements here are executed when the compiled binary is called." - .into(), - color: cx.theme().syntax_color("comment"), - }], - }), - cursors: None, - status: GitStatus::Modified, - show_line_number, - }, - BufferRow { - line_number: 3, - code_action: false, - current: false, - line: None, - cursors: None, - status: GitStatus::None, - show_line_number, - }, - BufferRow { - line_number: 4, - code_action: false, - current: false, - line: Some(HighlightedLine { - highlighted_texts: vec![HighlightedText { - text: " // Print text to the console.".into(), - color: cx.theme().syntax_color("comment"), - }], - }), - cursors: None, - status: GitStatus::None, - show_line_number, - }, - BufferRow { - line_number: 5, - code_action: false, - current: false, - line: Some(HighlightedLine { - highlighted_texts: vec![ - HighlightedText { - text: " println!(".into(), - color: cx.theme().colors().text, - }, - HighlightedText { - text: "\"Hello, world!\"".into(), - color: cx.theme().syntax_color("string"), - }, - HighlightedText { - text: ");".into(), - color: cx.theme().colors().text, - }, - ], - }), - cursors: None, - status: GitStatus::None, - show_line_number, - }, - BufferRow { - line_number: 6, - code_action: false, - current: false, - line: Some(HighlightedLine { - highlighted_texts: vec![HighlightedText { - text: "}".into(), - color: cx.theme().colors().text, - }], - }), - cursors: None, - status: GitStatus::None, - show_line_number, - }, - BufferRow { - line_number: 7, - code_action: false, - current: false, - line: Some(HighlightedLine { - highlighted_texts: vec![HighlightedText { - text: "".into(), - color: cx.theme().colors().text, - }], - }), - cursors: None, - status: GitStatus::Created, - show_line_number, - }, - BufferRow { - line_number: 8, - code_action: false, - current: false, - line: Some(HighlightedLine { - highlighted_texts: vec![HighlightedText { - text: "// Marshall and Nate were here".into(), - color: cx.theme().syntax_color("comment"), - }], - }), - cursors: None, - status: GitStatus::Created, - show_line_number, - }, - ] -} - -pub fn terminal_buffer(cx: &AppContext) -> Buffer { - Buffer::new("terminal") - .set_title(Some("zed — fish".into())) - .set_rows(Some(BufferRows { - show_line_numbers: false, - rows: terminal_buffer_rows(cx), - })) -} - -pub fn terminal_buffer_rows(cx: &AppContext) -> Vec { - let show_line_number = false; - - vec![ - BufferRow { - line_number: 1, - code_action: false, - current: false, - line: Some(HighlightedLine { - highlighted_texts: vec![ - HighlightedText { - text: "maxdeviant ".into(), - color: cx.theme().syntax_color("keyword"), - }, - HighlightedText { - text: "in ".into(), - color: cx.theme().colors().text, - }, - HighlightedText { - text: "profaned-capital ".into(), - color: cx.theme().syntax_color("function"), - }, - HighlightedText { - text: "in ".into(), - color: cx.theme().colors().text, - }, - HighlightedText { - text: "~/p/zed ".into(), - color: cx.theme().syntax_color("function"), - }, - HighlightedText { - text: "on ".into(), - color: cx.theme().colors().text, - }, - HighlightedText { - text: " gpui2-ui ".into(), - color: cx.theme().syntax_color("keyword"), - }, - ], - }), - cursors: None, - status: GitStatus::None, - show_line_number, - }, - BufferRow { - line_number: 2, - code_action: false, - current: false, - line: Some(HighlightedLine { - highlighted_texts: vec![HighlightedText { - text: "λ ".into(), - color: cx.theme().syntax_color("string"), - }], - }), - cursors: None, - status: GitStatus::None, - show_line_number, - }, - ] -} diff --git a/crates/ui2/src/to_extract/status_bar.rs b/crates/ui2/src/to_extract/status_bar.rs deleted file mode 100644 index ee7fa94786a9fa397fcb027c37896ccbc0fbaeec..0000000000000000000000000000000000000000 --- a/crates/ui2/src/to_extract/status_bar.rs +++ /dev/null @@ -1,197 +0,0 @@ -use std::sync::Arc; - -use gpui::{Div, RenderOnce}; - -use crate::prelude::*; -use crate::{Button, Icon, IconButton, TextColor, ToolDivider, Workspace}; - -#[derive(Default, PartialEq)] -pub enum Tool { - #[default] - ProjectPanel, - CollaborationPanel, - Terminal, - Assistant, - Feedback, - Diagnostics, -} - -struct ToolGroup { - active_index: Option, - tools: Vec, -} - -impl Default for ToolGroup { - fn default() -> Self { - ToolGroup { - active_index: None, - tools: vec![], - } - } -} - -#[derive(RenderOnce)] -#[view = "Workspace"] -pub struct StatusBar { - left_tools: Option, - right_tools: Option, - bottom_tools: Option, -} - -impl Component for StatusBar { - type Rendered = Div; - - fn render(self, view: &mut Workspace, cx: &mut ViewContext) -> Self::Rendered { - div() - .py_0p5() - .px_1() - .flex() - .items_center() - .justify_between() - .w_full() - .bg(cx.theme().colors().status_bar_background) - .child(self.left_tools(view, cx)) - .child(self.right_tools(view, cx)) - } -} - -impl StatusBar { - pub fn new() -> Self { - Self { - left_tools: None, - right_tools: None, - bottom_tools: None, - } - } - - pub fn left_tool(mut self, tool: Tool, active_index: Option) -> Self { - self.left_tools = { - let mut tools = vec![tool]; - tools.extend(self.left_tools.take().unwrap_or_default().tools); - Some(ToolGroup { - active_index, - tools, - }) - }; - self - } - - pub fn right_tool(mut self, tool: Tool, active_index: Option) -> Self { - self.right_tools = { - let mut tools = vec![tool]; - tools.extend(self.left_tools.take().unwrap_or_default().tools); - Some(ToolGroup { - active_index, - tools, - }) - }; - self - } - - pub fn bottom_tool(mut self, tool: Tool, active_index: Option) -> Self { - self.bottom_tools = { - let mut tools = vec![tool]; - tools.extend(self.left_tools.take().unwrap_or_default().tools); - Some(ToolGroup { - active_index, - tools, - }) - }; - self - } - - fn left_tools(&self, workspace: &mut Workspace, cx: &WindowContext) -> impl Element { - div() - .flex() - .items_center() - .gap_1() - .child( - IconButton::::new("project_panel", Icon::FileTree) - .when(workspace.is_project_panel_open(), |this| { - this.color(TextColor::Accent) - }) - .on_click(|workspace: &mut Workspace, cx| { - workspace.toggle_project_panel(cx); - }), - ) - .child( - IconButton::::new("collab_panel", Icon::Hash) - .when(workspace.is_collab_panel_open(), |this| { - this.color(TextColor::Accent) - }) - .on_click(|workspace: &mut Workspace, cx| { - workspace.toggle_collab_panel(); - }), - ) - .child(ToolDivider::new()) - .child(IconButton::new("diagnostics", Icon::XCircle)) - } - - fn right_tools(&self, workspace: &mut Workspace, cx: &WindowContext) -> impl Element { - div() - .flex() - .items_center() - .gap_2() - .child( - div() - .flex() - .items_center() - .gap_1() - .child(Button::new("116:25")) - .child( - Button::::new("Rust").on_click(Arc::new(|workspace, cx| { - workspace.toggle_language_selector(cx); - })), - ), - ) - .child(ToolDivider::new()) - .child( - div() - .flex() - .items_center() - .gap_1() - .child( - IconButton::new("copilot", Icon::Copilot) - .on_click(|_, _| println!("Copilot clicked.")), - ) - .child( - IconButton::new("envelope", Icon::Envelope) - .on_click(|_, _| println!("Send Feedback clicked.")), - ), - ) - .child(ToolDivider::new()) - .child( - div() - .flex() - .items_center() - .gap_1() - .child( - IconButton::::new("terminal", Icon::Terminal) - .when(workspace.is_terminal_open(), |this| { - this.color(TextColor::Accent) - }) - .on_click(|workspace: &mut Workspace, cx| { - workspace.toggle_terminal(cx); - }), - ) - .child( - IconButton::::new("chat_panel", Icon::MessageBubbles) - .when(workspace.is_chat_panel_open(), |this| { - this.color(TextColor::Accent) - }) - .on_click(|workspace: &mut Workspace, cx| { - workspace.toggle_chat_panel(cx); - }), - ) - .child( - IconButton::::new("assistant_panel", Icon::Ai) - .when(workspace.is_assistant_panel_open(), |this| { - this.color(TextColor::Accent) - }) - .on_click(|workspace: &mut Workspace, cx| { - workspace.toggle_assistant_panel(cx); - }), - ), - ) - } -} diff --git a/crates/ui2/src/to_extract/tab_bar.rs b/crates/ui2/src/to_extract/tab_bar.rs deleted file mode 100644 index fa30eda2e3d8091a3032b0f0096ff5670f4403ed..0000000000000000000000000000000000000000 --- a/crates/ui2/src/to_extract/tab_bar.rs +++ /dev/null @@ -1,156 +0,0 @@ -use crate::{prelude::*, Icon, IconButton, Tab}; -use gpui::prelude::*; -use gpui::Div; -use gpui::Stateful; - -#[derive(RenderOnce)] -pub struct TabBar { - id: ElementId, - /// Backwards, Forwards - can_navigate: (bool, bool), - tabs: Vec, -} - -impl Component for TabBar { - type Rendered = gpui::Stateful
; - - fn render(self, cx: &mut WindowContext) -> Self::Rendered { - let (can_navigate_back, can_navigate_forward) = self.can_navigate; - - div() - .group("tab_bar") - .id(self.id.clone()) - .w_full() - .flex() - .bg(cx.theme().colors().tab_bar_background) - // Left Side - .child( - div() - .relative() - .px_1() - .flex() - .flex_none() - .gap_2() - // Nav Buttons - .child( - div() - .right_0() - .flex() - .items_center() - .gap_px() - .child( - IconButton::new("arrow_left", Icon::ArrowLeft) - .state(InteractionState::Enabled.if_enabled(can_navigate_back)), - ) - .child( - IconButton::new("arrow_right", Icon::ArrowRight).state( - InteractionState::Enabled.if_enabled(can_navigate_forward), - ), - ), - ), - ) - .child( - div().w_0().flex_1().h_full().child( - div() - .id("tabs") - .flex() - .overflow_x_scroll() - .children(self.tabs.clone()), - ), - ) - // Right Side - .child( - div() - // We only use absolute here since we don't - // have opacity or `hidden()` yet - .absolute() - .neg_top_7() - .px_1() - .flex() - .flex_none() - .gap_2() - .group_hover("tab_bar", |this| this.top_0()) - // Nav Buttons - .child( - div() - .flex() - .items_center() - .gap_px() - .child(IconButton::new("plus", Icon::Plus)) - .child(IconButton::new("split", Icon::Split)), - ), - ) - } -} - -impl TabBar { - pub fn new(id: impl Into, tabs: Vec) -> Self { - Self { - id: id.into(), - can_navigate: (false, false), - tabs, - } - } - - pub fn can_navigate(mut self, can_navigate: (bool, bool)) -> Self { - self.can_navigate = can_navigate; - self - } -} - -use gpui::ElementId; -#[cfg(feature = "stories")] -pub use stories::*; - -#[cfg(feature = "stories")] -mod stories { - use super::*; - use crate::Story; - use gpui::{Div, Render}; - - pub struct TabBarStory; - - impl Render for TabBarStory { - type Element = Div; - - fn render(&mut self, cx: &mut ViewContext) -> Self::Element { - Story::container(cx) - .child(Story::title_for::<_, TabBar>(cx)) - .child(Story::label(cx, "Default")) - .child(TabBar::new( - "tab-bar", - vec![ - Tab::new(1) - .title("Cargo.toml".to_string()) - .current(false) - .git_status(GitStatus::Modified), - Tab::new(2) - .title("Channels Panel".to_string()) - .current(false), - Tab::new(3) - .title("channels_panel.rs".to_string()) - .current(true) - .git_status(GitStatus::Modified), - Tab::new(4) - .title("workspace.rs".to_string()) - .current(false) - .git_status(GitStatus::Modified), - Tab::new(5) - .title("icon_button.rs".to_string()) - .current(false), - Tab::new(6) - .title("storybook.rs".to_string()) - .current(false) - .git_status(GitStatus::Created), - Tab::new(7).title("theme.rs".to_string()).current(false), - Tab::new(8) - .title("theme_registry.rs".to_string()) - .current(false), - Tab::new(9) - .title("styleable_helpers.rs".to_string()) - .current(false), - ], - )) - } - } -} diff --git a/crates/ui2/src/to_extract/terminal.rs b/crates/ui2/src/to_extract/terminal.rs deleted file mode 100644 index 5a571d446375d33f9672e0830ec4c609cd8626d1..0000000000000000000000000000000000000000 --- a/crates/ui2/src/to_extract/terminal.rs +++ /dev/null @@ -1,166 +0,0 @@ -use crate::prelude::*; -use crate::{Icon, IconButton, Pane, Tab}; -use gpui::{relative, rems, Div, RenderOnce, Size}; - -#[derive(RenderOnce)] -pub struct Terminal; - -impl Component for Terminal { - type Rendered = Div; - - fn render(self, cx: &mut WindowContext) -> Self::Rendered { - let can_navigate_back = true; - let can_navigate_forward = false; - - div() - .flex() - .flex_col() - .w_full() - .child( - // Terminal Tabs. - div() - .w_full() - .flex() - .bg(cx.theme().colors().surface_background) - .child( - div().px_1().flex().flex_none().gap_2().child( - div() - .flex() - .items_center() - .gap_px() - .child( - IconButton::new("arrow_left", Icon::ArrowLeft).state( - InteractionState::Enabled.if_enabled(can_navigate_back), - ), - ) - .child(IconButton::new("arrow_right", Icon::ArrowRight).state( - InteractionState::Enabled.if_enabled(can_navigate_forward), - )), - ), - ) - .child( - div().w_0().flex_1().h_full().child( - div() - .flex() - .child( - Tab::new(1) - .title("zed — fish".to_string()) - .icon(Icon::Terminal) - .close_side(IconSide::Right) - .current(true), - ) - .child( - Tab::new(2) - .title("zed — fish".to_string()) - .icon(Icon::Terminal) - .close_side(IconSide::Right) - .current(false), - ), - ), - ), - ) - // Terminal Pane. - .child( - Pane::new( - "terminal", - Size { - width: relative(1.).into(), - height: rems(36.).into(), - }, - ) - .child(crate::static_data::terminal_buffer(cx)), - ) - } -} - -impl Terminal { - pub fn new() -> Self { - Self - } - - fn render(self, cx: &mut WindowContext) -> impl Element { - let can_navigate_back = true; - let can_navigate_forward = false; - - div() - .flex() - .flex_col() - .w_full() - .child( - // Terminal Tabs. - div() - .w_full() - .flex() - .bg(cx.theme().colors().surface_background) - .child( - div().px_1().flex().flex_none().gap_2().child( - div() - .flex() - .items_center() - .gap_px() - .child( - IconButton::new("arrow_left", Icon::ArrowLeft).state( - InteractionState::Enabled.if_enabled(can_navigate_back), - ), - ) - .child(IconButton::new("arrow_right", Icon::ArrowRight).state( - InteractionState::Enabled.if_enabled(can_navigate_forward), - )), - ), - ) - .child( - div().w_0().flex_1().h_full().child( - div() - .flex() - .child( - Tab::new(1) - .title("zed — fish".to_string()) - .icon(Icon::Terminal) - .close_side(IconSide::Right) - .current(true), - ) - .child( - Tab::new(2) - .title("zed — fish".to_string()) - .icon(Icon::Terminal) - .close_side(IconSide::Right) - .current(false), - ), - ), - ), - ) - // Terminal Pane. - .child( - Pane::new( - "terminal", - Size { - width: relative(1.).into(), - height: rems(36.).into(), - }, - ) - .child(crate::static_data::terminal_buffer(cx)), - ) - } -} - -#[cfg(feature = "stories")] -pub use stories::*; - -#[cfg(feature = "stories")] -mod stories { - use super::*; - use crate::Story; - use gpui::{Div, Render}; - pub struct TerminalStory; - - impl Render for TerminalStory { - type Element = Div; - - fn render(&mut self, cx: &mut ViewContext) -> Self::Element { - Story::container(cx) - .child(Story::title_for::<_, Terminal>(cx)) - .child(Story::label(cx, "Default")) - .child(Terminal::new()) - } - } -} diff --git a/crates/ui2/src/to_extract/theme_selector.rs b/crates/ui2/src/to_extract/theme_selector.rs deleted file mode 100644 index 976dd6aa6aa3b01474f213e268d1be920d391f45..0000000000000000000000000000000000000000 --- a/crates/ui2/src/to_extract/theme_selector.rs +++ /dev/null @@ -1,65 +0,0 @@ -use crate::prelude::*; -use crate::{OrderMethod, Palette, PaletteItem}; - -#[derive(RenderOnce)] -pub struct ThemeSelector { - id: ElementId, -} - -impl Component for ThemeSelector { - type Rendered = Div; - - fn render(self, cx: &mut WindowContext) -> Self::Rendered { - div().child( - Palette::new(self.id.clone()) - .items(vec![ - PaletteItem::new("One Dark"), - PaletteItem::new("Rosé Pine"), - PaletteItem::new("Rosé Pine Moon"), - PaletteItem::new("Sandcastle"), - PaletteItem::new("Solarized Dark"), - PaletteItem::new("Summercamp"), - PaletteItem::new("Atelier Cave Light"), - PaletteItem::new("Atelier Dune Light"), - PaletteItem::new("Atelier Estuary Light"), - PaletteItem::new("Atelier Forest Light"), - PaletteItem::new("Atelier Heath Light"), - ]) - .placeholder("Select Theme...") - .empty_string("No matches") - .default_order(OrderMethod::Ascending), - ) - } -} - -impl ThemeSelector { - pub fn new(id: impl Into) -> Self { - Self { id: id.into() } - } -} - -use gpui::{Div, RenderOnce}; -#[cfg(feature = "stories")] -pub use stories::*; - -#[cfg(feature = "stories")] -mod stories { - use gpui::{Div, Render}; - - use crate::Story; - - use super::*; - - pub struct ThemeSelectorStory; - - impl Render for ThemeSelectorStory { - type Element = Div; - - fn render(&mut self, cx: &mut ViewContext) -> Self::Element { - Story::container(cx) - .child(Story::title_for::<_, ThemeSelector>(cx)) - .child(Story::label(cx, "Default")) - .child(ThemeSelector::new("theme-selector")) - } - } -} diff --git a/crates/ui2/src/to_extract/title_bar.rs b/crates/ui2/src/to_extract/title_bar.rs deleted file mode 100644 index 72145ea93c6600d82d247be5017592b04629dfc3..0000000000000000000000000000000000000000 --- a/crates/ui2/src/to_extract/title_bar.rs +++ /dev/null @@ -1,218 +0,0 @@ -use std::sync::atomic::AtomicBool; -use std::sync::Arc; - -use gpui::{Div, Render, RenderOnce, View, VisualContext}; - -use crate::prelude::*; -use crate::settings::user_settings; -use crate::{ - Avatar, Button, Icon, IconButton, MicStatus, PlayerStack, PlayerWithCallStatus, - ScreenShareStatus, TextColor, ToolDivider, TrafficLights, -}; - -#[derive(Clone)] -pub struct Livestream { - pub players: Vec, - pub channel: Option, // projects - // windows -} - -#[derive(Clone)] -pub struct TitleBar { - /// If the window is active from the OS's perspective. - is_active: Arc, - livestream: Option, - mic_status: MicStatus, - is_deafened: bool, - screen_share_status: ScreenShareStatus, -} - -impl TitleBar { - pub fn new(cx: &mut ViewContext) -> Self { - let is_active = Arc::new(AtomicBool::new(true)); - let active = is_active.clone(); - - // cx.observe_window_activation(move |_, is_active, cx| { - // active.store(is_active, std::sync::atomic::Ordering::SeqCst); - // cx.notify(); - // }) - // .detach(); - - Self { - is_active, - livestream: None, - mic_status: MicStatus::Unmuted, - is_deafened: false, - screen_share_status: ScreenShareStatus::NotShared, - } - } - - pub fn set_livestream(mut self, livestream: Option) -> Self { - self.livestream = livestream; - self - } - - pub fn is_mic_muted(&self) -> bool { - self.mic_status == MicStatus::Muted - } - - pub fn toggle_mic_status(&mut self, cx: &mut ViewContext) { - self.mic_status = self.mic_status.inverse(); - - // Undeafen yourself when unmuting the mic while deafened. - if self.is_deafened && self.mic_status == MicStatus::Unmuted { - self.is_deafened = false; - } - - cx.notify(); - } - - pub fn toggle_deafened(&mut self, cx: &mut ViewContext) { - self.is_deafened = !self.is_deafened; - self.mic_status = MicStatus::Muted; - - cx.notify() - } - - pub fn toggle_screen_share_status(&mut self, cx: &mut ViewContext) { - self.screen_share_status = self.screen_share_status.inverse(); - - cx.notify(); - } - - pub fn view(cx: &mut WindowContext, livestream: Option) -> View { - cx.build_view(|cx| Self::new(cx).set_livestream(livestream)) - } -} - -impl Render for TitleBar { - type Element = Div; - - fn render(&mut self, cx: &mut WindowContext) -> Div { - let settings = user_settings(cx); - - // let has_focus = cx.window_is_active(); - let has_focus = true; - - let player_list = if let Some(livestream) = &self.livestream { - livestream.players.clone().into_iter() - } else { - vec![].into_iter() - }; - - div() - .flex() - .items_center() - .justify_between() - .w_full() - .bg(cx.theme().colors().background) - .py_1() - .child( - div() - .flex() - .items_center() - .h_full() - .gap_4() - .px_2() - .child(TrafficLights::new().window_has_focus(has_focus)) - // === Project Info === // - .child( - div() - .flex() - .items_center() - .gap_1() - .when(*settings.titlebar.show_project_owner, |this| { - this.child(Button::new("iamnbutler")) - }) - .child(Button::new("zed")) - .child(Button::new("nate/gpui2-ui-components")), - ) - .children(player_list.map(|p| PlayerStack::new(p))) - .child(IconButton::new("plus", Icon::Plus)), - ) - .child( - div() - .flex() - .items_center() - .child( - div() - .px_2() - .flex() - .items_center() - .gap_1() - .child(IconButton::new("folder_x", Icon::FolderX)) - .child(IconButton::new("exit", Icon::Exit)), - ) - .child(ToolDivider::new()) - .child( - div() - .px_2() - .flex() - .items_center() - .gap_1() - .child( - IconButton::::new("toggle_mic_status", Icon::Mic) - .when(self.is_mic_muted(), |this| this.color(TextColor::Error)) - .on_click(|title_bar: &mut TitleBar, cx| { - title_bar.toggle_mic_status(cx) - }), - ) - .child( - IconButton::::new("toggle_deafened", Icon::AudioOn) - .when(self.is_deafened, |this| this.color(TextColor::Error)) - .on_click(|title_bar: &mut TitleBar, cx| { - title_bar.toggle_deafened(cx) - }), - ) - .child( - IconButton::::new("toggle_screen_share", Icon::Screen) - .when( - self.screen_share_status == ScreenShareStatus::Shared, - |this| this.color(TextColor::Accent), - ) - .on_click(|title_bar: &mut TitleBar, cx| { - title_bar.toggle_screen_share_status(cx) - }), - ), - ) - .child( - div().px_2().flex().items_center().child( - Avatar::new("https://avatars.githubusercontent.com/u/1714999?v=4") - .shape(Shape::RoundedRectangle), - ), - ), - ) - } -} - -#[cfg(feature = "stories")] -pub use stories::*; - -#[cfg(feature = "stories")] -mod stories { - use super::*; - use crate::Story; - - pub struct TitleBarStory { - title_bar: View, - } - - impl TitleBarStory { - pub fn view(cx: &mut WindowContext) -> View { - cx.build_view(|cx| Self { - title_bar: TitleBar::view(cx, None), - }) - } - } - - impl Render for TitleBarStory { - type Element = Div; - - fn render(&mut self, cx: &mut WindowContext) -> Div { - Story::container(cx) - .child(Story::title_for::<_, TitleBar>(cx)) - .child(Story::label(cx, "Default")) - .child(self.title_bar.clone()) - } - } -} diff --git a/crates/ui2/src/to_extract/toolbar.rs b/crates/ui2/src/to_extract/toolbar.rs deleted file mode 100644 index 6a0e9a907c769a6269af11ed22463d5007d63174..0000000000000000000000000000000000000000 --- a/crates/ui2/src/to_extract/toolbar.rs +++ /dev/null @@ -1,130 +0,0 @@ -use gpui::{AnyElement, Div, RenderOnce}; -use smallvec::SmallVec; - -use crate::prelude::*; - -#[derive(Clone)] -pub struct ToolbarItem {} - -#[derive(RenderOnce)] -pub struct Toolbar { - left_items: SmallVec<[AnyElement; 2]>, - right_items: SmallVec<[AnyElement; 2]>, -} - -impl Component for Toolbar { - type Rendered = Div; - - fn render(self, cx: &WindowContext) -> Self::Rendered { - div() - .bg(cx.theme().colors().toolbar_background) - .p_2() - .flex() - .justify_between() - .child(div().flex().children(self.left_items)) - .child(div().flex().children(self.right_items)) - } -} - -impl Toolbar { - pub fn new() -> Self { - Self { - left_items: SmallVec::new(), - right_items: SmallVec::new(), - } - } - - pub fn left_item(mut self, child: impl RenderOnce) -> Self - where - Self: Sized, - { - self.left_items.push(child.render_into_any()); - self - } - - pub fn left_items(mut self, iter: impl IntoIterator) -> Self - where - Self: Sized, - { - self.left_items - .extend(iter.into_iter().map(|item| item.render_into_any())); - self - } - - pub fn right_item(mut self, child: impl RenderOnce) -> Self - where - Self: Sized, - { - self.right_items.push(child.render_into_any()); - self - } - - pub fn right_items(mut self, iter: impl IntoIterator) -> Self - where - Self: Sized, - { - self.right_items - .extend(iter.into_iter().map(|item| item.render_into_any())); - self - } -} - -#[cfg(feature = "stories")] -pub use stories::*; - -#[cfg(feature = "stories")] -mod stories { - use std::path::PathBuf; - use std::str::FromStr; - - use gpui::{Div, Render}; - - use crate::{Breadcrumb, HighlightedText, Icon, IconButton, Story, Symbol}; - - use super::*; - - pub struct ToolbarStory; - - impl Render for ToolbarStory { - type Element = Div; - - fn render(&mut self, cx: &mut WindowContext) -> Self::Element { - Story::container(cx) - .child(Story::title_for::<_, Toolbar>(cx)) - .child(Story::label(cx, "Default")) - .child( - Toolbar::new() - .left_item(Breadcrumb::new( - PathBuf::from_str("crates/ui/src/components/toolbar.rs").unwrap(), - vec![ - Symbol(vec![ - HighlightedText { - text: "impl ".into(), - color: cx.theme().syntax_color("keyword"), - }, - HighlightedText { - text: "ToolbarStory".into(), - color: cx.theme().syntax_color("function"), - }, - ]), - Symbol(vec![ - HighlightedText { - text: "fn ".into(), - color: cx.theme().syntax_color("keyword"), - }, - HighlightedText { - text: "render".into(), - color: cx.theme().syntax_color("function"), - }, - ]), - ], - )) - .right_items(vec![ - IconButton::new("toggle_inlay_hints", Icon::InlayHint), - IconButton::new("buffer_search", Icon::MagnifyingGlass), - IconButton::new("inline_assist", Icon::MagicWand), - ]), - ) - } - } -} diff --git a/crates/ui2/src/to_extract/traffic_lights.rs b/crates/ui2/src/to_extract/traffic_lights.rs deleted file mode 100644 index 2087e80a93f974a03e7e27aec7492e8a94af610c..0000000000000000000000000000000000000000 --- a/crates/ui2/src/to_extract/traffic_lights.rs +++ /dev/null @@ -1,109 +0,0 @@ -// use crate::prelude::*; - -// #[derive(Clone, Copy)] -// enum TrafficLightColor { -// Red, -// Yellow, -// Green, -// } - -// #[derive(RenderOnce)] -// struct TrafficLight { -// color: TrafficLightColor, -// window_has_focus: bool, -// } - -// impl Component for TrafficLight { -// type Rendered = Div; - -// fn render(self, cx: &mut WindowContext) -> Self::Rendered { -// let system_colors = &cx.theme().styles.system; - -// let fill = match (self.window_has_focus, self.color) { -// (true, TrafficLightColor::Red) => system_colors.mac_os_traffic_light_red, -// (true, TrafficLightColor::Yellow) => system_colors.mac_os_traffic_light_yellow, -// (true, TrafficLightColor::Green) => system_colors.mac_os_traffic_light_green, -// (false, _) => cx.theme().colors().element_background, -// }; - -// div().w_3().h_3().rounded_full().bg(fill) -// } -// } - -// impl TrafficLight { -// fn new(color: TrafficLightColor, window_has_focus: bool) -> Self { -// Self { -// color, -// window_has_focus, -// } -// } -// } - -// #[derive(RenderOnce)] -// pub struct TrafficLights { -// window_has_focus: bool, -// } - -// impl Component for TrafficLights { -// type Rendered = Div; - -// fn render(self, cx: &mut WindowContext) -> Self::Rendered { -// div() -// .flex() -// .items_center() -// .gap_2() -// .child(TrafficLight::new( -// TrafficLightColor::Red, -// self.window_has_focus, -// )) -// .child(TrafficLight::new( -// TrafficLightColor::Yellow, -// self.window_has_focus, -// )) -// .child(TrafficLight::new( -// TrafficLightColor::Green, -// self.window_has_focus, -// )) -// } -// } - -// impl TrafficLights { -// pub fn new() -> Self { -// Self { -// window_has_focus: true, -// } -// } - -// pub fn window_has_focus(mut self, window_has_focus: bool) -> Self { -// self.window_has_focus = window_has_focus; -// self -// } -// } - -// use gpui::{Div, RenderOnce}; -// #[cfg(feature = "stories")] -// pub use stories::*; - -// #[cfg(feature = "stories")] -// mod stories { -// use gpui::{Div, Render}; - -// use crate::Story; - -// use super::*; - -// pub struct TrafficLightsStory; - -// impl Render for TrafficLightsStory { -// type Element = Div; - -// fn render(&mut self, cx: &mut ViewContext) -> Self::Element { -// Story::container(cx) -// .child(Story::title_for::(cx)) -// .child(Story::label(cx, "Default")) -// .child(TrafficLights::new()) -// .child(Story::label(cx, "Unfocused")) -// .child(TrafficLights::new().window_has_focus(false)) -// } -// } -// } diff --git a/crates/ui2/src/to_extract/workspace.rs b/crates/ui2/src/to_extract/workspace.rs deleted file mode 100644 index a49c15a97f3789cd058e1ec72564eeb23c733343..0000000000000000000000000000000000000000 --- a/crates/ui2/src/to_extract/workspace.rs +++ /dev/null @@ -1,398 +0,0 @@ -// use std::sync::Arc; - -// use chrono::DateTime; -// use gpui::{px, relative, Div, Render, RenderOnce, Size, View, VisualContext}; -// use settings2::Settings; -// use theme2::ThemeSettings; - -// use crate::prelude::*; -// use crate::{ -// static_livestream, v_stack, AssistantPanel, Button, ChatMessage, ChatPanel, Checkbox, -// CollabPanel, EditorPane, Label, LanguageSelector, NotificationsPanel, Pane, PaneGroup, Panel, -// PanelAllowedSides, PanelSide, ProjectPanel, SplitDirection, StatusBar, Terminal, TitleBar, -// Toast, ToastOrigin, -// }; - -// #[derive(Clone)] -// pub struct Gpui2UiDebug { -// pub in_livestream: bool, -// pub enable_user_settings: bool, -// pub show_toast: bool, -// } - -// impl Default for Gpui2UiDebug { -// fn default() -> Self { -// Self { -// in_livestream: false, -// enable_user_settings: false, -// show_toast: false, -// } -// } -// } - -// #[derive(Clone)] -// pub struct Workspace { -// title_bar: View, -// editor_1: View, -// show_project_panel: bool, -// show_collab_panel: bool, -// show_chat_panel: bool, -// show_assistant_panel: bool, -// show_notifications_panel: bool, -// show_terminal: bool, -// show_debug: bool, -// show_language_selector: bool, -// test_checkbox_selection: Selection, -// debug: Gpui2UiDebug, -// } - -// impl Workspace { -// pub fn new(cx: &mut ViewContext) -> Self { -// Self { -// title_bar: TitleBar::view(cx, None), -// editor_1: EditorPane::view(cx), -// show_project_panel: true, -// show_collab_panel: false, -// show_chat_panel: false, -// show_assistant_panel: false, -// show_terminal: true, -// show_language_selector: false, -// show_debug: false, -// show_notifications_panel: true, -// test_checkbox_selection: Selection::Unselected, -// debug: Gpui2UiDebug::default(), -// } -// } - -// pub fn is_project_panel_open(&self) -> bool { -// self.show_project_panel -// } - -// pub fn toggle_project_panel(&mut self, cx: &mut ViewContext) { -// self.show_project_panel = !self.show_project_panel; - -// self.show_collab_panel = false; - -// cx.notify(); -// } - -// pub fn is_collab_panel_open(&self) -> bool { -// self.show_collab_panel -// } - -// pub fn toggle_collab_panel(&mut self) { -// self.show_collab_panel = !self.show_collab_panel; - -// self.show_project_panel = false; -// } - -// pub fn is_terminal_open(&self) -> bool { -// self.show_terminal -// } - -// pub fn toggle_terminal(&mut self, cx: &mut ViewContext) { -// self.show_terminal = !self.show_terminal; - -// cx.notify(); -// } - -// pub fn is_chat_panel_open(&self) -> bool { -// self.show_chat_panel -// } - -// pub fn toggle_chat_panel(&mut self, cx: &mut ViewContext) { -// self.show_chat_panel = !self.show_chat_panel; - -// self.show_assistant_panel = false; -// self.show_notifications_panel = false; - -// cx.notify(); -// } - -// pub fn is_notifications_panel_open(&self) -> bool { -// self.show_notifications_panel -// } - -// pub fn toggle_notifications_panel(&mut self, cx: &mut ViewContext) { -// self.show_notifications_panel = !self.show_notifications_panel; - -// self.show_chat_panel = false; -// self.show_assistant_panel = false; - -// cx.notify(); -// } - -// pub fn is_assistant_panel_open(&self) -> bool { -// self.show_assistant_panel -// } - -// pub fn toggle_assistant_panel(&mut self, cx: &mut ViewContext) { -// self.show_assistant_panel = !self.show_assistant_panel; - -// self.show_chat_panel = false; -// self.show_notifications_panel = false; - -// cx.notify(); -// } - -// pub fn is_language_selector_open(&self) -> bool { -// self.show_language_selector -// } - -// pub fn toggle_language_selector(&mut self, cx: &mut ViewContext) { -// self.show_language_selector = !self.show_language_selector; - -// cx.notify(); -// } - -// pub fn toggle_debug(&mut self, cx: &mut ViewContext) { -// self.show_debug = !self.show_debug; - -// cx.notify(); -// } - -// pub fn debug_toggle_user_settings(&mut self, cx: &mut ViewContext) { -// self.debug.enable_user_settings = !self.debug.enable_user_settings; - -// let mut theme_settings = ThemeSettings::get_global(cx).clone(); - -// if self.debug.enable_user_settings { -// theme_settings.ui_font_size = 18.0.into(); -// } else { -// theme_settings.ui_font_size = 16.0.into(); -// } - -// ThemeSettings::override_global(theme_settings.clone(), cx); - -// cx.set_rem_size(theme_settings.ui_font_size); - -// cx.notify(); -// } - -// pub fn debug_toggle_livestream(&mut self, cx: &mut ViewContext) { -// self.debug.in_livestream = !self.debug.in_livestream; - -// self.title_bar = TitleBar::view( -// cx, -// Some(static_livestream()).filter(|_| self.debug.in_livestream), -// ); - -// cx.notify(); -// } - -// pub fn debug_toggle_toast(&mut self, cx: &mut ViewContext) { -// self.debug.show_toast = !self.debug.show_toast; - -// cx.notify(); -// } - -// pub fn view(cx: &mut WindowContext) -> View { -// cx.build_view(|cx| Self::new(cx)) -// } -// } - -// impl Render for Workspace { -// type Element = Div; - -// fn render(&mut self, cx: &mut WindowContext) -> Div { -// let root_group = PaneGroup::new_panes( -// vec![Pane::new( -// "pane-0", -// Size { -// width: relative(1.).into(), -// height: relative(1.).into(), -// }, -// ) -// .child(self.editor_1.clone())], -// SplitDirection::Horizontal, -// ); -// let ui_font = ThemeSettings::get_global(cx).ui_font.family.clone(); - -// div() -// .relative() -// .size_full() -// .flex() -// .flex_col() -// .font(ui_font) -// .gap_0() -// .justify_start() -// .items_start() -// .text_color(cx.theme().colors().text) -// .bg(cx.theme().colors().background) -// .child(self.title_bar.clone()) -// .child( -// div() -// .absolute() -// .top_12() -// .left_12() -// .z_index(99) -// .bg(cx.theme().colors().background) -// .child( -// Checkbox::new("test_checkbox", self.test_checkbox_selection).on_click( -// |selection, workspace: &mut Workspace, cx| { -// workspace.test_checkbox_selection = selection; - -// cx.notify(); -// }, -// ), -// ), -// ) -// .child( -// div() -// .flex_1() -// .w_full() -// .flex() -// .flex_row() -// .overflow_hidden() -// .border_t() -// .border_b() -// .border_color(cx.theme().colors().border) -// .children( -// Some( -// Panel::new("project-panel-outer", cx) -// .side(PanelSide::Left) -// .child(ProjectPanel::new("project-panel-inner")), -// ) -// .filter(|_| self.is_project_panel_open()), -// ) -// .children( -// Some( -// Panel::new("collab-panel-outer", cx) -// .child(CollabPanel::new("collab-panel-inner")) -// .side(PanelSide::Left), -// ) -// .filter(|_| self.is_collab_panel_open()), -// ) -// // .child(NotificationToast::new( -// // "maxbrunsfeld has requested to add you as a contact.".into(), -// // )) -// .child( -// v_stack() -// .flex_1() -// .h_full() -// .child(div().flex().flex_1().child(root_group)) -// .children( -// Some( -// Panel::new("terminal-panel", cx) -// .child(Terminal::new()) -// .allowed_sides(PanelAllowedSides::BottomOnly) -// .side(PanelSide::Bottom), -// ) -// .filter(|_| self.is_terminal_open()), -// ), -// ) -// .children( -// Some( -// Panel::new("chat-panel-outer", cx) -// .side(PanelSide::Right) -// .child(ChatPanel::new("chat-panel-inner").messages(vec![ -// ChatMessage::new( -// "osiewicz".to_string(), -// "is this thing on?".to_string(), -// DateTime::parse_from_rfc3339("2023-09-27T15:40:52.707Z") -// .unwrap() -// .naive_local(), -// ), -// ChatMessage::new( -// "maxdeviant".to_string(), -// "Reading you loud and clear!".to_string(), -// DateTime::parse_from_rfc3339("2023-09-28T15:40:52.707Z") -// .unwrap() -// .naive_local(), -// ), -// ])), -// ) -// .filter(|_| self.is_chat_panel_open()), -// ) -// .children( -// Some( -// Panel::new("notifications-panel-outer", cx) -// .side(PanelSide::Right) -// .child(NotificationsPanel::new("notifications-panel-inner")), -// ) -// .filter(|_| self.is_notifications_panel_open()), -// ) -// .children( -// Some( -// Panel::new("assistant-panel-outer", cx) -// .child(AssistantPanel::new("assistant-panel-inner")), -// ) -// .filter(|_| self.is_assistant_panel_open()), -// ), -// ) -// .child(StatusBar::new()) -// .when(self.debug.show_toast, |this| { -// this.child(Toast::new(ToastOrigin::Bottom).child(Label::new("A toast"))) -// }) -// .children( -// Some( -// div() -// .absolute() -// .top(px(50.)) -// .left(px(640.)) -// .z_index(8) -// .child(LanguageSelector::new("language-selector")), -// ) -// .filter(|_| self.is_language_selector_open()), -// ) -// .z_index(8) -// // Debug -// .child( -// v_stack() -// .z_index(9) -// .absolute() -// .top_20() -// .left_1_4() -// .w_40() -// .gap_2() -// .when(self.show_debug, |this| { -// this.child(Button::::new("Toggle User Settings").on_click( -// Arc::new(|workspace, cx| workspace.debug_toggle_user_settings(cx)), -// )) -// .child( -// Button::::new("Toggle Toasts").on_click(Arc::new( -// |workspace, cx| workspace.debug_toggle_toast(cx), -// )), -// ) -// .child( -// Button::::new("Toggle Livestream").on_click(Arc::new( -// |workspace, cx| workspace.debug_toggle_livestream(cx), -// )), -// ) -// }) -// .child( -// Button::::new("Toggle Debug") -// .on_click(Arc::new(|workspace, cx| workspace.toggle_debug(cx))), -// ), -// ) -// } -// } - -// #[cfg(feature = "stories")] -// pub use stories::*; - -// #[cfg(feature = "stories")] -// mod stories { -// use super::*; -// use gpui::VisualContext; - -// pub struct WorkspaceStory { -// workspace: View, -// } - -// impl WorkspaceStory { -// pub fn view(cx: &mut WindowContext) -> View { -// cx.build_view(|cx| Self { -// workspace: Workspace::view(cx), -// }) -// } -// } - -// impl Render for WorkspaceStory { -// type Element = Div; - -// fn render(&mut self, cx: &mut ViewContext) -> Self::Element { -// div().child(self.workspace.clone()) -// } -// } -// }