diff --git a/Cargo.lock b/Cargo.lock index f8e01f38..6a3fe630 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2132,7 +2132,7 @@ dependencies = [ "thiserror", "time", "usvg", - "util 0.1.0 (git+https://github.com/zed-industries/zed.git)", + "util", "uuid", "waker-fn", "wayland-backend", @@ -2867,9 +2867,8 @@ dependencies = [ "gpui", "log", "rust-embed", + "story", "ui", - "ui-story", - "util 0.1.0", "workspace", ] @@ -4583,6 +4582,18 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" +[[package]] +name = "story" +version = "0.1.0" +dependencies = [ + "anyhow", + "fake", + "gpui", + "serde", + "ui", + "workspace", +] + [[package]] name = "strict-num" version = "0.1.1" @@ -5164,18 +5175,6 @@ dependencies = [ "wry", ] -[[package]] -name = "ui-story" -version = "0.1.0" -dependencies = [ - "anyhow", - "fake", - "gpui", - "serde", - "ui", - "workspace", -] - [[package]] name = "unicase" version = "2.7.0" @@ -5297,13 +5296,6 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" -[[package]] -name = "util" -version = "0.1.0" -dependencies = [ - "log", -] - [[package]] name = "util" version = "0.1.0" @@ -6034,7 +6026,7 @@ dependencies = [ "serde", "smallvec", "ui", - "util 0.1.0", + "windows", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 8dee4f51..ed932e82 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,11 +1,5 @@ [workspace] -members = [ - "crates/app", - "crates/ui", - "crates/ui-story", - "crates/workspace", - "crates/util", -] +members = ["crates/app", "crates/ui", "crates/story", "crates/workspace"] default-members = ["crates/app"] resolver = "2" @@ -13,9 +7,8 @@ resolver = "2" [workspace.dependencies] gpui = { git = "https://github.com/zed-industries/zed.git" } ui = { path = "crates/ui" } -ui-story = { path = "crates/ui-story" } +story = { path = "crates/story" } workspace = { path = "crates/workspace" } -util = { path = "crates/util" } anyhow = "1" log = "0.4" serde = "1.0.203" diff --git a/README.md b/README.md index f78ae4cc..1d6e9181 100644 --- a/README.md +++ b/README.md @@ -64,11 +64,8 @@ cargo run There have a part of UI components from [Zed](https://github.com/zed-industries/zed/tree/main/crates/ui), that are under GPL v3.0 license. -- workspace (crate) -- title_bar -- picker +- workspace - scrollbar - -> I think we can discuss them with Zed team to change the license to MIT or Apache License for share to community. +- picker Other code are under Apache License. diff --git a/crates/app/Cargo.toml b/crates/app/Cargo.toml index 919909b1..3dfec390 100644 --- a/crates/app/Cargo.toml +++ b/crates/app/Cargo.toml @@ -10,8 +10,8 @@ rust-embed = "8" log.workspace = true workspace.workspace = true ui.workspace = true -ui-story.workspace = true -util.workspace = true +story.workspace = true + [lints] workspace = true diff --git a/crates/app/LICENSE-APACHE b/crates/app/LICENSE-APACHE deleted file mode 100644 index 1cd601d0..00000000 --- a/crates/app/LICENSE-APACHE +++ /dev/null @@ -1 +0,0 @@ -../../LICENSE-APACHE \ No newline at end of file diff --git a/crates/app/src/story_workspace.rs b/crates/app/src/story_workspace.rs index f2ddd643..82417371 100644 --- a/crates/app/src/story_workspace.rs +++ b/crates/app/src/story_workspace.rs @@ -1,19 +1,17 @@ use gpui::*; use prelude::FluentBuilder as _; -use ui_story::{ +use story::{ ButtonStory, CheckboxStory, DropdownStory, InputStory, ListStory, PickerStory, PopoverStory, StoryContainer, SwitchStory, TooltipStory, }; -use workspace::Workspace; +use workspace::{TitleBar, Workspace}; use std::sync::Arc; use ui::{ button::ButtonSize, switch::{LabelSide, Switch}, theme::{ActiveTheme, Theme}, - title_bar::TitleBar, }; -use util::ResultExt as _; use crate::app_state::AppState; @@ -162,7 +160,7 @@ impl StoryWorkspace { }) .detach(); }) - .log_err(); + .expect("failed to update window"); Ok(window) }) @@ -177,10 +175,10 @@ pub fn open_new( let task: Task, anyhow::Error>> = StoryWorkspace::new_local(app_state, cx); cx.spawn(|mut cx| async move { - if let Some(workspace) = task.await.log_err() { + if let Some(workspace) = task.await.ok() { workspace .update(&mut cx, |workspace, cx| init(workspace, cx)) - .log_err(); + .expect("failed to init workspace"); } }) } diff --git a/crates/ui-story/Cargo.toml b/crates/story/Cargo.toml similarity index 92% rename from crates/ui-story/Cargo.toml rename to crates/story/Cargo.toml index dadc53ff..dd885911 100644 --- a/crates/ui-story/Cargo.toml +++ b/crates/story/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "ui-story" +name = "story" version = "0.1.0" edition = "2021" diff --git a/crates/ui-story/src/button_story.rs b/crates/story/src/button_story.rs similarity index 98% rename from crates/ui-story/src/button_story.rs rename to crates/story/src/button_story.rs index db0b877c..31535e37 100644 --- a/crates/ui-story/src/button_story.rs +++ b/crates/story/src/button_story.rs @@ -1,6 +1,6 @@ use gpui::{ - div, ClickEvent, Div, IntoElement, ParentElement as _, Render, SharedString, Styled as _, View, - ViewContext, VisualContext as _, WindowContext, + ClickEvent, IntoElement, ParentElement as _, Render, Styled as _, View, ViewContext, + VisualContext as _, WindowContext, }; use ui::{ diff --git a/crates/ui-story/src/checkbox_story.rs b/crates/story/src/checkbox_story.rs similarity index 100% rename from crates/ui-story/src/checkbox_story.rs rename to crates/story/src/checkbox_story.rs diff --git a/crates/ui-story/src/dropdown_story.rs b/crates/story/src/dropdown_story.rs similarity index 100% rename from crates/ui-story/src/dropdown_story.rs rename to crates/story/src/dropdown_story.rs diff --git a/crates/ui-story/src/input_story.rs b/crates/story/src/input_story.rs similarity index 98% rename from crates/ui-story/src/input_story.rs rename to crates/story/src/input_story.rs index 070dab65..bac1bf17 100644 --- a/crates/ui-story/src/input_story.rs +++ b/crates/story/src/input_story.rs @@ -3,7 +3,7 @@ use gpui::{ VisualContext, WindowContext, }; -use ui::{input::TextInput, v_flex, Icon, IconName}; +use ui::{input::TextInput, v_flex, IconName}; use crate::section; diff --git a/crates/ui-story/src/lib.rs b/crates/story/src/lib.rs similarity index 100% rename from crates/ui-story/src/lib.rs rename to crates/story/src/lib.rs diff --git a/crates/ui-story/src/list_story.rs b/crates/story/src/list_story.rs similarity index 100% rename from crates/ui-story/src/list_story.rs rename to crates/story/src/list_story.rs diff --git a/crates/ui-story/src/picker_story.rs b/crates/story/src/picker_story.rs similarity index 100% rename from crates/ui-story/src/picker_story.rs rename to crates/story/src/picker_story.rs diff --git a/crates/ui-story/src/popover_story.rs b/crates/story/src/popover_story.rs similarity index 100% rename from crates/ui-story/src/popover_story.rs rename to crates/story/src/popover_story.rs diff --git a/crates/ui-story/src/switch_story.rs b/crates/story/src/switch_story.rs similarity index 100% rename from crates/ui-story/src/switch_story.rs rename to crates/story/src/switch_story.rs diff --git a/crates/ui-story/src/tooltip_story.rs b/crates/story/src/tooltip_story.rs similarity index 100% rename from crates/ui-story/src/tooltip_story.rs rename to crates/story/src/tooltip_story.rs diff --git a/crates/ui-story/LICENSE-APACHE b/crates/ui-story/LICENSE-APACHE deleted file mode 100644 index 1cd601d0..00000000 --- a/crates/ui-story/LICENSE-APACHE +++ /dev/null @@ -1 +0,0 @@ -../../LICENSE-APACHE \ No newline at end of file diff --git a/crates/ui/src/icon.rs b/crates/ui/src/icon.rs index 84daf198..9e05e871 100644 --- a/crates/ui/src/icon.rs +++ b/crates/ui/src/icon.rs @@ -1,8 +1,6 @@ -use std::ops::Deref; - use crate::{button::ButtonSize, theme::ActiveTheme}; use gpui::{ - prelude::FluentBuilder as _, svg, AnyElement, AnyView, Hsla, IntoElement, Render, RenderOnce, + prelude::FluentBuilder as _, svg, AnyElement, Hsla, IntoElement, Render, RenderOnce, SharedString, StyleRefinement, Styled, Svg, View, VisualContext, WindowContext, }; diff --git a/crates/ui/src/lib.rs b/crates/ui/src/lib.rs index d5e4830c..8f1403fb 100644 --- a/crates/ui/src/lib.rs +++ b/crates/ui/src/lib.rs @@ -2,8 +2,6 @@ mod clickable; mod disableable; mod event; mod icon; -mod platform; -mod prelude; mod scrollbar; mod selectable; mod stock; @@ -13,8 +11,8 @@ pub mod button; pub mod checkbox; pub mod empty; pub mod label; +pub mod prelude; pub mod theme; -pub mod title_bar; pub use styled_ext::StyledExt; pub mod divider; pub mod dropdown; diff --git a/crates/ui/src/scrollbar.rs b/crates/ui/src/scrollbar.rs index 1ea0f191..e5c60c44 100644 --- a/crates/ui/src/scrollbar.rs +++ b/crates/ui/src/scrollbar.rs @@ -32,8 +32,6 @@ impl Scrollbar { ) -> Option { let cloned_handle = handle.clone(); - // Ref from: Zed crates\project_panel\src\project_panel.rs - // render_scrollbar method let scroll_state = handle.0.borrow(); let last_item_height = scroll_state .last_item_height diff --git a/crates/ui/src/tab/tab.rs b/crates/ui/src/tab/tab.rs index 7802f898..0d70c202 100644 --- a/crates/ui/src/tab/tab.rs +++ b/crates/ui/src/tab/tab.rs @@ -1,11 +1,11 @@ use crate::selectable::Selectable; use crate::theme::{ActiveTheme, Colorize}; use gpui::prelude::FluentBuilder as _; +use gpui::InteractiveElement; use gpui::{ div, px, AnyElement, Div, ElementId, IntoElement, ParentElement as _, RenderOnce, Stateful, - StatefulInteractiveElement, WindowContext, + StatefulInteractiveElement, Styled, WindowContext, }; -use gpui::{InteractiveElement, Styled as _}; #[derive(IntoElement)] pub struct Tab { @@ -70,6 +70,8 @@ impl RenderOnce for Tab { .items_center() .gap_2() .h_full() + .flex_shrink_0() + .overflow_scroll() .cursor_pointer() .py_1() .px_3() diff --git a/crates/util/Cargo.toml b/crates/util/Cargo.toml deleted file mode 100644 index 1c7b49a5..00000000 --- a/crates/util/Cargo.toml +++ /dev/null @@ -1,10 +0,0 @@ -[package] -name = "util" -version = "0.1.0" -edition = "2021" - -[dependencies] -log.workspace = true - -[lints] -workspace = true diff --git a/crates/util/LICENSE-APACHE b/crates/util/LICENSE-APACHE deleted file mode 100644 index 1cd601d0..00000000 --- a/crates/util/LICENSE-APACHE +++ /dev/null @@ -1 +0,0 @@ -../../LICENSE-APACHE \ No newline at end of file diff --git a/crates/workspace/Cargo.toml b/crates/workspace/Cargo.toml index 5a35c65a..4f9c80f9 100644 --- a/crates/workspace/Cargo.toml +++ b/crates/workspace/Cargo.toml @@ -7,7 +7,7 @@ edition = "2021" gpui.workspace = true ui.workspace = true anyhow.workspace = true -util.workspace = true +windows = "0.57.0" schemars = "0.7.0" parking_lot = "0.12.1" serde = "1.0.203" diff --git a/crates/workspace/src/lib.rs b/crates/workspace/src/lib.rs index be44c051..78926f98 100644 --- a/crates/workspace/src/lib.rs +++ b/crates/workspace/src/lib.rs @@ -4,6 +4,9 @@ pub mod model_layer; pub mod notification; pub mod pane; pub mod pane_group; +mod title_bar; +mod util; mod workspace; +pub use title_bar::TitleBar; pub use workspace::*; diff --git a/crates/workspace/src/pane.rs b/crates/workspace/src/pane.rs index 329ad1ff..9b94ee00 100644 --- a/crates/workspace/src/pane.rs +++ b/crates/workspace/src/pane.rs @@ -19,6 +19,7 @@ use gpui::{ }; use serde::Deserialize; +use crate::util::ResultExt; use ui::{ label::Label, tab::{Tab, TabBar}, @@ -26,7 +27,6 @@ use ui::{ tooltip::Tooltip, v_flex, Icon, IconName, Selectable, StyledExt as _, }; -use util::ResultExt; use super::{ item::{ItemHandle, TabContentParams}, diff --git a/crates/workspace/src/pane_group.rs b/crates/workspace/src/pane_group.rs index 6233325b..e232b737 100644 --- a/crates/workspace/src/pane_group.rs +++ b/crates/workspace/src/pane_group.rs @@ -455,6 +455,7 @@ mod element { use std::mem; use std::{cell::RefCell, iter, rc::Rc, sync::Arc}; + use crate::util::ResultExt; use gpui::{ px, relative, Along, AnyElement, Axis, Bounds, Element, ElementId, GlobalElementId, IntoElement, MouseDownEvent, MouseMoveEvent, MouseUpEvent, ParentElement, Pixels, Point, @@ -464,7 +465,6 @@ mod element { use parking_lot::Mutex; use smallvec::SmallVec; use ui::theme::ActiveTheme; - use util::ResultExt; use crate::Workspace; diff --git a/crates/ui/src/title_bar.rs b/crates/workspace/src/title_bar.rs similarity index 87% rename from crates/ui/src/title_bar.rs rename to crates/workspace/src/title_bar.rs index 28aac32c..0bef5a8f 100644 --- a/crates/ui/src/title_bar.rs +++ b/crates/workspace/src/title_bar.rs @@ -1,4 +1,5 @@ mod linux_window_controls; +mod platform; mod title_bar; mod windows_window_controls; diff --git a/crates/ui/src/title_bar/README.md b/crates/workspace/src/title_bar/README.md similarity index 100% rename from crates/ui/src/title_bar/README.md rename to crates/workspace/src/title_bar/README.md diff --git a/crates/ui/src/title_bar/linux_window_controls.rs b/crates/workspace/src/title_bar/linux_window_controls.rs similarity index 98% rename from crates/ui/src/title_bar/linux_window_controls.rs rename to crates/workspace/src/title_bar/linux_window_controls.rs index 425e8f68..8d1d0cb0 100644 --- a/crates/ui/src/title_bar/linux_window_controls.rs +++ b/crates/workspace/src/title_bar/linux_window_controls.rs @@ -1,6 +1,5 @@ use gpui::{prelude::*, Action, Rgba, WindowAppearance}; - -use crate::{prelude::*, stock::h_flex, Icon, IconName}; +use ui::{h_flex, prelude::*, Icon, IconName}; #[derive(IntoElement)] pub struct LinuxWindowControls { diff --git a/crates/ui/src/platform.rs b/crates/workspace/src/title_bar/platform.rs similarity index 100% rename from crates/ui/src/platform.rs rename to crates/workspace/src/title_bar/platform.rs diff --git a/crates/ui/src/title_bar/title_bar.rs b/crates/workspace/src/title_bar/title_bar.rs similarity index 96% rename from crates/ui/src/title_bar/title_bar.rs rename to crates/workspace/src/title_bar/title_bar.rs index 7974f13f..91369d61 100644 --- a/crates/ui/src/title_bar/title_bar.rs +++ b/crates/workspace/src/title_bar/title_bar.rs @@ -1,10 +1,11 @@ use gpui::{Action, AnyElement, Interactivity, Stateful}; use smallvec::SmallVec; -use crate::{platform::PlatformStyle, prelude::*, stock::h_flex, theme::ActiveTheme}; +use ui::{h_flex, prelude::*, theme::ActiveTheme}; use super::{ - linux_window_controls::LinuxWindowControls, windows_window_controls::WindowsWindowControls, + linux_window_controls::LinuxWindowControls, platform::PlatformStyle, + windows_window_controls::WindowsWindowControls, }; #[derive(IntoElement)] diff --git a/crates/ui/src/title_bar/windows_window_controls.rs b/crates/workspace/src/title_bar/windows_window_controls.rs similarity index 98% rename from crates/ui/src/title_bar/windows_window_controls.rs rename to crates/workspace/src/title_bar/windows_window_controls.rs index 8b8858cf..8006402c 100644 --- a/crates/ui/src/title_bar/windows_window_controls.rs +++ b/crates/workspace/src/title_bar/windows_window_controls.rs @@ -1,6 +1,6 @@ use gpui::{hsla, prelude::*, Hsla}; -use crate::{prelude::*, stock::h_flex, theme::ActiveTheme}; +use ui::{h_flex, prelude::*, theme::ActiveTheme}; #[derive(IntoElement)] pub struct WindowsWindowControls { diff --git a/crates/util/src/log.rs b/crates/workspace/src/util/log.rs similarity index 99% rename from crates/util/src/log.rs rename to crates/workspace/src/util/log.rs index 454b6eb4..de85735d 100644 --- a/crates/util/src/log.rs +++ b/crates/workspace/src/util/log.rs @@ -17,6 +17,7 @@ macro_rules! debug_panic { }; } +#[allow(unused)] pub trait ResultExt { type Ok; diff --git a/crates/util/src/lib.rs b/crates/workspace/src/util/mod.rs similarity index 60% rename from crates/util/src/lib.rs rename to crates/workspace/src/util/mod.rs index b19c0087..866a0072 100644 --- a/crates/util/src/lib.rs +++ b/crates/workspace/src/util/mod.rs @@ -1,3 +1,4 @@ +#[allow(unused)] mod log; pub use log::*;