diff --git a/crates/signed_app/src/lib.rs b/crates/signed_app/src/lib.rs index a14673a..3f7ca9f 100644 --- a/crates/signed_app/src/lib.rs +++ b/crates/signed_app/src/lib.rs @@ -14,7 +14,6 @@ mod workspace; pub use app::AppRoot; pub use app::helpers::{apply_appearance, apply_appearance_mode}; - use gpui::{App, AppContext as _, Entity, Window}; pub fn root(window: &mut Window, cx: &mut App) -> Entity { diff --git a/crates/ui/src/components/alert.rs b/crates/ui/src/components/alert.rs index c6e5ae7..b6ab0f8 100644 --- a/crates/ui/src/components/alert.rs +++ b/crates/ui/src/components/alert.rs @@ -1,11 +1,5 @@ use std::rc::Rc; -use crate::icons::{Icon, IconRole}; -use crate::theme::{ - ALERT_EDGE_WIDTH, ALERT_STACK_WIDTH, ActiveTheme as _, ENTER_SLIDE_DISTANCE, Size, TextRole, - Typeset as _, -}; -use crate::utils::ResultLogErr as _; use gpui::prelude::FluentBuilder as _; use gpui::{ Animation, AnimationExt as _, App, Context, ElementId, Entity, InteractiveElement as _, @@ -15,11 +9,15 @@ use gpui::{ }; use crate::components::button::{Button, ButtonVariant}; -use crate::components::common::DismissHandler; -use crate::components::common::Sizable as _; -use crate::components::common::StyledExt as _; -use crate::components::common::TOAST_LAYER; -use crate::components::common::v_flex; +use crate::components::common::{ + DismissHandler, Sizable as _, StyledExt as _, TOAST_LAYER, v_flex, +}; +use crate::icons::{Icon, IconRole}; +use crate::theme::{ + ALERT_EDGE_WIDTH, ALERT_STACK_WIDTH, ActiveTheme as _, ENTER_SLIDE_DISTANCE, Size, TextRole, + Typeset as _, +}; +use crate::utils::ResultLogErr as _; /// How alarming an [`Alert`] is; picks the accent color. #[derive(Clone, Copy, Debug, Default, PartialEq, Eq)] diff --git a/crates/ui/src/components/avatar.rs b/crates/ui/src/components/avatar.rs index ffe75ec..0a78bb4 100644 --- a/crates/ui/src/components/avatar.rs +++ b/crates/ui/src/components/avatar.rs @@ -1,15 +1,15 @@ use std::fmt::Display; -use crate::theme::{ - ActiveTheme as _, Oklch, PIXEL_AVATAR_DARK_FACTOR, PIXEL_AVATAR_DARK_FLOOR, - PIXEL_AVATAR_LIGHT_CAP, PIXEL_AVATAR_LIGHT_LIFT, PIXEL_AVATAR_TINT_ALPHA, Size, ThemeVariant, -}; use gpui::{ App, ElementId, InteractiveElement as _, IntoElement, ParentElement as _, RenderOnce, Role, SharedString, StatefulInteractiveElement as _, StyleRefinement, Styled as _, Window, div, }; use crate::components::common::{Sizable, StyledExt, h_flex}; +use crate::theme::{ + ActiveTheme as _, Oklch, PIXEL_AVATAR_DARK_FACTOR, PIXEL_AVATAR_DARK_FLOOR, + PIXEL_AVATAR_LIGHT_CAP, PIXEL_AVATAR_LIGHT_LIFT, PIXEL_AVATAR_TINT_ALPHA, Size, ThemeVariant, +}; /// Number of rows and columns in the pixel grid. const GRID_SIZE: usize = 8; diff --git a/crates/ui/src/components/badge.rs b/crates/ui/src/components/badge.rs index 4d9a798..13e56aa 100644 --- a/crates/ui/src/components/badge.rs +++ b/crates/ui/src/components/badge.rs @@ -1,7 +1,5 @@ use std::rc::Rc; -use crate::icons::Icon; -use crate::theme::{ActiveTheme as _, Size, Theme}; use gpui::prelude::FluentBuilder as _; use gpui::{ AnyView, App, ElementId, Hsla, InteractiveElement as _, IntoElement, ParentElement as _, @@ -10,6 +8,8 @@ use gpui::{ }; use crate::components::common::{StyledExt, h_flex}; +use crate::icons::Icon; +use crate::theme::{ActiveTheme as _, Size, Theme}; /// The tooltip view builder gpui's `.tooltip(...)` expects. type TooltipBuilder = Rc AnyView>; diff --git a/crates/ui/src/components/button.rs b/crates/ui/src/components/button.rs index a8f3b5a..8a26d12 100644 --- a/crates/ui/src/components/button.rs +++ b/crates/ui/src/components/button.rs @@ -1,18 +1,19 @@ //! The push button: the API template for every control that follows. -use crate::icons::Icon; -use crate::theme::{ActiveTheme as _, DISABLED_OPACITY, Size}; -use crate::utils::{focus_ring, record_anchor_bounds}; +use std::rc::Rc; + use gpui::prelude::FluentBuilder as _; use gpui::{ AnyElement, AnyView, App, ClickEvent, ElementId, InteractiveElement as _, IntoElement, ParentElement, RenderOnce, Role, SharedString, StatefulInteractiveElement as _, StyleRefinement, Styled as _, Window, canvas, relative, transparent_black, }; -use std::rc::Rc; use crate::components::common::{Sizable, StyledExt as _, h_flex}; use crate::components::spinner::Spinner; +use crate::icons::Icon; +use crate::theme::{ActiveTheme as _, DISABLED_OPACITY, Size}; +use crate::utils::{focus_ring, record_anchor_bounds}; /// The single activation handler, shared by pointer, Enter, and Space. type ClickHandler = Box; diff --git a/crates/ui/src/components/checkbox.rs b/crates/ui/src/components/checkbox.rs index a373216..c0461c1 100644 --- a/crates/ui/src/components/checkbox.rs +++ b/crates/ui/src/components/checkbox.rs @@ -2,9 +2,6 @@ use std::rc::Rc; -use crate::icons::{IconRole, icon}; -use crate::theme::{ActiveTheme as _, DISABLED_OPACITY, Size}; -use crate::utils::focus_ring; use gpui::prelude::FluentBuilder as _; use gpui::{ App, ElementId, InteractiveElement as _, IntoElement, ParentElement as _, RenderOnce, Role, @@ -12,6 +9,9 @@ use gpui::{ }; use crate::components::common::{Sizable, StyledExt as _, h_flex}; +use crate::icons::{IconRole, icon}; +use crate::theme::{ActiveTheme as _, DISABLED_OPACITY, Size}; +use crate::utils::focus_ring; /// The change reporter, fired with the next value by pointer, Enter, and Space. type ChangeHandler = Box; diff --git a/crates/ui/src/components/clipboard.rs b/crates/ui/src/components/clipboard.rs index 622a091..37337aa 100644 --- a/crates/ui/src/components/clipboard.rs +++ b/crates/ui/src/components/clipboard.rs @@ -3,9 +3,6 @@ use std::rc::Rc; use std::time::Duration; -use crate::icons::IconRole; -use crate::theme::Size; -use crate::utils::ResultLogErr as _; use gpui::prelude::FluentBuilder as _; use gpui::{ AnyView, App, ClipboardItem, ElementId, Entity, IntoElement, RenderOnce, SharedString, @@ -14,6 +11,9 @@ use gpui::{ use crate::components::button::{Button, ButtonVariant}; use crate::components::common::{Sizable, StyledExt as _}; +use crate::icons::IconRole; +use crate::theme::Size; +use crate::utils::ResultLogErr as _; /// How long the check mark shows before reverting to the copy icon. pub const COPIED_DURATION: Duration = Duration::from_secs(1); diff --git a/crates/ui/src/components/combobox.rs b/crates/ui/src/components/combobox.rs index 3ae67b7..a558aaa 100644 --- a/crates/ui/src/components/combobox.rs +++ b/crates/ui/src/components/combobox.rs @@ -8,10 +8,6 @@ use std::cell::RefCell; use std::rc::Rc; -use crate::icons::{IconRole, icon}; -use crate::theme::ActiveTheme as _; -use crate::theme::{COMBOBOX_MIN_WIDTH, COMBOBOX_WIDTH, POPUP_MAX_HEIGHT, Size}; -use crate::utils::ResultLogErr as _; use gpui::prelude::FluentBuilder; use gpui::{ App, Bounds, Context, ElementId, Entity, InteractiveElement as _, IntoElement, KeyBinding, @@ -23,6 +19,9 @@ use gpui::{ use crate::components::common::{OVERLAY_LAYER, Sizable, StyledExt as _, h_flex, v_flex}; use crate::components::input::{Input, InputState, InputStateEvent}; use crate::components::scroll_area::ScrollArea; +use crate::icons::{IconRole, icon}; +use crate::theme::{ActiveTheme as _, COMBOBOX_MIN_WIDTH, COMBOBOX_WIDTH, POPUP_MAX_HEIGHT, Size}; +use crate::utils::ResultLogErr as _; actions!( combobox, diff --git a/crates/ui/src/components/command_palette.rs b/crates/ui/src/components/command_palette.rs index aa192ce..be9a6a5 100644 --- a/crates/ui/src/components/command_palette.rs +++ b/crates/ui/src/components/command_palette.rs @@ -2,8 +2,6 @@ use std::rc::Rc; -use crate::icons::Icon; -use crate::theme::{ActiveTheme as _, POPUP_MAX_HEIGHT, Size}; use gpui::prelude::FluentBuilder; use gpui::{ AnyElement, App, Context, ElementId, Entity, InteractiveElement as _, IntoElement, KeyBinding, @@ -15,6 +13,8 @@ use gpui::{ use crate::components::common::{DIALOG_LAYER, StyledExt as _, h_flex, v_flex}; use crate::components::input::{Input, InputState, InputStateEvent}; use crate::components::scroll_area::{ScrollArea, ScrollAxes}; +use crate::icons::Icon; +use crate::theme::{ActiveTheme as _, POPUP_MAX_HEIGHT, Size}; actions!( command_palette, diff --git a/crates/ui/src/components/dialog.rs b/crates/ui/src/components/dialog.rs index 7cd7f67..3f597dc 100644 --- a/crates/ui/src/components/dialog.rs +++ b/crates/ui/src/components/dialog.rs @@ -1,8 +1,6 @@ -use gpui::prelude::FluentBuilder as _; use std::rc::Rc; -use crate::icons::IconRole; -use crate::theme::{ActiveTheme as _, DIALOG_MIN_WIDTH, TextRole, Typeset as _}; +use gpui::prelude::FluentBuilder as _; use gpui::{ Animation, AnimationExt as _, AnyElement, App, DefiniteLength, ElementId, InteractiveElement as _, IntoElement, KeyDownEvent, MouseButton, ParentElement as _, @@ -14,6 +12,8 @@ use crate::components::button::{Button, ButtonVariant}; use crate::components::common::{DIALOG_LAYER, Sizable, StyledExt as _, v_flex}; use crate::components::grain::grain; use crate::components::scroll_area::ScrollArea; +use crate::icons::IconRole; +use crate::theme::{ActiveTheme as _, DIALOG_MIN_WIDTH, TextRole, Typeset as _}; /// Requests the dialog's close: `false` closes. pub type ChangeHandler = Rc; diff --git a/crates/ui/src/components/dropdown_menu.rs b/crates/ui/src/components/dropdown_menu.rs index 15fd92e..df058e7 100644 --- a/crates/ui/src/components/dropdown_menu.rs +++ b/crates/ui/src/components/dropdown_menu.rs @@ -3,9 +3,6 @@ use std::cell::RefCell; use std::rc::Rc; -use crate::icons::{Icon, IconRole, icon}; -use crate::theme::{ActiveTheme as _, DISABLED_OPACITY, Size}; -use crate::utils::{focus_handle, focus_ring}; use gpui::prelude::FluentBuilder as _; use gpui::{ App, ClickEvent, DefiniteLength, DispatchPhase, ElementId, InteractiveElement as _, @@ -20,6 +17,9 @@ use crate::components::menu::{ ChangeHandler, MenuChrome, MenuItem, MenuPanelSpec, TriggerBoundsCell, anchored_menu_panel, }; use crate::components::spinner::Spinner; +use crate::icons::{Icon, IconRole, icon}; +use crate::theme::{ActiveTheme as _, DISABLED_OPACITY, Size}; +use crate::utils::{focus_handle, focus_ring}; /// The main zone's activation handler, shared by pointer, Enter, and Space. type ClickHandler = Box; diff --git a/crates/ui/src/components/empty_state.rs b/crates/ui/src/components/empty_state.rs index f3b8df2..c96bbb0 100644 --- a/crates/ui/src/components/empty_state.rs +++ b/crates/ui/src/components/empty_state.rs @@ -1,5 +1,3 @@ -use crate::icons::Icon; -use crate::theme::{ActiveTheme as _, Size, TextRole, Typeset as _}; use gpui::prelude::FluentBuilder as _; use gpui::{ App, IntoElement, ParentElement as _, RenderOnce, SharedString, StyleRefinement, Styled as _, @@ -7,6 +5,8 @@ use gpui::{ }; use crate::components::common::{StyledExt, v_flex}; +use crate::icons::Icon; +use crate::theme::{ActiveTheme as _, Size, TextRole, Typeset as _}; /// The centered "nothing here yet" panel for lists, tables, and searches. #[derive(IntoElement)] diff --git a/crates/ui/src/components/field.rs b/crates/ui/src/components/field.rs index b94dd50..8c50ef2 100644 --- a/crates/ui/src/components/field.rs +++ b/crates/ui/src/components/field.rs @@ -1,6 +1,5 @@ //! The field: a label, description, and error wrapped around a control. -use crate::theme::{ActiveTheme as _, TextRole, Typeset as _}; use gpui::prelude::FluentBuilder as _; use gpui::{ AnyElement, App, ElementId, InteractiveElement as _, IntoElement, ParentElement, RenderOnce, @@ -8,6 +7,7 @@ use gpui::{ }; use crate::components::common::{StyledExt, h_flex, v_flex}; +use crate::theme::{ActiveTheme as _, TextRole, Typeset as _}; /// The arrangement of a [`Field`]'s label and control. #[derive(Clone, Copy, Debug, Default, PartialEq, Eq)] diff --git a/crates/ui/src/components/grain.rs b/crates/ui/src/components/grain.rs index 9537050..dfdd245 100644 --- a/crates/ui/src/components/grain.rs +++ b/crates/ui/src/components/grain.rs @@ -2,14 +2,15 @@ use std::sync::{Arc, OnceLock}; -use crate::theme::GRAIN_ALPHA; -use crate::utils::ResultLogErr as _; use gpui::{ App, Bounds, Corners, IntoElement, RenderImage, RenderOnce, Styled as _, Window, canvas, point, px, size, }; use image::{Frame, ImageBuffer, Rgba}; +use crate::theme::GRAIN_ALPHA; +use crate::utils::ResultLogErr as _; + /// The side of one noise tile, in device pixels. const TILE_PX: u32 = 256; diff --git a/crates/ui/src/components/input.rs b/crates/ui/src/components/input.rs index 6ec892f..d5b3828 100644 --- a/crates/ui/src/components/input.rs +++ b/crates/ui/src/components/input.rs @@ -2,13 +2,6 @@ use std::ops::Range; use std::rc::Rc; use std::time::{Duration, Instant}; -use unicode_segmentation::UnicodeSegmentation; - -use crate::icons::IconRole; -use crate::theme::{ - ActiveTheme as _, CARET_WIDTH, ColorTokens, DISABLED_OPACITY, Size, UNDERLINE_WIDTH, - WHEEL_LINE_HEIGHT, -}; use gpui::prelude::FluentBuilder as _; use gpui::{ Animation, AnimationExt as _, AnyElement, App, AppContext as _, Bounds, ClipboardItem, @@ -19,9 +12,15 @@ use gpui::{ StatefulInteractiveElement as _, StyleRefinement, Styled as _, TextAlign, TextRun, UTF16Selection, Window, WrappedLine, actions, canvas, div, fill, point, px, }; +use unicode_segmentation::UnicodeSegmentation; use crate::components::button::{Button, ButtonVariant}; use crate::components::common::{Sizable, StyledExt as _, h_flex}; +use crate::icons::IconRole; +use crate::theme::{ + ActiveTheme as _, CARET_WIDTH, ColorTokens, DISABLED_OPACITY, Size, UNDERLINE_WIDTH, + WHEEL_LINE_HEIGHT, +}; /// The key context input bindings match against. pub const INPUT_CONTEXT: &str = "Input"; diff --git a/crates/ui/src/components/link.rs b/crates/ui/src/components/link.rs index f90cbaf..70e5846 100644 --- a/crates/ui/src/components/link.rs +++ b/crates/ui/src/components/link.rs @@ -1,5 +1,3 @@ -use crate::theme::{ActiveTheme as _, DISABLED_OPACITY, Size}; -use crate::utils::focus_ring; use gpui::prelude::FluentBuilder as _; use gpui::{ App, ClickEvent, ElementId, InteractiveElement as _, IntoElement, ParentElement as _, @@ -8,6 +6,8 @@ use gpui::{ }; use crate::components::common::{Sizable, StyledExt as _, h_flex}; +use crate::theme::{ActiveTheme as _, DISABLED_OPACITY, Size}; +use crate::utils::focus_ring; /// The click handler. When set it replaces the default `href` opening. type ClickHandler = Box; diff --git a/crates/ui/src/components/menu.rs b/crates/ui/src/components/menu.rs index 2f195fd..77d1e92 100644 --- a/crates/ui/src/components/menu.rs +++ b/crates/ui/src/components/menu.rs @@ -3,9 +3,6 @@ use std::cell::RefCell; use std::rc::Rc; -use crate::icons::{Icon, IconRole, icon as icon_glyph}; -use crate::theme::{ActiveTheme as _, BORDER_WIDTH, MENU_MIN_WIDTH, POPUP_MAX_HEIGHT}; -use crate::utils::focus_handle; use gpui::prelude::FluentBuilder; use gpui::{ Animation, AnimationExt as _, AnyElement, App, Bounds, BoxShadow, DefiniteLength, @@ -17,6 +14,9 @@ use gpui::{ use crate::components::common::{OVERLAY_LAYER, StyledExt as _, v_flex}; use crate::components::scroll_area::{ScrollArea, ScrollAxes}; +use crate::icons::{Icon, IconRole, icon as icon_glyph}; +use crate::theme::{ActiveTheme as _, BORDER_WIDTH, MENU_MIN_WIDTH, POPUP_MAX_HEIGHT}; +use crate::utils::focus_handle; /// Runs the item's action. The menu closes itself before the handler runs. pub type ItemHandler = Rc; diff --git a/crates/ui/src/components/popover.rs b/crates/ui/src/components/popover.rs index 6e4e9cf..95b293c 100644 --- a/crates/ui/src/components/popover.rs +++ b/crates/ui/src/components/popover.rs @@ -1,7 +1,6 @@ use std::cell::RefCell; use std::rc::Rc; -use crate::theme::{ActiveTheme as _, POPOVER_MIN_WIDTH}; use gpui::prelude::FluentBuilder as _; use gpui::{ Animation, AnimationExt as _, AnyElement, App, Bounds, DispatchPhase, ElementId, @@ -11,6 +10,7 @@ use gpui::{ }; use crate::components::common::{OVERLAY_LAYER, StyledExt as _, v_flex}; +use crate::theme::{ActiveTheme as _, POPOVER_MIN_WIDTH}; /// Reports the next open state of a [`Popover`]: `true` to open, `false` to close. type ChangeHandler = Rc; diff --git a/crates/ui/src/components/progress.rs b/crates/ui/src/components/progress.rs index 6b910c0..cc9bb73 100644 --- a/crates/ui/src/components/progress.rs +++ b/crates/ui/src/components/progress.rs @@ -1,6 +1,5 @@ //! The progress bar: determinate fill or an indeterminate sweep. -use crate::theme::{ActiveTheme as _, PROGRESS_ANIMATION_PERIOD, Size}; use gpui::prelude::FluentBuilder as _; use gpui::{ Animation, AnimationExt as _, App, ElementId, InteractiveElement as _, IntoElement, @@ -9,6 +8,7 @@ use gpui::{ }; use crate::components::common::{Sizable, StyledExt as _}; +use crate::theme::{ActiveTheme as _, PROGRESS_ANIMATION_PERIOD, Size}; /// A progress bar. With a `value` in `0..=1` it paints a determinate fill. #[derive(IntoElement)] diff --git a/crates/ui/src/components/radio.rs b/crates/ui/src/components/radio.rs index 2947fbb..106d50f 100644 --- a/crates/ui/src/components/radio.rs +++ b/crates/ui/src/components/radio.rs @@ -1,5 +1,3 @@ -use crate::theme::{ActiveTheme as _, DISABLED_OPACITY, Size}; -use crate::utils::focus_ring; use gpui::prelude::FluentBuilder; use gpui::{ App, ElementId, InteractiveElement as _, IntoElement, ParentElement as _, RenderOnce, Role, @@ -8,6 +6,8 @@ use gpui::{ }; use crate::components::common::{Sizable, StyledExt as _, h_flex, v_flex}; +use crate::theme::{ActiveTheme as _, DISABLED_OPACITY, Size}; +use crate::utils::focus_ring; /// The group's change reporter, fired with the clicked radio's value. type ChangeHandler = std::rc::Rc; diff --git a/crates/ui/src/components/scrollbar.rs b/crates/ui/src/components/scrollbar.rs index fa83722..5c68d1a 100644 --- a/crates/ui/src/components/scrollbar.rs +++ b/crates/ui/src/components/scrollbar.rs @@ -4,8 +4,6 @@ use std::rc::Rc; use std::sync::Arc; use std::time::{Duration, Instant}; -use crate::theme::{ActiveTheme as _, SCROLLBAR_AUTOHIDE_DELAY, SCROLLBAR_FADE_DURATION}; -use crate::utils::ResultLogErr as _; use gpui::{ App, Bounds, DispatchPhase, ElementId, Entity, EntityId, IntoElement, ListState, MouseButton, MouseDownEvent, MouseMoveEvent, MouseUpEvent, Pixels, Point, RenderOnce, ScrollEvent, @@ -13,6 +11,9 @@ use gpui::{ point, }; +use crate::theme::{ActiveTheme as _, SCROLLBAR_AUTOHIDE_DELAY, SCROLLBAR_FADE_DURATION}; +use crate::utils::ResultLogErr as _; + /// When an overlay scrollbar shows. #[derive(Clone, Copy, Debug, Default, PartialEq, Eq)] pub enum ScrollbarVisibility { diff --git a/crates/ui/src/components/segmented.rs b/crates/ui/src/components/segmented.rs index 6631733..9d84eb7 100644 --- a/crates/ui/src/components/segmented.rs +++ b/crates/ui/src/components/segmented.rs @@ -1,8 +1,5 @@ use std::rc::Rc; -use crate::icons::Icon; -use crate::theme::{ActiveTheme as _, CONTROL_SPRING, Size}; -use crate::utils::{focus_handle, focus_ring}; use gpui::prelude::FluentBuilder; use gpui::{ AnimationExt as _, App, Bounds, ElementId, Entity, InteractiveElement as _, IntoElement, @@ -11,6 +8,9 @@ use gpui::{ }; use crate::components::common::{Sizable, StyledExt, h_flex}; +use crate::icons::Icon; +use crate::theme::{ActiveTheme as _, CONTROL_SPRING, Size}; +use crate::utils::{focus_handle, focus_ring}; /// Reports the segment the user chose. type ChangeHandler = Rc; diff --git a/crates/ui/src/components/select.rs b/crates/ui/src/components/select.rs index d138c25..a1a5815 100644 --- a/crates/ui/src/components/select.rs +++ b/crates/ui/src/components/select.rs @@ -1,8 +1,5 @@ use std::rc::Rc; -use crate::icons::{Icon, IconRole, icon}; -use crate::theme::{ActiveTheme as _, Size}; -use crate::utils::focus_handle; use gpui::prelude::FluentBuilder; use gpui::{ App, ElementId, InteractiveElement as _, IntoElement, KeyDownEvent, ParentElement as _, @@ -12,6 +9,9 @@ use gpui::{ use crate::components::common::{Sizable, StyledExt, h_flex}; use crate::components::menu::{Menu, MenuItem}; +use crate::icons::{Icon, IconRole, icon}; +use crate::theme::{ActiveTheme as _, Size}; +use crate::utils::focus_handle; /// Reports the value the user chose. `None` means the select holds no value. pub type SelectHandler = Rc, &mut Window, &mut App)>; diff --git a/crates/ui/src/components/separator.rs b/crates/ui/src/components/separator.rs index 3098dbc..29a704b 100644 --- a/crates/ui/src/components/separator.rs +++ b/crates/ui/src/components/separator.rs @@ -2,14 +2,15 @@ use std::rc::Rc; -use crate::theme::{ActiveTheme as _, BORDER_WIDTH}; -use crate::utils::StyledExt as _; use gpui::prelude::FluentBuilder as _; use gpui::{ App, InteractiveElement as _, IntoElement, RenderOnce, StyleRefinement, Styled as _, Window, div, }; +use crate::theme::{ActiveTheme as _, BORDER_WIDTH}; +use crate::utils::StyledExt as _; + /// Which axis the rule runs along. #[derive(Clone, Copy, Debug, Default, PartialEq, Eq)] pub enum SeparatorOrientation { diff --git a/crates/ui/src/components/slider.rs b/crates/ui/src/components/slider.rs index 90ae678..09f6f29 100644 --- a/crates/ui/src/components/slider.rs +++ b/crates/ui/src/components/slider.rs @@ -1,8 +1,6 @@ use std::cell::Cell; use std::rc::Rc; -use crate::theme::{ActiveTheme as _, DISABLED_OPACITY, Size}; -use crate::utils::focus_ring; use gpui::prelude::FluentBuilder as _; use gpui::{ App, Bounds, DispatchPhase, ElementId, InteractiveElement as _, IntoElement, KeyDownEvent, @@ -12,6 +10,8 @@ use gpui::{ }; use crate::components::common::{Sizable, StyledExt as _, h_flex}; +use crate::theme::{ActiveTheme as _, DISABLED_OPACITY, Size}; +use crate::utils::focus_ring; /// The change reporter, fired with the next value by click, drag, and arrows. type ChangeHandler = Rc; diff --git a/crates/ui/src/components/speech.rs b/crates/ui/src/components/speech.rs index 6c52e40..a7c4de7 100644 --- a/crates/ui/src/components/speech.rs +++ b/crates/ui/src/components/speech.rs @@ -7,14 +7,10 @@ //! and has no recognizer, so [`SpeechButton`] renders nothing until the //! application provides one. -use std::time::Duration; - #[cfg(not(target_arch = "wasm32"))] use std::sync::{Arc, Mutex}; +use std::time::Duration; -use crate::icons::{IconRole, icon}; -use crate::theme::{ActiveTheme as _, DISABLED_OPACITY, SPEECH_WAVEFORM_WIDTH, Size}; -use crate::utils::focus_ring; use gpui::prelude::FluentBuilder as _; use gpui::{ App, Context, ElementId, Entity, EventEmitter, InteractiveElement as _, IntoElement, @@ -25,6 +21,9 @@ use gpui::{ use crate::components::common::{Sizable, StyledExt as _, h_flex}; use crate::components::spinner::{Spinner, SpinnerVariant}; use crate::components::tooltip::Tooltip; +use crate::icons::{IconRole, icon}; +use crate::theme::{ActiveTheme as _, DISABLED_OPACITY, SPEECH_WAVEFORM_WIDTH, Size}; +use crate::utils::focus_ring; /// One input-level entry per this much of captured audio. const LEVEL_BUCKET: Duration = Duration::from_millis(80); diff --git a/crates/ui/src/components/spinner.rs b/crates/ui/src/components/spinner.rs index b57df4e..290414d 100644 --- a/crates/ui/src/components/spinner.rs +++ b/crates/ui/src/components/spinner.rs @@ -4,8 +4,6 @@ use std::cell::Cell; use std::f32::consts::{PI, TAU}; use std::rc::Rc; -use crate::icons::{Icon, IconRole, icon}; -use crate::theme::{ActiveTheme as _, SPINNER_PERIOD, Size}; use gpui::prelude::FluentBuilder as _; use gpui::{ Animation, AnimationElement, AnimationExt as _, App, Canvas, ElementId, Hsla, @@ -15,6 +13,8 @@ use gpui::{ }; use crate::components::common::{Sizable, StyledExt as _}; +use crate::icons::{Icon, IconRole, icon}; +use crate::theme::{ActiveTheme as _, SPINNER_PERIOD, Size}; /// The share of the circle the spinning arc paints. const SPIN_SWEEP: f32 = 0.75; @@ -263,9 +263,10 @@ fn circle_path(center: Point, radius: Pixels, stroke: Pixels) -> Option< #[cfg(test)] mod tests { - use super::*; use std::f32::consts::FRAC_PI_2; + use super::*; + #[test] fn ring_points_run_clockwise_from_twelve() { let center = point(px(10.0), px(20.0)); diff --git a/crates/ui/src/components/status_dot.rs b/crates/ui/src/components/status_dot.rs index 0a03ae0..2a077f6 100644 --- a/crates/ui/src/components/status_dot.rs +++ b/crates/ui/src/components/status_dot.rs @@ -1,6 +1,5 @@ //! The status dot: a small colored bead for row state. -use crate::theme::{ActiveTheme as _, Size, Theme}; use gpui::prelude::FluentBuilder as _; use gpui::{ App, ElementId, Hsla, InteractiveElement as _, IntoElement, RenderOnce, Role, SharedString, @@ -8,6 +7,7 @@ use gpui::{ }; use crate::components::common::{Sizable, StyledExt}; +use crate::theme::{ActiveTheme as _, Size, Theme}; /// How loud a dot is, the same vocabulary as [`crate::components::badge::BadgeVariant`]. #[derive(Clone, Copy, Debug, Default, PartialEq, Eq)] diff --git a/crates/ui/src/components/switch.rs b/crates/ui/src/components/switch.rs index f2a89bc..c586f5e 100644 --- a/crates/ui/src/components/switch.rs +++ b/crates/ui/src/components/switch.rs @@ -1,7 +1,5 @@ //! The switch: a controlled on/off pill with a thumb. -use crate::theme::{ActiveTheme as _, BORDER_WIDTH, CONTROL_SPRING, DISABLED_OPACITY, Size}; -use crate::utils::focus_ring; use gpui::prelude::FluentBuilder as _; use gpui::{ AnimationExt as _, App, ElementId, InteractiveElement as _, IntoElement, ParentElement as _, @@ -10,6 +8,8 @@ use gpui::{ }; use crate::components::common::{Sizable, StyledExt as _, h_flex}; +use crate::theme::{ActiveTheme as _, BORDER_WIDTH, CONTROL_SPRING, DISABLED_OPACITY, Size}; +use crate::utils::focus_ring; /// The change reporter, fired with the next value by pointer, Enter, and Space. type ChangeHandler = Box; diff --git a/crates/ui/src/components/toast.rs b/crates/ui/src/components/toast.rs index c7f9d1f..2bd313b 100644 --- a/crates/ui/src/components/toast.rs +++ b/crates/ui/src/components/toast.rs @@ -3,9 +3,6 @@ use std::rc::Rc; use std::time::Duration; -use crate::icons::{Icon, IconRole}; -use crate::theme::{ActiveTheme as _, TOAST_MAX_WIDTH}; -use crate::utils::ResultLogErr as _; use gpui::prelude::FluentBuilder; use gpui::{ Animation, AnimationExt as _, App, Context, ElementId, Entity, InteractiveElement as _, @@ -16,6 +13,9 @@ use gpui::{ use crate::components::button::{Button, ButtonVariant}; use crate::components::common::{DismissHandler, Sizable as _, StyledExt as _, TOAST_LAYER}; +use crate::icons::{Icon, IconRole}; +use crate::theme::{ActiveTheme as _, TOAST_MAX_WIDTH}; +use crate::utils::ResultLogErr as _; /// The action handler of a [`Toast`]. pub type ActionHandler = Rc; diff --git a/crates/ui/src/components/toggle.rs b/crates/ui/src/components/toggle.rs index 166ae83..9abd382 100644 --- a/crates/ui/src/components/toggle.rs +++ b/crates/ui/src/components/toggle.rs @@ -1,6 +1,3 @@ -use crate::icons::Icon; -use crate::theme::{ActiveTheme as _, DISABLED_OPACITY, Size}; -use crate::utils::focus_ring; use gpui::prelude::FluentBuilder as _; use gpui::{ App, ElementId, InteractiveElement as _, IntoElement, ParentElement as _, RenderOnce, Role, @@ -8,6 +5,9 @@ use gpui::{ }; use crate::components::common::{Sizable, StyledExt as _, h_flex}; +use crate::icons::Icon; +use crate::theme::{ActiveTheme as _, DISABLED_OPACITY, Size}; +use crate::utils::focus_ring; /// The change handler, fired with the next pressed state. type ChangeHandler = Box; diff --git a/crates/ui/src/components/tooltip.rs b/crates/ui/src/components/tooltip.rs index ec658b7..6cb4648 100644 --- a/crates/ui/src/components/tooltip.rs +++ b/crates/ui/src/components/tooltip.rs @@ -1,11 +1,11 @@ +use gpui::{ + AnyView, App, AppContext as _, Bounds, Context, ElementId, Entity, InteractiveElement as _, + IntoElement, ParentElement as _, Pixels, Render, Role, SharedString, + StatefulInteractiveElement as _, Styled as _, Window, canvas, div, point, +}; + use crate::theme::{ActiveTheme as _, BORDER_WIDTH, TOOLTIP_MAX_WIDTH, TOOLTIP_OFFSET}; use crate::utils::{anchor_bounds, record_anchor_bounds}; -use gpui::AppContext as _; -use gpui::{ - AnyView, App, Bounds, Context, ElementId, Entity, InteractiveElement as _, IntoElement, - ParentElement as _, Pixels, Render, Role, SharedString, StatefulInteractiveElement as _, - Styled as _, Window, canvas, div, point, -}; const PANEL_BOUNDS_ID: &str = "tooltip-panel-bounds"; diff --git a/crates/ui/src/data/list.rs b/crates/ui/src/data/list.rs index 27a5d9f..59b1c8d 100644 --- a/crates/ui/src/data/list.rs +++ b/crates/ui/src/data/list.rs @@ -1,8 +1,5 @@ use std::rc::Rc; -use crate::icons::Icon; -use crate::theme::{ActiveTheme as _, TextRole, Typeset as _}; -use crate::utils::{StyledExt as _, nav_key, paint_selectable_row, selectable_label_color}; use gpui::prelude::FluentBuilder; use gpui::{ AnyElement, App, ElementId, FocusHandle, InteractiveElement as _, IntoElement, KeyDownEvent, @@ -10,6 +7,10 @@ use gpui::{ StyleRefinement, Styled as _, Window, div, }; +use crate::icons::Icon; +use crate::theme::{ActiveTheme as _, TextRole, Typeset as _}; +use crate::utils::{StyledExt as _, nav_key, paint_selectable_row, selectable_label_color}; + /// The change reporter, fired with the next selection by pointer and keys. type ChangeHandler = Rc, &mut Window, &mut App)>; type ItemsFn = Box Vec>; diff --git a/crates/ui/src/data/sidebar.rs b/crates/ui/src/data/sidebar.rs index 1f6ce98..e6ffdea 100644 --- a/crates/ui/src/data/sidebar.rs +++ b/crates/ui/src/data/sidebar.rs @@ -4,10 +4,6 @@ use std::rc::Rc; -use crate::components::grain::grain as grain_overlay; -use crate::components::scroll_area::ScrollArea; -use crate::theme::{ActiveTheme as _, BORDER_WIDTH, SIDEBAR_DEFAULT_WIDTH, TextRole, Typeset as _}; -use crate::utils::{StyledExt as _, nav_key, paint_selectable_row, selectable_label_color}; use gpui::prelude::FluentBuilder; use gpui::{ AnyElement, App, ElementId, FocusHandle, InteractiveElement as _, IntoElement, KeyDownEvent, @@ -15,6 +11,11 @@ use gpui::{ StyleRefinement, Styled as _, Window, div, }; +use crate::components::grain::grain as grain_overlay; +use crate::components::scroll_area::ScrollArea; +use crate::theme::{ActiveTheme as _, BORDER_WIDTH, SIDEBAR_DEFAULT_WIDTH, TextRole, Typeset as _}; +use crate::utils::{StyledExt as _, nav_key, paint_selectable_row, selectable_label_color}; + /// The change reporter, fired with the next selected row by pointer and keys. type ChangeHandler = Rc, &mut Window, &mut App)>; type EntriesFn = Box Vec>; diff --git a/crates/ui/src/data/tabs.rs b/crates/ui/src/data/tabs.rs index 080f54e..5dc1143 100644 --- a/crates/ui/src/data/tabs.rs +++ b/crates/ui/src/data/tabs.rs @@ -2,6 +2,14 @@ use std::cell::RefCell; use std::collections::HashMap; use std::rc::Rc; +use gpui::prelude::FluentBuilder; +use gpui::{ + AnyElement, App, AppContext as _, Bounds, ClickEvent, Context, Div, ElementId, Global, + InteractiveElement as _, IntoElement, KeyDownEvent, MouseButton, ParentElement as _, Pixels, + Point, Render, RenderOnce, Role, SharedString, Stateful, StatefulInteractiveElement as _, + StyleRefinement, Styled as _, Window, canvas, div, px, relative, +}; + use crate::components::button::{Button, ButtonVariant}; use crate::components::common::{Sizable as _, v_flex}; use crate::components::popover::Popover; @@ -11,13 +19,6 @@ use crate::components::tooltip::Tooltip; use crate::icons::IconRole; use crate::theme::{ActiveTheme as _, POPUP_MAX_HEIGHT, Size, TAB_INDICATOR_WIDTH}; use crate::utils::{StyledExt as _, adjacent_selectable}; -use gpui::prelude::FluentBuilder; -use gpui::{ - AnyElement, App, AppContext as _, Bounds, ClickEvent, Context, Div, ElementId, Global, - InteractiveElement as _, IntoElement, KeyDownEvent, MouseButton, ParentElement as _, Pixels, - Point, Render, RenderOnce, Role, SharedString, Stateful, StatefulInteractiveElement as _, - StyleRefinement, Styled as _, Window, canvas, div, px, relative, -}; /// Reports the next selected tab by pointer and keys. type ChangeHandler = Rc; diff --git a/crates/ui/src/data/tree.rs b/crates/ui/src/data/tree.rs index 9311a73..e5088ab 100644 --- a/crates/ui/src/data/tree.rs +++ b/crates/ui/src/data/tree.rs @@ -1,8 +1,5 @@ use std::rc::Rc; -use crate::icons::{Icon, IconRole, icon}; -use crate::theme::ActiveTheme as _; -use crate::utils::{StyledExt as _, nav_key, paint_selectable_row, selectable_label_color}; use gpui::prelude::FluentBuilder; use gpui::{ AnyElement, App, ElementId, FocusHandle, InteractiveElement as _, IntoElement, KeyDownEvent, @@ -10,6 +7,10 @@ use gpui::{ StyleRefinement, Styled as _, Window, div, }; +use crate::icons::{Icon, IconRole, icon}; +use crate::theme::ActiveTheme as _; +use crate::utils::{StyledExt as _, nav_key, paint_selectable_row, selectable_label_color}; + /// The change reporter, fired with the next selection by pointer and keys. type ChangeHandler = Rc, &mut Window, &mut App)>; /// The disclosure reporter, fired with the toggled row's index. diff --git a/crates/ui/src/editor/code.rs b/crates/ui/src/editor/code.rs index 92dce9a..f9ed671 100644 --- a/crates/ui/src/editor/code.rs +++ b/crates/ui/src/editor/code.rs @@ -2,11 +2,6 @@ //! Rows render only when visible, the line-number gutter is part of each //! row, and the overlay scrollbar is the core one. -use crate::components::scrollbar::{Scrollbar, ScrollbarHandle, ScrollbarVisibility}; -use crate::theme::{ - ActiveTheme as _, CODE_GUTTER_WIDTH, CODE_LINE_HEIGHT, ColorTokens, MONO_ADVANCE_RATIO, Ramps, - WASH_ALPHA_SOFT, -}; use gpui::prelude::FluentBuilder as _; use gpui::{ App, Bounds, ClipboardItem, Context, ElementId, HighlightStyle, Hsla, InteractiveElement as _, @@ -16,8 +11,13 @@ use gpui::{ actions, canvas, div, uniform_list, }; +use crate::components::scrollbar::{Scrollbar, ScrollbarHandle, ScrollbarVisibility}; use crate::editor::highlight::{HighlightedCode, Language, Role, highlight}; use crate::editor::utils::gutter_cell; +use crate::theme::{ + ActiveTheme as _, CODE_GUTTER_WIDTH, CODE_LINE_HEIGHT, ColorTokens, MONO_ADVANCE_RATIO, Ramps, + WASH_ALPHA_SOFT, +}; actions!(code_view, [Copy]); diff --git a/crates/ui/src/editor/diff.rs b/crates/ui/src/editor/diff.rs index 758b6f5..306cb37 100644 --- a/crates/ui/src/editor/diff.rs +++ b/crates/ui/src/editor/diff.rs @@ -5,8 +5,8 @@ //! consumers that already hold a git diff can build [`DiffRow`]s themselves //! instead of calling [`DiffViewState::diff_rows`]. -use crate::components::scrollbar::{Scrollbar, ScrollbarHandle, ScrollbarVisibility}; -use crate::theme::{ActiveTheme as _, BORDER_WIDTH, CODE_GUTTER_WIDTH, MONO_ADVANCE_RATIO}; +use std::ops::Range; + use gpui::prelude::FluentBuilder as _; use gpui::{ App, Context, ElementId, HighlightStyle, InteractiveElement as _, IntoElement, @@ -16,10 +16,10 @@ use gpui::{ }; use similar::{Change, ChangeTag, TextDiff}; -use std::ops::Range; - +use crate::components::scrollbar::{Scrollbar, ScrollbarHandle, ScrollbarVisibility}; use crate::editor::highlight::{HighlightedCode, Language, Line, Role, highlight}; use crate::editor::utils::{gutter_cell, wash, wash_gutter, wash_strong}; +use crate::theme::{ActiveTheme as _, BORDER_WIDTH, CODE_GUTTER_WIDTH, MONO_ADVANCE_RATIO}; /// What a diff row did to the file. #[derive(Clone, Copy, Debug, PartialEq, Eq)] diff --git a/crates/ui/src/editor/highlight.rs b/crates/ui/src/editor/highlight.rs index 016bb9c..4ba949f 100644 --- a/crates/ui/src/editor/highlight.rs +++ b/crates/ui/src/editor/highlight.rs @@ -2,13 +2,15 @@ //! are resolved to theme colors at render time, so a theme change re-colors //! code without re-parsing it. -use crate::utils::ResultLogErr; -use gpui::SharedString; use std::cell::RefCell; use std::collections::HashMap; + +use gpui::SharedString; #[cfg(not(target_arch = "wasm32"))] use tree_sitter::StreamingIterator as _; +use crate::utils::ResultLogErr; + #[cfg(not(target_arch = "wasm32"))] thread_local! { static HIGHLIGHTERS: RefCell>> = diff --git a/crates/ui/src/editor/markdown.rs b/crates/ui/src/editor/markdown.rs index 569f601..1173753 100644 --- a/crates/ui/src/editor/markdown.rs +++ b/crates/ui/src/editor/markdown.rs @@ -6,14 +6,12 @@ //! toggles and code blocks offer a copy action. Footnotes, math, and HTML //! render nothing; long code lines clip rather than scroll. -use crate::components::button::{Button, ButtonVariant}; -use crate::components::checkbox::Checkbox; -use crate::components::common::Sizable as _; -use crate::components::scrollbar::{Scrollbar, ScrollbarVisibility}; -use crate::theme::{ - ActiveTheme as _, BORDER_WIDTH, CODE_LINE_HEIGHT, CODE_OVERSCROLL_MAX, Size, TextRole, - Typeset as _, -}; +use std::borrow::Borrow as _; +use std::collections::HashMap; +use std::hash::{DefaultHasher, Hash, Hasher}; +use std::ops::Range; +use std::sync::Arc; + use gpui::prelude::FluentBuilder as _; use gpui::{ AnyElement, App, Bounds, ClipboardItem, Context, Div, Element, ElementId, Entity, FontStyle, @@ -26,14 +24,16 @@ use gpui::{ }; use pulldown_cmark::{CodeBlockKind, Event, HeadingLevel, Options, Parser, Tag, TagEnd}; -use std::borrow::Borrow as _; -use std::collections::HashMap; -use std::hash::{DefaultHasher, Hash, Hasher}; -use std::ops::Range; -use std::sync::Arc; - +use crate::components::button::{Button, ButtonVariant}; +use crate::components::checkbox::Checkbox; +use crate::components::common::Sizable as _; +use crate::components::scrollbar::{Scrollbar, ScrollbarVisibility}; use crate::editor::highlight::{HighlightedCode, Language, highlight, plain}; use crate::editor::utils::code_line; +use crate::theme::{ + ActiveTheme as _, BORDER_WIDTH, CODE_LINE_HEIGHT, CODE_OVERSCROLL_MAX, Size, TextRole, + Typeset as _, +}; /// The bottom padding between sibling blocks, in root font sizes. const BLOCK_GAP: f32 = 0.75; @@ -648,8 +648,8 @@ impl Styled for TextView { } impl Element for TextView { - type RequestLayoutState = AnyElement; type PrepaintState = (); + type RequestLayoutState = AnyElement; fn id(&self) -> Option { Some(self.id.clone()) diff --git a/crates/ui/src/editor/utils.rs b/crates/ui/src/editor/utils.rs index e65de4e..372f170 100644 --- a/crates/ui/src/editor/utils.rs +++ b/crates/ui/src/editor/utils.rs @@ -3,13 +3,15 @@ use std::ops::Range; -use crate::editor::highlight::{Language, Line}; -use crate::theme::{ActiveTheme as _, CODE_GUTTER_WIDTH, ColorTokens, Ramps}; -use crate::theme::{WASH_ALPHA, WASH_ALPHA_GUTTER, WASH_ALPHA_STRONG}; -use gpui::StyledText; -use gpui::{App, HighlightStyle, Hsla, IntoElement, ParentElement as _, Styled as _, div}; +use gpui::{ + App, HighlightStyle, Hsla, IntoElement, ParentElement as _, Styled as _, StyledText, div, +}; -use crate::editor::highlight::Role; +use crate::editor::highlight::{Language, Line, Role}; +use crate::theme::{ + ActiveTheme as _, CODE_GUTTER_WIDTH, ColorTokens, Ramps, WASH_ALPHA, WASH_ALPHA_GUTTER, + WASH_ALPHA_STRONG, +}; impl Role { /// Maps the role to the theme's semantic palette. diff --git a/crates/ui/src/layout/panel.rs b/crates/ui/src/layout/panel.rs index 9120738..51d3fcb 100644 --- a/crates/ui/src/layout/panel.rs +++ b/crates/ui/src/layout/panel.rs @@ -5,14 +5,14 @@ use std::sync::Arc; -use crate::theme::ActiveTheme as _; -use crate::utils::StyledExt as _; use gpui::{ AnyElement, AnyView, App, Axis, Div, ElementId, Entity, IntoElement, ParentElement as _, Render, RenderOnce, SharedString, StyleRefinement, Styled as _, Window, div, }; use crate::layout::resizable::{Resizable, ResizableState}; +use crate::theme::ActiveTheme as _; +use crate::utils::StyledExt as _; /// A user-defined panel the row can show. #[allow(unused_variables)] diff --git a/crates/ui/src/layout/resizable.rs b/crates/ui/src/layout/resizable.rs index 113bd41..983e33a 100644 --- a/crates/ui/src/layout/resizable.rs +++ b/crates/ui/src/layout/resizable.rs @@ -1,7 +1,5 @@ //! The resizable group: stacked panes with drag dividers, outside the dock. -use crate::theme::{PANE_DEFAULT_SIZE, PANE_MIN_SIZE}; -use crate::utils::StyledExt as _; use gpui::prelude::FluentBuilder as _; use gpui::{ AnyElement, App, AppContext as _, Axis, Bounds, Context, ElementId, Entity, @@ -10,6 +8,8 @@ use gpui::{ }; use crate::layout::resize_handle::ResizeHandle; +use crate::theme::{PANE_DEFAULT_SIZE, PANE_MIN_SIZE}; +use crate::utils::StyledExt as _; type DebugSelector = std::rc::Rc String>; diff --git a/crates/ui/src/layout/resize_handle.rs b/crates/ui/src/layout/resize_handle.rs index 17a3f86..fdf7a29 100644 --- a/crates/ui/src/layout/resize_handle.rs +++ b/crates/ui/src/layout/resize_handle.rs @@ -3,10 +3,6 @@ use std::rc::Rc; -use crate::theme::{ - ActiveTheme as _, BORDER_WIDTH, DISABLED_OPACITY, HAIRLINE_WIDTH, RESIZE_KEYBOARD_STEP, -}; -use crate::utils::{StyledExt as _, focus_handle, focus_ring}; use gpui::prelude::FluentBuilder as _; use gpui::{ App, Axis, Bounds, CursorStyle, DispatchPhase, ElementId, HitboxBehavior, @@ -16,6 +12,11 @@ use gpui::{ deferred, div, fill, point, px, }; +use crate::theme::{ + ActiveTheme as _, BORDER_WIDTH, DISABLED_OPACITY, HAIRLINE_WIDTH, RESIZE_KEYBOARD_STEP, +}; +use crate::utils::{StyledExt as _, focus_handle, focus_ring}; + /// How far one keyboard arrow step moves the seam. const KEYBOARD_STEP: Pixels = RESIZE_KEYBOARD_STEP; diff --git a/crates/ui/src/layout/titlebar.rs b/crates/ui/src/layout/titlebar.rs index 6e55ef8..f976a59 100644 --- a/crates/ui/src/layout/titlebar.rs +++ b/crates/ui/src/layout/titlebar.rs @@ -4,8 +4,6 @@ //! edge. The bar itself moves the window, tab bar included; the prefix and //! suffix opt out, so a press on a control never starts a drag. -use crate::theme::{ActiveTheme as _, Size, TRAFFIC_LIGHT_PAD}; -use crate::utils::{StyledExt as _, h_flex}; use gpui::prelude::FluentBuilder as _; use gpui::{ AnyElement, App, ElementId, InteractiveElement as _, IntoElement, ParentElement, RenderOnce, @@ -13,6 +11,8 @@ use gpui::{ }; use crate::layout::window_controls::{WindowControls, titlebar_strip}; +use crate::theme::{ActiveTheme as _, Size, TRAFFIC_LIGHT_PAD}; +use crate::utils::{StyledExt as _, h_flex}; /// The window's titlebar. #[derive(IntoElement)] diff --git a/crates/ui/src/layout/window_controls.rs b/crates/ui/src/layout/window_controls.rs index 97303a4..137fd28 100644 --- a/crates/ui/src/layout/window_controls.rs +++ b/crates/ui/src/layout/window_controls.rs @@ -4,21 +4,25 @@ //! never moves it; macOS draws its traffic lights in the shell's reserved pad //! and needs no controls of ours. -use gpui::WindowControlArea; -use gpui::{App, ClickEvent, Div, ElementId, IntoElement, RenderOnce, Stateful, Window, div}; -use gpui::{InteractiveElement as _, MouseButton, StatefulInteractiveElement as _}; - +#[cfg(target_os = "linux")] +use gpui::Decorations; #[cfg(any(target_os = "windows", target_os = "linux"))] -use crate::icons::{IconRole, icon}; -#[cfg(any(target_os = "windows", target_os = "linux"))] -use crate::theme::ActiveTheme as _; +use gpui::SharedString; #[cfg(any(target_os = "windows", target_os = "linux"))] use gpui::Styled as _; #[cfg(any(target_os = "windows", target_os = "linux"))] use gpui::prelude::FluentBuilder as _; #[cfg(any(target_os = "windows", target_os = "linux"))] use gpui::{AnyElement, ParentElement as _}; +use gpui::{ + App, ClickEvent, Div, ElementId, InteractiveElement as _, IntoElement, MouseButton, RenderOnce, + Stateful, StatefulInteractiveElement as _, Window, WindowControlArea, div, +}; +#[cfg(any(target_os = "windows", target_os = "linux"))] +use crate::icons::{IconRole, icon}; +#[cfg(any(target_os = "windows", target_os = "linux"))] +use crate::theme::ActiveTheme as _; /// macOS traffic-lights zone: the pad a leading titlebar strip reserves. pub use crate::theme::TRAFFIC_LIGHT_PAD; #[cfg(target_os = "windows")] @@ -26,10 +30,6 @@ use crate::theme::{ WINDOWS_CAPTION_WIDTH as CAPTION_WIDTH, WINDOWS_CLOSE_FOREGROUND, WINDOWS_CLOSE_HOVER, WINDOWS_CLOSE_PRESSED, }; -#[cfg(target_os = "linux")] -use gpui::Decorations; -#[cfg(any(target_os = "windows", target_os = "linux"))] -use gpui::SharedString; /// The window controls for the trailing end of a titlebar strip. #[derive(IntoElement)] diff --git a/crates/ui/src/layout/window_frame.rs b/crates/ui/src/layout/window_frame.rs index d21a88f..97d988f 100644 --- a/crates/ui/src/layout/window_frame.rs +++ b/crates/ui/src/layout/window_frame.rs @@ -1,7 +1,6 @@ //! The client-side window frame: the border, corners, shadow, and resize //! edges of a window the system does not decorate. -use crate::theme::{ActiveTheme as _, BORDER_WIDTH, INACTIVE_SHADOW_OPACITY, WINDOW_RESIZE_INSET}; use gpui::prelude::FluentBuilder as _; use gpui::{ App, Bounds, BoxShadow, CursorStyle, Decorations, Div, HitboxBehavior, InteractiveElement as _, @@ -9,6 +8,8 @@ use gpui::{ Tiling, Window, canvas, div, point, px, size, }; +use crate::theme::{ActiveTheme as _, BORDER_WIDTH, INACTIVE_SHADOW_OPACITY, WINDOW_RESIZE_INSET}; + /// Wraps a window's root in the frame it owes. pub fn frame(child: E, window: &mut Window, cx: &App) -> Div where diff --git a/crates/ui/src/lib.rs b/crates/ui/src/lib.rs index ce4a201..ea6916f 100644 --- a/crates/ui/src/lib.rs +++ b/crates/ui/src/lib.rs @@ -9,9 +9,8 @@ pub mod theme; pub mod utils; pub use components::*; -pub use icons::{Assets, Icon, IconRole}; - use gpui::App; +pub use icons::{Assets, Icon, IconRole}; /// Initializes the theme and every key binding the UI layer owns. pub fn init(cx: &mut App) { diff --git a/crates/ui/src/theme/mod.rs b/crates/ui/src/theme/mod.rs index d025219..1a28d29 100644 --- a/crates/ui/src/theme/mod.rs +++ b/crates/ui/src/theme/mod.rs @@ -15,18 +15,18 @@ mod source; mod system; mod typography; +use std::time::Duration; + pub use colors::{ColorTokens, MaterialTokens}; pub use definition::ThemeDefinition; +use gpui::{ + App, Global, Hsla, Pixels, SpringConfig, WindowAppearance, WindowBackgroundAppearance, hsla, px, +}; pub use ramps::{AccentShades, Oklch}; pub use resolve::{Ramps, ResolvedTheme}; pub use system::{AccessibilityPreferences, SourceKind, SystemTheme}; pub use typography::{TextRole, TypeMetrics, Typeset, Typography}; -use gpui::{ - App, Global, Hsla, Pixels, SpringConfig, WindowAppearance, WindowBackgroundAppearance, hsla, px, -}; -use std::time::Duration; - /// The hairline width of the control border every button and field paints. pub const BORDER_WIDTH: Pixels = px(1.0); /// The underline and drop indicators a tab strip paints. @@ -767,9 +767,10 @@ pub fn detected_source(cx: &App) -> &'static str { #[cfg(test)] mod tests { - use super::*; use gpui::Rgba; + use super::*; + #[test] fn the_windows_close_colors_match_the_legacy_hex() { let hover = Hsla::from(gpui::rgba(0xE81123FF)); diff --git a/crates/ui/src/theme/ramps.rs b/crates/ui/src/theme/ramps.rs index 35318ba..920e2b5 100644 --- a/crates/ui/src/theme/ramps.rs +++ b/crates/ui/src/theme/ramps.rs @@ -181,9 +181,10 @@ pub fn derive_shades(accent: Hsla, background: Hsla, is_dark: bool) -> AccentSha #[cfg(test)] mod tests { - use super::*; use gpui::rgb; + use super::*; + fn hsla(hex: u32) -> Hsla { Hsla::from(rgb(hex)) } diff --git a/crates/ui/src/theme/resolve.rs b/crates/ui/src/theme/resolve.rs index 51dab15..c73e821 100644 --- a/crates/ui/src/theme/resolve.rs +++ b/crates/ui/src/theme/resolve.rs @@ -1,3 +1,5 @@ +use gpui::{WindowBackgroundAppearance, px}; + use crate::theme::definition::ThemeDefinition; use crate::theme::ramps::{AccentShades, Oklch, contrast_foreground, derive_shades, mix}; use crate::theme::system::{SourceKind, SystemTheme}; @@ -5,7 +7,6 @@ use crate::theme::{ ColorTokens, CustomTheme, Elevations, MaterialTokens, Motion, Radius, Scrollbar, SizeTable, Spacing, ThemeVariant, Typography, }; -use gpui::{WindowBackgroundAppearance, px}; /// Derived state shades for the colors that get pressed and hovered. #[derive(Clone, Copy, Debug, PartialEq)] @@ -245,10 +246,11 @@ fn mono_font() -> &'static str { #[cfg(test)] mod tests { + use gpui::{Rgba, WindowBackgroundAppearance, rgb}; + use super::*; use crate::theme::system::{AccessibilityPreferences, SourceKind}; use crate::theme::{Elevation, Shadow}; - use gpui::{Rgba, WindowBackgroundAppearance, rgb}; fn hsla(hex: u32) -> gpui::Hsla { gpui::Hsla::from(rgb(hex)) diff --git a/crates/ui/src/theme/source/linux.rs b/crates/ui/src/theme/source/linux.rs index 94fc3e5..681351c 100644 --- a/crates/ui/src/theme/source/linux.rs +++ b/crates/ui/src/theme/source/linux.rs @@ -8,14 +8,9 @@ use std::path::{Path, PathBuf}; use gpui::Hsla; use notify::{RecursiveMode, Watcher}; -use super::ThemeSource; -use super::kde; -use super::omarchy; -use super::portal; use super::signal::ReapplySignal; - +use super::{ThemeSource, kde, omarchy, portal}; use crate::theme::ThemeVariant; - use crate::theme::system::{SourceKind, SystemTheme}; pub(crate) struct LinuxSource { diff --git a/crates/ui/src/theme/source/macos.rs b/crates/ui/src/theme/source/macos.rs index 4697c29..52e489d 100644 --- a/crates/ui/src/theme/source/macos.rs +++ b/crates/ui/src/theme/source/macos.rs @@ -13,10 +13,8 @@ use objc2_foundation::{ NSNotificationName, NSObjectNSKeyValueObserverRegistration, NSString, NSUserDefaults, }; -use super::narrow_component; - -use super::ThemeSource; use super::signal::ReapplySignal; +use super::{ThemeSource, narrow_component}; use crate::theme::ThemeVariant; use crate::theme::system::{AccessibilityPreferences, SourceKind, SystemTheme}; diff --git a/crates/ui/src/theme/source/portal.rs b/crates/ui/src/theme/source/portal.rs index 1b7b14a..7ac3cdd 100644 --- a/crates/ui/src/theme/source/portal.rs +++ b/crates/ui/src/theme/source/portal.rs @@ -6,8 +6,8 @@ use gpui::Hsla; use super::narrow_component; - -use crate::theme::{ThemeVariant, system::AccessibilityPreferences}; +use crate::theme::ThemeVariant; +use crate::theme::system::AccessibilityPreferences; /// The raw portal values, already converted off the DBus wire types. #[derive(Clone, Copy, Debug, Default, PartialEq)] diff --git a/crates/ui/src/utils.rs b/crates/ui/src/utils.rs index c244aab..4a53bd4 100644 --- a/crates/ui/src/utils.rs +++ b/crates/ui/src/utils.rs @@ -1,11 +1,13 @@ -use crate::theme::{ActiveTheme as _, FOCUS_RING_ALPHA, FOCUS_RING_SPREAD}; +use std::collections::HashMap; + use gpui::prelude::FluentBuilder as _; use gpui::{ App, Bounds, BoxShadow, Div, ElementId, FocusHandle, Global, Hsla, IntoElement, Pixels, Refineable as _, StatefulInteractiveElement, StyleRefinement, Styled, Window, WindowId, div, px, }; -use std::collections::HashMap; + +use crate::theme::{ActiveTheme as _, FOCUS_RING_ALPHA, FOCUS_RING_SPREAD}; /// A row whose children center on the cross axis. #[must_use]