diff --git a/Cargo.lock b/Cargo.lock index 6da7c4c..02074c8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1034,6 +1034,7 @@ dependencies = [ "anyhow", "chat", "common", + "dock", "emojis", "gpui", "gpui_tokio", @@ -1295,6 +1296,7 @@ dependencies = [ "chat_ui", "common", "device", + "dock", "futures", "gpui", "gpui_tokio", @@ -1740,6 +1742,19 @@ dependencies = [ "rand 0.8.5", ] +[[package]] +name = "dock" +version = "0.3.0" +dependencies = [ + "anyhow", + "common", + "gpui", + "log", + "smallvec", + "theme", + "ui", +] + [[package]] name = "downcast-rs" version = "1.2.1" @@ -6584,10 +6599,7 @@ dependencies = [ "common", "gpui", "linicon", - "log", - "nostr-sdk", "smallvec", - "smol", "theme", "ui", "windows 0.61.3", diff --git a/crates/chat_ui/Cargo.toml b/crates/chat_ui/Cargo.toml index bff3e8d..9f99fc0 100644 --- a/crates/chat_ui/Cargo.toml +++ b/crates/chat_ui/Cargo.toml @@ -7,6 +7,7 @@ publish.workspace = true [dependencies] state = { path = "../state" } ui = { path = "../ui" } +dock = { path = "../dock" } theme = { path = "../theme" } common = { path = "../common" } person = { path = "../person" } diff --git a/crates/chat_ui/src/lib.rs b/crates/chat_ui/src/lib.rs index 9bbd428..791beee 100644 --- a/crates/chat_ui/src/lib.rs +++ b/crates/chat_ui/src/lib.rs @@ -4,6 +4,7 @@ use std::time::Duration; pub use actions::*; use chat::{Message, RenderedMessage, Room, RoomEvent, RoomKind, SendReport}; use common::{nip96_upload, RenderedTimestamp}; +use dock::panel::{Panel, PanelEvent}; use gpui::prelude::FluentBuilder; use gpui::{ div, img, list, px, red, relative, rems, svg, white, AnyElement, App, AppContext, @@ -25,7 +26,6 @@ use theme::ActiveTheme; use ui::avatar::Avatar; use ui::button::{Button, ButtonVariants}; use ui::context_menu::ContextMenuExt; -use ui::dock_area::panel::{Panel, PanelEvent}; use ui::input::{InputEvent, InputState, TextInput}; use ui::notification::Notification; use ui::popup_menu::PopupMenuExt; diff --git a/crates/coop/Cargo.toml b/crates/coop/Cargo.toml index a5e5ca4..2147bc7 100644 --- a/crates/coop/Cargo.toml +++ b/crates/coop/Cargo.toml @@ -29,6 +29,7 @@ icons = [ [dependencies] assets = { path = "../assets" } ui = { path = "../ui" } +dock = { path = "../dock" } title_bar = { path = "../title_bar" } theme = { path = "../theme" } common = { path = "../common" } diff --git a/crates/coop/src/login/mod.rs b/crates/coop/src/login/mod.rs index a62e42e..39154bb 100644 --- a/crates/coop/src/login/mod.rs +++ b/crates/coop/src/login/mod.rs @@ -2,6 +2,7 @@ use std::time::Duration; use anyhow::anyhow; use common::BUNKER_TIMEOUT; +use dock::panel::{Panel, PanelEvent}; use gpui::prelude::FluentBuilder; use gpui::{ div, relative, AnyElement, App, AppContext, Context, Entity, EventEmitter, FocusHandle, @@ -13,7 +14,6 @@ use smallvec::{smallvec, SmallVec}; use state::NostrRegistry; use theme::ActiveTheme; use ui::button::{Button, ButtonVariants}; -use ui::dock_area::panel::{Panel, PanelEvent}; use ui::input::{InputEvent, InputState, TextInput}; use ui::notification::Notification; use ui::{v_flex, Disableable, StyledExt, WindowExtension}; diff --git a/crates/coop/src/new_identity/mod.rs b/crates/coop/src/new_identity/mod.rs index 89d7611..4c69475 100644 --- a/crates/coop/src/new_identity/mod.rs +++ b/crates/coop/src/new_identity/mod.rs @@ -1,5 +1,6 @@ use anyhow::{anyhow, Error}; use common::{default_nip17_relays, default_nip65_relays, nip96_upload, BOOTSTRAP_RELAYS}; +use dock::panel::{Panel, PanelEvent}; use gpui::{ rems, AnyElement, App, AppContext, Context, Entity, EventEmitter, FocusHandle, Focusable, IntoElement, ParentElement, PathPromptOptions, Render, SharedString, Styled, Task, Window, @@ -12,7 +13,6 @@ use smol::fs; use state::NostrRegistry; use ui::avatar::Avatar; use ui::button::{Button, ButtonVariants}; -use ui::dock_area::panel::{Panel, PanelEvent}; use ui::input::{InputState, TextInput}; use ui::modal::ModalButtonProps; use ui::{divider, v_flex, Disableable, IconName, Sizable, WindowExtension}; diff --git a/crates/coop/src/sidebar/mod.rs b/crates/coop/src/sidebar/mod.rs index a64842c..2cf5ef8 100644 --- a/crates/coop/src/sidebar/mod.rs +++ b/crates/coop/src/sidebar/mod.rs @@ -4,6 +4,7 @@ use std::time::Duration; use anyhow::{anyhow, Error}; use chat::{ChatEvent, ChatRegistry, Room, RoomKind}; use common::{DebouncedDelay, RenderedTimestamp, TextUtils, BOOTSTRAP_RELAYS, SEARCH_RELAYS}; +use dock::panel::{Panel, PanelEvent}; use gpui::prelude::FluentBuilder; use gpui::{ deferred, div, relative, uniform_list, App, AppContext, Context, Entity, EventEmitter, @@ -17,7 +18,6 @@ use smallvec::{smallvec, SmallVec}; use state::{NostrRegistry, GIFTWRAP_SUBSCRIPTION}; use theme::ActiveTheme; use ui::button::{Button, ButtonVariants}; -use ui::dock_area::panel::{Panel, PanelEvent}; use ui::input::{InputEvent, InputState, TextInput}; use ui::popup_menu::PopupMenuExt; use ui::{h_flex, v_flex, Icon, IconName, Selectable, Sizable, StyledExt, WindowExtension}; diff --git a/crates/coop/src/views/startup.rs b/crates/coop/src/views/startup.rs index 80b14de..b89d9ba 100644 --- a/crates/coop/src/views/startup.rs +++ b/crates/coop/src/views/startup.rs @@ -1,6 +1,7 @@ use std::time::Duration; use common::BUNKER_TIMEOUT; +use dock::panel::{Panel, PanelEvent}; use gpui::prelude::FluentBuilder; use gpui::{ div, relative, rems, svg, AnyElement, App, AppContext, Context, Entity, EventEmitter, @@ -16,7 +17,6 @@ use state::NostrRegistry; use theme::ActiveTheme; use ui::avatar::Avatar; use ui::button::{Button, ButtonVariants}; -use ui::dock_area::panel::{Panel, PanelEvent}; use ui::indicator::Indicator; use ui::{h_flex, v_flex, Sizable, StyledExt, WindowExtension}; diff --git a/crates/coop/src/views/welcome.rs b/crates/coop/src/views/welcome.rs index f21f27d..f2acc1f 100644 --- a/crates/coop/src/views/welcome.rs +++ b/crates/coop/src/views/welcome.rs @@ -1,10 +1,10 @@ +use dock::panel::{Panel, PanelEvent}; use gpui::{ div, svg, AnyElement, App, AppContext, Context, Entity, EventEmitter, FocusHandle, Focusable, InteractiveElement, IntoElement, ParentElement, Render, SharedString, StatefulInteractiveElement, Styled, Window, }; use theme::ActiveTheme; -use ui::dock_area::panel::{Panel, PanelEvent}; use ui::{h_flex, v_flex, StyledExt}; pub fn init(window: &mut Window, cx: &mut App) -> Entity { diff --git a/crates/coop/src/workspace.rs b/crates/coop/src/workspace.rs index fea0fc7..b68d7a4 100644 --- a/crates/coop/src/workspace.rs +++ b/crates/coop/src/workspace.rs @@ -4,6 +4,8 @@ use auto_update::{AutoUpdateStatus, AutoUpdater}; use chat::{ChatEvent, ChatRegistry}; use chat_ui::{CopyPublicKey, OpenPublicKey}; use common::DEFAULT_SIDEBAR_WIDTH; +use dock::dock::DockPlacement; +use dock::{ClosePanel, DockArea, DockItem}; use gpui::prelude::FluentBuilder; use gpui::{ deferred, div, px, relative, rems, App, AppContext, Axis, ClipboardItem, Context, Entity, @@ -19,8 +21,6 @@ use theme::{ActiveTheme, Theme, ThemeMode, ThemeRegistry}; use title_bar::TitleBar; use ui::avatar::Avatar; use ui::button::{Button, ButtonVariants}; -use ui::dock_area::dock::DockPlacement; -use ui::dock_area::{ClosePanel, DockArea, DockItem}; use ui::modal::ModalButtonProps; use ui::popup_menu::PopupMenuExt; use ui::{h_flex, v_flex, IconName, Root, Sizable, WindowExtension}; @@ -46,15 +46,12 @@ pub struct Workspace { dock: Entity, /// Event subscriptions - _subscriptions: SmallVec<[Subscription; 4]>, + _subscriptions: SmallVec<[Subscription; 3]>, } impl Workspace { fn new(window: &mut Window, cx: &mut Context) -> Self { let chat = ChatRegistry::global(cx); - let nostr = NostrRegistry::global(cx); - let identity = nostr.read(cx).identity(); - let title_bar = cx.new(|_| TitleBar::new()); let dock = cx.new(|cx| DockArea::new(window, cx)); @@ -67,17 +64,6 @@ impl Workspace { }), ); - subscriptions.push( - // Observe the identity entity - cx.observe_in(&identity, window, move |this, state, window, cx| { - if state.read(cx).has_public_key() { - this.dock.update(cx, |this, cx| { - this.toggle_dock(DockPlacement::Left, window, cx); - }); - }; - }), - ); - subscriptions.push( // Observe all events emitted by the chat registry cx.subscribe_in(&chat, window, move |this, chat, ev, window, cx| { @@ -158,7 +144,7 @@ impl Workspace { // Update the dock layout self.dock.update(cx, |this, cx| { - this.set_left_dock(left, Some(px(DEFAULT_SIDEBAR_WIDTH)), false, window, cx); + this.set_left_dock(left, Some(px(DEFAULT_SIDEBAR_WIDTH)), true, window, cx); this.set_center(center, window, cx); }); } @@ -369,43 +355,50 @@ impl Workspace { fn titlebar_left(&mut self, _window: &mut Window, cx: &Context) -> impl IntoElement { let nostr = NostrRegistry::global(cx); - let chat = ChatRegistry::global(cx); - let status = chat.read(cx).loading(); - - if !nostr.read(cx).identity().read(cx).has_public_key() { - return div(); - } + let identity = nostr.read(cx).identity(); h_flex() .gap_2() .h_6() .w_full() - .child(compose_button()) - .when(status, |this| { - this.child(deferred( - h_flex() - .px_2() - .h_6() - .gap_1() - .text_xs() - .rounded_full() - .bg(cx.theme().surface_background) - .child(SharedString::from( - "Getting messages. This may take a while...", - )), - )) + .when_some(identity.read(cx).public_key, |this, public_key| { + let persons = PersonRegistry::global(cx); + let profile = persons.read(cx).get(&public_key, cx); + + this.child( + Button::new("user") + .small() + .reverse() + .transparent() + .icon(IconName::CaretDown) + .child(Avatar::new(profile.avatar()).size(rems(1.5))) + .popup_menu(move |this, _window, _cx| { + this.label(profile.name()) + .menu_with_icon("Profile", IconName::Emoji, Box::new(ViewProfile)) + .menu_with_icon( + "Messaging Relays", + IconName::Relay, + Box::new(ViewRelays), + ) + .separator() + .menu_with_icon("Dark Mode", IconName::Sun, Box::new(DarkMode)) + .menu_with_icon("Themes", IconName::Moon, Box::new(Themes)) + .menu_with_icon("Settings", IconName::Settings, Box::new(Settings)) + .menu_with_icon("Sign Out", IconName::Door, Box::new(Logout)) + }), + ) }) + .child(compose_button()) } fn titlebar_right(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { - let auto_update = AutoUpdater::global(cx); + let chat = ChatRegistry::global(cx); + let status = chat.read(cx).loading(); + let auto_update = AutoUpdater::global(cx); let relay_auth = RelayAuth::global(cx); let pending_requests = relay_auth.read(cx).pending_requests(cx); - let nostr = NostrRegistry::global(cx); - let identity = nostr.read(cx).identity(); - h_flex() .gap_2() .map(|this| match auto_update.read(cx).status.as_ref() { @@ -464,32 +457,19 @@ impl Workspace { }), ) }) - .when_some(identity.read(cx).public_key, |this, public_key| { - let persons = PersonRegistry::global(cx); - let profile = persons.read(cx).get(&public_key, cx); - - this.child( - Button::new("user") - .small() - .reverse() - .transparent() - .icon(IconName::CaretDown) - .child(Avatar::new(profile.avatar()).size(rems(1.45))) - .popup_menu(move |this, _window, _cx| { - this.label(profile.name()) - .menu_with_icon("Profile", IconName::Emoji, Box::new(ViewProfile)) - .menu_with_icon( - "Messaging Relays", - IconName::Relay, - Box::new(ViewRelays), - ) - .separator() - .menu_with_icon("Dark Mode", IconName::Sun, Box::new(DarkMode)) - .menu_with_icon("Themes", IconName::Moon, Box::new(Themes)) - .menu_with_icon("Settings", IconName::Settings, Box::new(Settings)) - .menu_with_icon("Sign Out", IconName::Door, Box::new(Logout)) - }), - ) + .when(status, |this| { + this.child(deferred( + h_flex() + .px_2() + .h_6() + .gap_1() + .text_xs() + .rounded_full() + .bg(cx.theme().surface_background) + .child(SharedString::from( + "Getting messages. This may take a while...", + )), + )) }) } } @@ -498,13 +478,6 @@ impl Render for Workspace { fn render(&mut self, window: &mut Window, cx: &mut Context) -> impl IntoElement { let modal_layer = Root::render_modal_layer(window, cx); let notification_layer = Root::render_notification_layer(window, cx); - let left = self.titlebar_left(window, cx).into_any_element(); - let right = self.titlebar_right(window, cx).into_any_element(); - - // Update title bar children - self.title_bar.update(cx, |this, _cx| { - this.set_children(vec![left, right]); - }); div() .id(SharedString::from("workspace")) @@ -519,14 +492,8 @@ impl Render for Workspace { .on_action(cx.listener(Self::on_keyring)) .relative() .size_full() - .child( - v_flex() - .size_full() - // Title Bar - .child(self.title_bar.clone()) - // Dock - .child(self.dock.clone()), - ) + // Dock + .child(self.dock.clone()) // Notifications .children(notification_layer) // Modals diff --git a/crates/dock/Cargo.toml b/crates/dock/Cargo.toml new file mode 100644 index 0000000..36830b8 --- /dev/null +++ b/crates/dock/Cargo.toml @@ -0,0 +1,15 @@ +[package] +name = "dock" +version.workspace = true +edition.workspace = true +publish.workspace = true + +[dependencies] +common = { path = "../common" } +theme = { path = "../theme" } +ui = { path = "../ui" } + +gpui.workspace = true +smallvec.workspace = true +anyhow.workspace = true +log.workspace = true diff --git a/crates/ui/src/dock_area/dock.rs b/crates/dock/src/dock.rs similarity index 96% rename from crates/ui/src/dock_area/dock.rs rename to crates/dock/src/dock.rs index 3c427a6..603510b 100644 --- a/crates/ui/src/dock_area/dock.rs +++ b/crates/dock/src/dock.rs @@ -6,27 +6,22 @@ use gpui::{ MouseMoveEvent, MouseUpEvent, ParentElement as _, Pixels, Point, Render, StatefulInteractiveElement, Style, Styled as _, WeakEntity, Window, }; -use serde::{Deserialize, Serialize}; use theme::ActiveTheme; +use ui::resizable::{HANDLE_PADDING, HANDLE_SIZE, PANEL_MIN_SIZE}; +use ui::{AxisExt as _, StyledExt}; use super::{DockArea, DockItem}; -use crate::dock_area::panel::PanelView; -use crate::dock_area::tab_panel::TabPanel; -use crate::resizable::{HANDLE_PADDING, HANDLE_SIZE, PANEL_MIN_SIZE}; -use crate::{AxisExt as _, StyledExt}; +use crate::panel::PanelView; +use crate::tab_panel::TabPanel; #[derive(Clone, Render)] struct ResizePanel; -#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq)] +#[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum DockPlacement { - #[serde(rename = "center")] Center, - #[serde(rename = "left")] Left, - #[serde(rename = "bottom")] Bottom, - #[serde(rename = "right")] Right, } @@ -58,14 +53,19 @@ impl DockPlacement { pub struct Dock { pub(super) placement: DockPlacement, dock_area: WeakEntity, + + /// Dock layout pub(crate) panel: DockItem, + /// The size is means the width or height of the Dock, if the placement is left or right, the size is width, otherwise the size is height. pub(super) size: Pixels, + + /// Whether the Dock is open pub(super) open: bool, + /// Whether the Dock is collapsible, default: true pub(super) collapsible: bool, - // Runtime state /// Whether the Dock is resizing is_resizing: bool, } diff --git a/crates/ui/src/dock_area/mod.rs b/crates/dock/src/lib.rs similarity index 98% rename from crates/ui/src/dock_area/mod.rs rename to crates/dock/src/lib.rs index a2fb704..13265cf 100644 --- a/crates/ui/src/dock_area/mod.rs +++ b/crates/dock/src/lib.rs @@ -7,25 +7,17 @@ use gpui::{ ParentElement as _, Pixels, Render, SharedString, Styled, Subscription, WeakEntity, Window, }; -use crate::dock_area::dock::{Dock, DockPlacement}; -use crate::dock_area::panel::{Panel, PanelEvent, PanelStyle, PanelView}; -use crate::dock_area::stack_panel::StackPanel; -use crate::dock_area::tab_panel::TabPanel; +use crate::dock::{Dock, DockPlacement}; +use crate::panel::{Panel, PanelEvent, PanelStyle, PanelView}; +use crate::stack_panel::StackPanel; +use crate::tab_panel::TabPanel; pub mod dock; pub mod panel; pub mod stack_panel; pub mod tab_panel; -actions!( - dock, - [ - /// Zoom the current panel - ToggleZoom, - /// Close the current panel - ClosePanel - ] -); +actions!(dock, [ToggleZoom, ClosePanel]); pub enum DockEvent { /// The layout of the dock has changed, subscribers this to save the layout. diff --git a/crates/ui/src/dock_area/panel.rs b/crates/dock/src/panel.rs similarity index 98% rename from crates/ui/src/dock_area/panel.rs rename to crates/dock/src/panel.rs index 8e64dc6..f1fe9d3 100644 --- a/crates/ui/src/dock_area/panel.rs +++ b/crates/dock/src/panel.rs @@ -2,9 +2,8 @@ use gpui::{ AnyElement, AnyView, App, Element, Entity, EventEmitter, FocusHandle, Focusable, Hsla, Render, SharedString, Window, }; - -use crate::button::Button; -use crate::popup_menu::PopupMenu; +use ui::button::Button; +use ui::popup_menu::PopupMenu; pub enum PanelEvent { ZoomIn, diff --git a/crates/ui/src/dock_area/stack_panel.rs b/crates/dock/src/stack_panel.rs similarity index 98% rename from crates/ui/src/dock_area/stack_panel.rs rename to crates/dock/src/stack_panel.rs index 92fe47a..6a7a18e 100644 --- a/crates/ui/src/dock_area/stack_panel.rs +++ b/crates/dock/src/stack_panel.rs @@ -7,15 +7,15 @@ use gpui::{ Window, }; use smallvec::SmallVec; - -use super::{DockArea, PanelEvent}; -use crate::dock_area::panel::{Panel, PanelView}; -use crate::dock_area::tab_panel::TabPanel; -use crate::resizable::{ +use ui::resizable::{ h_resizable, resizable_panel, v_resizable, ResizablePanel, ResizablePanelEvent, ResizablePanelGroup, }; -use crate::{h_flex, AxisExt as _, Placement}; +use ui::{h_flex, AxisExt as _, Placement}; + +use super::{DockArea, PanelEvent}; +use crate::panel::{Panel, PanelView}; +use crate::tab_panel::TabPanel; pub struct StackPanel { pub(super) parent: Option>, diff --git a/crates/ui/src/dock_area/tab_panel.rs b/crates/dock/src/tab_panel.rs similarity index 97% rename from crates/ui/src/dock_area/tab_panel.rs rename to crates/dock/src/tab_panel.rs index b91e635..0ef0efd 100644 --- a/crates/ui/src/dock_area/tab_panel.rs +++ b/crates/dock/src/tab_panel.rs @@ -8,16 +8,15 @@ use gpui::{ StatefulInteractiveElement, Styled, WeakEntity, Window, }; use theme::ActiveTheme; +use ui::button::{Button, ButtonVariants as _}; +use ui::popup_menu::{PopupMenu, PopupMenuExt}; +use ui::tab::tab_bar::TabBar; +use ui::tab::Tab; +use ui::{h_flex, v_flex, AxisExt, IconName, Placement, Selectable, Sizable, StyledExt}; -use super::panel::PanelView; -use super::stack_panel::StackPanel; -use super::{ClosePanel, DockArea, PanelEvent, PanelStyle, ToggleZoom}; -use crate::button::{Button, ButtonVariants as _}; -use crate::dock_area::panel::Panel; -use crate::popup_menu::{PopupMenu, PopupMenuExt}; -use crate::tab::tab_bar::TabBar; -use crate::tab::Tab; -use crate::{h_flex, v_flex, AxisExt, IconName, Placement, Selectable, Sizable, StyledExt}; +use crate::panel::{Panel, PanelView}; +use crate::stack_panel::StackPanel; +use crate::{ClosePanel, DockArea, PanelEvent, PanelStyle, ToggleZoom}; #[derive(Clone)] struct TabState { @@ -646,13 +645,9 @@ impl TabPanel { .group("") .overflow_hidden() .flex_1() - .p_1() .child( div() .size_full() - .rounded(cx.theme().radius_lg) - .when(cx.theme().shadow, |this| this.shadow_sm()) - .when(cx.theme().mode.is_dark(), |this| this.shadow_lg()) .bg(cx.theme().panel_background) .overflow_hidden() .child( @@ -667,7 +662,6 @@ impl TabPanel { div() .invisible() .absolute() - .p_1() .child( div() .rounded(cx.theme().radius_lg) diff --git a/crates/state/src/lib.rs b/crates/state/src/lib.rs index a83e5de..5ebaa28 100644 --- a/crates/state/src/lib.rs +++ b/crates/state/src/lib.rs @@ -653,6 +653,8 @@ impl NostrRegistry { // Update the signer self.set_signer(keys, false, cx); + // TODO: set metadata + // Spawn a task to write the credentials cx.background_spawn(async move { if let Err(e) = write_credential.await { diff --git a/crates/title_bar/Cargo.toml b/crates/title_bar/Cargo.toml index ee0cf1f..e6fb439 100644 --- a/crates/title_bar/Cargo.toml +++ b/crates/title_bar/Cargo.toml @@ -9,12 +9,9 @@ common = { path = "../common" } theme = { path = "../theme" } ui = { path = "../ui" } -nostr-sdk.workspace = true gpui.workspace = true -smol.workspace = true smallvec.workspace = true anyhow.workspace = true -log.workspace = true [target.'cfg(target_os = "windows")'.dependencies] windows = { version = "0.61", features = ["Wdk_System_SystemServices"] } diff --git a/crates/title_bar/src/lib.rs b/crates/title_bar/src/lib.rs index 0ff981a..4a718d8 100644 --- a/crates/title_bar/src/lib.rs +++ b/crates/title_bar/src/lib.rs @@ -43,7 +43,7 @@ impl TitleBar { #[cfg(not(target_os = "windows"))] pub fn height(window: &mut Window) -> Pixels { - (1.75 * window.rem_size()).max(px(34.)) + (1.75 * window.rem_size()).max(px(36.)) } #[cfg(target_os = "windows")] diff --git a/crates/title_bar/src/platforms/linux.rs b/crates/title_bar/src/platforms/linux.rs index d285d71..530ed5a 100644 --- a/crates/title_bar/src/platforms/linux.rs +++ b/crates/title_bar/src/platforms/linux.rs @@ -5,7 +5,7 @@ use std::sync::OnceLock; use gpui::prelude::FluentBuilder; use gpui::{ svg, App, InteractiveElement, IntoElement, MouseButton, ParentElement, RenderOnce, - SharedString, StatefulInteractiveElement, Styled, Window, + StatefulInteractiveElement, Styled, Window, }; use linicon::{lookup_icon, IconType}; use theme::ActiveTheme; @@ -70,15 +70,14 @@ impl RenderOnce for WindowControl { .justify_center() .items_center() .rounded_full() + .size_6() .map(|this| { if is_gnome { - this.size_6() - .bg(cx.theme().tab_inactive_background) + this.bg(cx.theme().tab_inactive_background) .hover(|this| this.bg(cx.theme().tab_hover_background)) .active(|this| this.bg(cx.theme().tab_active_background)) } else { - this.size_5() - .bg(cx.theme().ghost_element_background) + this.bg(cx.theme().ghost_element_background) .hover(|this| this.bg(cx.theme().ghost_element_hover)) .active(|this| this.bg(cx.theme().ghost_element_active)) } @@ -87,9 +86,7 @@ impl RenderOnce for WindowControl { if let Some(Some(path)) = linux_controls().get(&self.kind).cloned() { this.child( svg() - .external_path(SharedString::from( - path.into_os_string().into_string().unwrap(), - )) + .external_path(path.into_os_string().into_string().unwrap()) .map(|this| { if cx.theme().is_dark() { this.text_color(gpui::white()) diff --git a/crates/ui/src/lib.rs b/crates/ui/src/lib.rs index 5875b15..832639b 100644 --- a/crates/ui/src/lib.rs +++ b/crates/ui/src/lib.rs @@ -15,7 +15,6 @@ pub mod avatar; pub mod button; pub mod checkbox; pub mod divider; -pub mod dock_area; pub mod dropdown; pub mod history; pub mod indicator; diff --git a/crates/ui/src/resizable/mod.rs b/crates/ui/src/resizable/mod.rs index 1e52ddc..a9f9ff0 100644 --- a/crates/ui/src/resizable/mod.rs +++ b/crates/ui/src/resizable/mod.rs @@ -3,7 +3,7 @@ mod panel; mod resize_handle; pub use panel::*; -pub(crate) use resize_handle::*; +pub use resize_handle::*; pub fn h_resizable( window: &mut Window, diff --git a/crates/ui/src/resizable/panel.rs b/crates/ui/src/resizable/panel.rs index a150982..8885ce0 100644 --- a/crates/ui/src/resizable/panel.rs +++ b/crates/ui/src/resizable/panel.rs @@ -11,7 +11,7 @@ use gpui::{ use super::resize_handle; use crate::{h_flex, v_flex, AxisExt}; -pub(crate) const PANEL_MIN_SIZE: Pixels = px(100.); +pub const PANEL_MIN_SIZE: Pixels = px(100.); pub enum ResizablePanelEvent { Resized, @@ -53,7 +53,7 @@ impl ResizablePanelGroup { self } - pub(crate) fn set_axis(&mut self, axis: Axis, _window: &mut Window, cx: &mut Context) { + pub fn set_axis(&mut self, axis: Axis, _window: &mut Window, cx: &mut Context) { self.axis = axis; cx.notify(); } @@ -130,7 +130,7 @@ impl ResizablePanelGroup { } /// Replace a child panel with a new panel at the given index. - pub(crate) fn replace_child( + pub fn replace_child( &mut self, panel: ResizablePanel, ix: usize, @@ -158,7 +158,7 @@ impl ResizablePanelGroup { cx.notify() } - pub(crate) fn remove_all_children(&mut self, _window: &mut Window, cx: &mut Context) { + pub fn remove_all_children(&mut self, _window: &mut Window, cx: &mut Context) { self.sizes.clear(); self.panels.clear(); cx.notify() @@ -349,7 +349,7 @@ impl ResizablePanel { self } - pub(crate) fn content_visible(mut self, content_visible: F) -> Self + pub fn content_visible(mut self, content_visible: F) -> Self where F: Fn(&App) -> bool + 'static, { diff --git a/crates/ui/src/resizable/resize_handle.rs b/crates/ui/src/resizable/resize_handle.rs index 0a8e131..916ddd3 100644 --- a/crates/ui/src/resizable/resize_handle.rs +++ b/crates/ui/src/resizable/resize_handle.rs @@ -7,11 +7,11 @@ use theme::ActiveTheme; use crate::AxisExt as _; -pub(crate) const HANDLE_PADDING: Pixels = px(8.); -pub(crate) const HANDLE_SIZE: Pixels = px(2.); +pub const HANDLE_PADDING: Pixels = px(8.); +pub const HANDLE_SIZE: Pixels = px(2.); #[derive(IntoElement)] -pub(crate) struct ResizeHandle { +pub struct ResizeHandle { base: Stateful
, axis: Axis, } @@ -26,7 +26,7 @@ impl ResizeHandle { } /// Create a resize handle for a resizable panel. -pub(crate) fn resize_handle(id: impl Into, axis: Axis) -> ResizeHandle { +pub fn resize_handle(id: impl Into, axis: Axis) -> ResizeHandle { ResizeHandle::new(id, axis) }