Move title_bar, util into workspace.
This commit is contained in:
parent
f84e8b82ef
commit
f2703122b8
36 changed files with 50 additions and 81 deletions
38
Cargo.lock
generated
38
Cargo.lock
generated
|
|
@ -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]]
|
||||
|
|
|
|||
11
Cargo.toml
11
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"
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -1 +0,0 @@
|
|||
../../LICENSE-APACHE
|
||||
|
|
@ -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<std::result::Result<WindowHandle<StoryWorkspace>, 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");
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
[package]
|
||||
name = "ui-story"
|
||||
name = "story"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
|
|
@ -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::{
|
||||
|
|
@ -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;
|
||||
|
||||
|
|
@ -1 +0,0 @@
|
|||
../../LICENSE-APACHE
|
||||
|
|
@ -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,
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -32,8 +32,6 @@ impl Scrollbar {
|
|||
) -> Option<Self> {
|
||||
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
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -1,10 +0,0 @@
|
|||
[package]
|
||||
name = "util"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
log.workspace = true
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
|
@ -1 +0,0 @@
|
|||
../../LICENSE-APACHE
|
||||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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::*;
|
||||
|
|
|
|||
|
|
@ -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},
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
mod linux_window_controls;
|
||||
mod platform;
|
||||
mod title_bar;
|
||||
mod windows_window_controls;
|
||||
|
||||
|
|
@ -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 {
|
||||
|
|
@ -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)]
|
||||
|
|
@ -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 {
|
||||
|
|
@ -17,6 +17,7 @@ macro_rules! debug_panic {
|
|||
};
|
||||
}
|
||||
|
||||
#[allow(unused)]
|
||||
pub trait ResultExt<E> {
|
||||
type Ok;
|
||||
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
#[allow(unused)]
|
||||
mod log;
|
||||
|
||||
pub use log::*;
|
||||
Loading…
Reference in a new issue