mirror of
https://github.com/zed-industries/zed.git
synced 2026-06-01 03:14:56 +07:00
Group more elements under workspace theme struct
Co-Authored-By: Max Brunsfeld <maxbrunsfeld@gmail.com>
This commit is contained in:
parent
e69d1f9a9b
commit
621203eb60
4 changed files with 24 additions and 24 deletions
|
|
@ -1,25 +1,25 @@
|
|||
[workspace]
|
||||
background = "$surface.0"
|
||||
|
||||
[tab]
|
||||
[workspace.tab]
|
||||
text = "$text.2"
|
||||
padding = { left = 10, right = 10 }
|
||||
icon_close = "$text.0"
|
||||
icon_dirty = "$status.info"
|
||||
icon_conflict = "$status.warn"
|
||||
|
||||
[active_tab]
|
||||
[workspace.active_tab]
|
||||
extends = "$tab"
|
||||
background = "$surface.1"
|
||||
text = "$text.0"
|
||||
|
||||
[sidebar]
|
||||
[workspace.sidebar]
|
||||
padding = { left = 10, right = 10 }
|
||||
|
||||
[sidebar_icon]
|
||||
[workspace.sidebar_icon]
|
||||
color = "$text.2"
|
||||
|
||||
[active_sidebar_icon]
|
||||
[workspace.active_sidebar_icon]
|
||||
color = "$text.0"
|
||||
|
||||
[selector]
|
||||
|
|
|
|||
|
|
@ -20,11 +20,6 @@ pub struct Theme {
|
|||
#[serde(default)]
|
||||
pub name: String,
|
||||
pub workspace: Workspace,
|
||||
pub tab: Tab,
|
||||
pub active_tab: Tab,
|
||||
pub sidebar: ContainerStyle,
|
||||
pub sidebar_icon: SidebarIcon,
|
||||
pub active_sidebar_icon: SidebarIcon,
|
||||
pub selector: Selector,
|
||||
pub editor: Editor,
|
||||
#[serde(deserialize_with = "deserialize_syntax_theme")]
|
||||
|
|
@ -34,6 +29,11 @@ pub struct Theme {
|
|||
#[derive(Debug, Default, Deserialize)]
|
||||
pub struct Workspace {
|
||||
pub background: Color,
|
||||
pub tab: Tab,
|
||||
pub active_tab: Tab,
|
||||
pub sidebar: ContainerStyle,
|
||||
pub sidebar_icon: SidebarIcon,
|
||||
pub active_sidebar_icon: SidebarIcon,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
|
|
|
|||
|
|
@ -189,7 +189,7 @@ impl Pane {
|
|||
let is_active = ix == self.active_item;
|
||||
|
||||
enum Tab {}
|
||||
let border = &theme.tab.container.border;
|
||||
let border = &theme.workspace.tab.container.border;
|
||||
|
||||
row.add_child(
|
||||
Expanded::new(
|
||||
|
|
@ -212,9 +212,9 @@ impl Pane {
|
|||
settings.ui_font_size,
|
||||
)
|
||||
.with_style(if is_active {
|
||||
&theme.active_tab.label
|
||||
&theme.workspace.active_tab.label
|
||||
} else {
|
||||
&theme.tab.label
|
||||
&theme.workspace.tab.label
|
||||
})
|
||||
.boxed(),
|
||||
)
|
||||
|
|
@ -236,9 +236,9 @@ impl Pane {
|
|||
.boxed(),
|
||||
)
|
||||
.with_style(if is_active {
|
||||
&theme.active_tab.container
|
||||
&theme.workspace.active_tab.container
|
||||
} else {
|
||||
&theme.tab.container
|
||||
&theme.workspace.tab.container
|
||||
})
|
||||
.with_border(border);
|
||||
|
||||
|
|
@ -267,7 +267,7 @@ impl Pane {
|
|||
// Ensure there's always a minimum amount of space after the last tab,
|
||||
// so that the tab's border doesn't abut the window's border.
|
||||
let mut border = Border::bottom(1.0, Color::default());
|
||||
border.color = theme.tab.container.border.color;
|
||||
border.color = theme.workspace.tab.container.border.color;
|
||||
|
||||
row.add_child(
|
||||
ConstrainedBox::new(
|
||||
|
|
@ -305,19 +305,19 @@ impl Pane {
|
|||
) -> ElementBox {
|
||||
enum TabCloseButton {}
|
||||
|
||||
let mut clicked_color = theme.tab.icon_dirty;
|
||||
let mut clicked_color = theme.workspace.tab.icon_dirty;
|
||||
clicked_color.a = 180;
|
||||
|
||||
let current_color = if has_conflict {
|
||||
Some(theme.tab.icon_conflict)
|
||||
Some(theme.workspace.tab.icon_conflict)
|
||||
} else if is_dirty {
|
||||
Some(theme.tab.icon_dirty)
|
||||
Some(theme.workspace.tab.icon_dirty)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
let icon = if tab_hovered {
|
||||
let close_color = current_color.unwrap_or(theme.tab.icon_close);
|
||||
let close_color = current_color.unwrap_or(theme.workspace.tab.icon_close);
|
||||
let icon = Svg::new("icons/x.svg").with_color(close_color);
|
||||
|
||||
MouseEventHandler::new::<TabCloseButton, _>(item_id, cx, |mouse_state| {
|
||||
|
|
@ -326,7 +326,7 @@ impl Pane {
|
|||
.with_background_color(if mouse_state.clicked {
|
||||
clicked_color
|
||||
} else {
|
||||
theme.tab.icon_dirty
|
||||
theme.workspace.tab.icon_dirty
|
||||
})
|
||||
.with_corner_radius(close_icon_size / 2.)
|
||||
.boxed()
|
||||
|
|
|
|||
|
|
@ -70,9 +70,9 @@ impl Sidebar {
|
|||
Flex::column()
|
||||
.with_children(self.items.iter().enumerate().map(|(item_index, item)| {
|
||||
let theme = if Some(item_index) == self.active_item_ix {
|
||||
&settings.theme.active_sidebar_icon
|
||||
&settings.theme.workspace.active_sidebar_icon
|
||||
} else {
|
||||
&settings.theme.sidebar_icon
|
||||
&settings.theme.workspace.sidebar_icon
|
||||
};
|
||||
enum SidebarButton {}
|
||||
MouseEventHandler::new::<SidebarButton, _>(item.view.id(), cx, |_| {
|
||||
|
|
@ -96,7 +96,7 @@ impl Sidebar {
|
|||
}))
|
||||
.boxed(),
|
||||
)
|
||||
.with_style(&settings.theme.sidebar)
|
||||
.with_style(&settings.theme.workspace.sidebar)
|
||||
.boxed()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue