zed/crates/theme/src/lib.rs

233 lines
5.5 KiB
Rust
Raw Normal View History

mod resolution;
mod theme_registry;
use editor::{EditorStyle, SelectionStyle};
use gpui::{
color::Color,
elements::{ContainerStyle, ImageStyle, LabelStyle},
2021-10-04 14:50:12 +00:00
fonts::TextStyle,
Border,
};
use serde::Deserialize;
pub use theme_registry::*;
pub const DEFAULT_THEME_NAME: &'static str = "black";
#[derive(Deserialize)]
pub struct Theme {
#[serde(default)]
pub name: String,
pub workspace: Workspace,
pub chat_panel: ChatPanel,
pub people_panel: PeoplePanel,
2021-09-24 01:14:15 +00:00
pub project_panel: ProjectPanel,
pub selector: Selector,
2021-09-02 00:13:48 +00:00
pub editor: EditorStyle,
}
#[derive(Deserialize)]
pub struct Workspace {
pub background: Color,
pub titlebar: Titlebar,
pub tab: Tab,
pub active_tab: Tab,
pub pane_divider: Border,
pub left_sidebar: Sidebar,
pub right_sidebar: Sidebar,
}
#[derive(Clone, Deserialize)]
pub struct Titlebar {
#[serde(flatten)]
pub container: ContainerStyle,
pub title: TextStyle,
pub avatar_width: f32,
pub offline_icon: OfflineIcon,
pub icon_color: Color,
pub avatar: ImageStyle,
pub outdated_warning: ContainedText,
}
#[derive(Clone, Deserialize)]
pub struct OfflineIcon {
#[serde(flatten)]
pub container: ContainerStyle,
pub width: f32,
}
#[derive(Clone, Deserialize)]
pub struct Tab {
pub height: f32,
#[serde(flatten)]
pub container: ContainerStyle,
#[serde(flatten)]
pub label: LabelStyle,
pub spacing: f32,
pub icon_width: f32,
pub icon_close: Color,
pub icon_close_active: Color,
pub icon_dirty: Color,
pub icon_conflict: Color,
}
2021-08-27 12:57:47 +00:00
#[derive(Deserialize)]
pub struct Sidebar {
#[serde(flatten)]
pub container: ContainerStyle,
pub width: f32,
pub item: SidebarItem,
pub active_item: SidebarItem,
2021-08-27 12:57:47 +00:00
pub resize_handle: ContainerStyle,
}
#[derive(Deserialize)]
pub struct SidebarItem {
pub icon_color: Color,
pub icon_size: f32,
pub height: f32,
}
#[derive(Deserialize)]
pub struct ChatPanel {
2021-08-25 22:22:14 +00:00
#[serde(flatten)]
pub container: ContainerStyle,
pub message: ChatMessage,
2021-09-15 13:12:16 +00:00
pub pending_message: ChatMessage,
pub channel_select: ChannelSelect,
pub input_editor: InputEditorStyle,
pub sign_in_prompt: TextStyle,
pub hovered_sign_in_prompt: TextStyle,
}
#[derive(Debug, Deserialize)]
2021-09-24 01:14:15 +00:00
pub struct ProjectPanel {
#[serde(flatten)]
pub container: ContainerStyle,
pub entry: ProjectPanelEntry,
pub hovered_entry: ProjectPanelEntry,
pub selected_entry: ProjectPanelEntry,
pub hovered_selected_entry: ProjectPanelEntry,
}
#[derive(Debug, Deserialize)]
pub struct ProjectPanelEntry {
pub height: f32,
#[serde(flatten)]
pub container: ContainerStyle,
pub text: TextStyle,
pub icon_color: Color,
pub icon_size: f32,
pub icon_spacing: f32,
2021-09-24 01:14:15 +00:00
}
#[derive(Deserialize)]
pub struct PeoplePanel {
#[serde(flatten)]
pub container: ContainerStyle,
pub host_row_height: f32,
pub host_avatar: ImageStyle,
pub host_username: ContainedText,
pub tree_branch_width: f32,
pub tree_branch_color: Color,
pub shared_worktree: WorktreeRow,
pub hovered_shared_worktree: WorktreeRow,
pub unshared_worktree: WorktreeRow,
pub hovered_unshared_worktree: WorktreeRow,
}
#[derive(Deserialize)]
pub struct WorktreeRow {
#[serde(flatten)]
pub container: ContainerStyle,
pub height: f32,
pub name: ContainedText,
pub guest_avatar: ImageStyle,
pub guest_avatar_spacing: f32,
}
#[derive(Deserialize)]
pub struct ChatMessage {
#[serde(flatten)]
pub container: ContainerStyle,
pub body: TextStyle,
pub sender: ContainedText,
pub timestamp: ContainedText,
}
#[derive(Deserialize)]
pub struct ChannelSelect {
#[serde(flatten)]
pub container: ContainerStyle,
pub header: ChannelName,
pub item: ChannelName,
pub active_item: ChannelName,
pub hovered_item: ChannelName,
pub hovered_active_item: ChannelName,
pub menu: ContainerStyle,
}
#[derive(Deserialize)]
pub struct ChannelName {
#[serde(flatten)]
pub container: ContainerStyle,
pub hash: ContainedText,
pub name: TextStyle,
}
#[derive(Deserialize)]
pub struct Selector {
#[serde(flatten)]
pub container: ContainerStyle,
pub empty: ContainedLabel,
pub input_editor: InputEditorStyle,
2021-08-25 22:22:14 +00:00
pub item: ContainedLabel,
pub active_item: ContainedLabel,
}
#[derive(Clone, Debug, Deserialize)]
pub struct ContainedText {
#[serde(flatten)]
pub container: ContainerStyle,
#[serde(flatten)]
pub text: TextStyle,
}
#[derive(Deserialize)]
2021-08-25 22:22:14 +00:00
pub struct ContainedLabel {
#[serde(flatten)]
pub container: ContainerStyle,
#[serde(flatten)]
pub label: LabelStyle,
}
#[derive(Clone, Deserialize)]
pub struct InputEditorStyle {
#[serde(flatten)]
pub container: ContainerStyle,
2021-09-16 20:12:38 +00:00
pub text: TextStyle,
2021-09-16 19:23:42 +00:00
#[serde(default)]
2021-09-16 20:12:38 +00:00
pub placeholder_text: Option<TextStyle>,
pub selection: SelectionStyle,
}
impl InputEditorStyle {
pub fn as_editor(&self) -> EditorStyle {
EditorStyle {
text: self.text.clone(),
placeholder_text: self.placeholder_text.clone(),
background: self
.container
.background_color
.unwrap_or(Color::transparent_black()),
selection: self.selection,
2021-09-16 20:12:38 +00:00
gutter_background: Default::default(),
active_line_background: Default::default(),
line_number: Default::default(),
line_number_active: Default::default(),
guest_selections: Default::default(),
syntax: Default::default(),
2021-09-02 00:13:48 +00:00
}
}
}