2021-08-24 23:33:56 +00:00
|
|
|
mod theme_registry;
|
|
|
|
|
2021-08-04 00:51:06 +00:00
|
|
|
use gpui::{
|
|
|
|
color::Color,
|
2022-04-28 22:17:56 +00:00
|
|
|
elements::{ContainerStyle, ImageStyle, LabelStyle, MouseState},
|
2021-10-05 17:21:13 +00:00
|
|
|
fonts::{HighlightStyle, TextStyle},
|
2021-09-07 22:04:29 +00:00
|
|
|
Border,
|
2021-08-04 00:51:06 +00:00
|
|
|
};
|
2022-04-28 17:59:32 +00:00
|
|
|
use serde::{de::DeserializeOwned, Deserialize};
|
|
|
|
use serde_json::Value;
|
2021-10-05 17:21:13 +00:00
|
|
|
use std::{collections::HashMap, sync::Arc};
|
2021-08-04 01:42:39 +00:00
|
|
|
|
2021-08-24 23:33:56 +00:00
|
|
|
pub use theme_registry::*;
|
2021-08-04 01:42:39 +00:00
|
|
|
|
2022-04-01 17:45:08 +00:00
|
|
|
pub const DEFAULT_THEME_NAME: &'static str = "dark";
|
2021-08-04 01:42:39 +00:00
|
|
|
|
2021-10-05 11:45:19 +00:00
|
|
|
#[derive(Deserialize, Default)]
|
2021-08-03 20:36:58 +00:00
|
|
|
pub struct Theme {
|
2021-08-04 21:16:28 +00:00
|
|
|
#[serde(default)]
|
|
|
|
pub name: String,
|
2021-08-20 16:44:34 +00:00
|
|
|
pub workspace: Workspace,
|
2021-08-24 23:46:23 +00:00
|
|
|
pub chat_panel: ChatPanel,
|
2021-11-26 18:13:05 +00:00
|
|
|
pub contacts_panel: ContactsPanel,
|
2022-05-10 13:24:14 +00:00
|
|
|
pub contact_finder: ContactFinder,
|
2021-09-24 01:14:15 +00:00
|
|
|
pub project_panel: ProjectPanel,
|
2022-04-14 23:04:32 +00:00
|
|
|
pub command_palette: CommandPalette,
|
2022-04-28 21:45:32 +00:00
|
|
|
pub picker: Picker,
|
2022-02-24 23:27:11 +00:00
|
|
|
pub editor: Editor,
|
2022-02-27 15:15:38 +00:00
|
|
|
pub search: Search,
|
2022-01-05 16:25:03 +00:00
|
|
|
pub project_diagnostics: ProjectDiagnostics,
|
2022-03-31 17:44:16 +00:00
|
|
|
pub breadcrumbs: ContainedText,
|
2022-05-11 13:13:37 +00:00
|
|
|
pub incoming_request_notification: IncomingRequestNotification,
|
2021-08-03 20:36:58 +00:00
|
|
|
}
|
|
|
|
|
2021-10-05 11:45:19 +00:00
|
|
|
#[derive(Deserialize, Default)]
|
2021-08-20 16:44:34 +00:00
|
|
|
pub struct Workspace {
|
2021-08-03 20:36:58 +00:00
|
|
|
pub background: Color,
|
2021-09-14 16:53:41 +00:00
|
|
|
pub titlebar: Titlebar,
|
2021-08-24 23:38:26 +00:00
|
|
|
pub tab: Tab,
|
|
|
|
pub active_tab: Tab,
|
2021-09-07 22:04:29 +00:00
|
|
|
pub pane_divider: Border,
|
2022-03-21 22:12:15 +00:00
|
|
|
pub leader_border_opacity: f32,
|
2022-03-22 18:43:30 +00:00
|
|
|
pub leader_border_width: f32,
|
2022-04-26 20:10:40 +00:00
|
|
|
pub sidebar_resize_handle: ContainerStyle,
|
2021-11-03 16:27:51 +00:00
|
|
|
pub status_bar: StatusBar,
|
2022-01-31 10:00:29 +00:00
|
|
|
pub toolbar: Toolbar,
|
2022-03-04 16:28:18 +00:00
|
|
|
pub disconnected_overlay: ContainedText,
|
2022-04-22 16:54:09 +00:00
|
|
|
pub modal: ContainerStyle,
|
2022-05-10 23:46:46 +00:00
|
|
|
pub notification: ContainerStyle,
|
|
|
|
pub notifications: Notifications,
|
2021-08-03 20:36:58 +00:00
|
|
|
}
|
|
|
|
|
2021-10-05 11:45:19 +00:00
|
|
|
#[derive(Clone, Deserialize, Default)]
|
2021-09-14 16:53:41 +00:00
|
|
|
pub struct Titlebar {
|
|
|
|
#[serde(flatten)]
|
|
|
|
pub container: ContainerStyle,
|
2021-11-28 19:41:46 +00:00
|
|
|
pub height: f32,
|
2021-09-14 16:53:41 +00:00
|
|
|
pub title: TextStyle,
|
2021-09-14 22:59:38 +00:00
|
|
|
pub avatar_width: f32,
|
2022-05-03 16:04:53 +00:00
|
|
|
pub avatar_margin: f32,
|
2021-11-28 20:25:05 +00:00
|
|
|
pub avatar_ribbon: AvatarRibbon,
|
2021-09-14 23:47:43 +00:00
|
|
|
pub offline_icon: OfflineIcon,
|
2022-04-28 19:08:15 +00:00
|
|
|
pub share_icon: Interactive<ShareIcon>,
|
2021-09-14 22:59:38 +00:00
|
|
|
pub avatar: ImageStyle,
|
2022-04-28 19:08:15 +00:00
|
|
|
pub sign_in_prompt: Interactive<ContainedText>,
|
2021-09-23 13:36:32 +00:00
|
|
|
pub outdated_warning: ContainedText,
|
2021-09-14 16:53:41 +00:00
|
|
|
}
|
|
|
|
|
2021-11-28 20:25:05 +00:00
|
|
|
#[derive(Clone, Deserialize, Default)]
|
|
|
|
pub struct AvatarRibbon {
|
|
|
|
#[serde(flatten)]
|
|
|
|
pub container: ContainerStyle,
|
|
|
|
pub width: f32,
|
|
|
|
pub height: f32,
|
|
|
|
}
|
|
|
|
|
2021-10-05 11:45:19 +00:00
|
|
|
#[derive(Clone, Deserialize, Default)]
|
2021-09-14 23:47:43 +00:00
|
|
|
pub struct OfflineIcon {
|
|
|
|
#[serde(flatten)]
|
|
|
|
pub container: ContainerStyle,
|
|
|
|
pub width: f32,
|
2022-01-10 19:26:07 +00:00
|
|
|
pub color: Color,
|
2021-09-14 23:47:43 +00:00
|
|
|
}
|
|
|
|
|
2022-04-26 12:35:13 +00:00
|
|
|
#[derive(Clone, Deserialize, Default)]
|
|
|
|
pub struct ShareIcon {
|
|
|
|
#[serde(flatten)]
|
|
|
|
pub container: ContainerStyle,
|
|
|
|
pub color: Color,
|
|
|
|
}
|
|
|
|
|
2021-10-05 11:45:19 +00:00
|
|
|
#[derive(Clone, Deserialize, Default)]
|
2021-08-03 20:36:58 +00:00
|
|
|
pub struct Tab {
|
2021-09-30 20:30:24 +00:00
|
|
|
pub height: f32,
|
2021-08-03 20:36:58 +00:00
|
|
|
#[serde(flatten)]
|
|
|
|
pub container: ContainerStyle,
|
|
|
|
#[serde(flatten)]
|
|
|
|
pub label: LabelStyle,
|
2021-09-07 21:28:14 +00:00
|
|
|
pub spacing: f32,
|
|
|
|
pub icon_width: f32,
|
2021-08-03 20:36:58 +00:00
|
|
|
pub icon_close: Color,
|
2021-09-07 21:28:14 +00:00
|
|
|
pub icon_close_active: Color,
|
2021-08-03 20:36:58 +00:00
|
|
|
pub icon_dirty: Color,
|
|
|
|
pub icon_conflict: Color,
|
|
|
|
}
|
|
|
|
|
2022-01-31 10:00:29 +00:00
|
|
|
#[derive(Clone, Deserialize, Default)]
|
|
|
|
pub struct Toolbar {
|
2022-03-29 09:48:21 +00:00
|
|
|
#[serde(flatten)]
|
|
|
|
pub container: ContainerStyle,
|
2022-01-31 10:00:29 +00:00
|
|
|
pub height: f32,
|
2022-03-29 09:48:21 +00:00
|
|
|
pub item_spacing: f32,
|
2022-01-31 10:00:29 +00:00
|
|
|
}
|
|
|
|
|
2022-05-10 23:46:46 +00:00
|
|
|
#[derive(Clone, Deserialize, Default)]
|
|
|
|
pub struct Notifications {
|
|
|
|
#[serde(flatten)]
|
|
|
|
pub container: ContainerStyle,
|
|
|
|
pub width: f32,
|
|
|
|
}
|
|
|
|
|
2022-01-27 23:19:52 +00:00
|
|
|
#[derive(Clone, Deserialize, Default)]
|
2022-02-27 15:15:38 +00:00
|
|
|
pub struct Search {
|
2022-01-28 01:59:44 +00:00
|
|
|
#[serde(flatten)]
|
|
|
|
pub container: ContainerStyle,
|
2022-03-30 11:35:17 +00:00
|
|
|
pub editor: FindEditor,
|
2022-01-28 15:15:18 +00:00
|
|
|
pub invalid_editor: ContainerStyle,
|
2022-02-25 09:27:45 +00:00
|
|
|
pub option_button_group: ContainerStyle,
|
2022-04-28 22:29:03 +00:00
|
|
|
pub option_button: Interactive<ContainedText>,
|
2022-01-27 23:19:52 +00:00
|
|
|
pub match_background: Color,
|
2022-01-29 13:38:58 +00:00
|
|
|
pub match_index: ContainedText,
|
2022-02-25 14:27:34 +00:00
|
|
|
pub results_status: TextStyle,
|
2022-02-26 15:21:38 +00:00
|
|
|
pub tab_icon_width: f32,
|
|
|
|
pub tab_icon_spacing: f32,
|
2022-01-27 23:19:52 +00:00
|
|
|
}
|
|
|
|
|
2022-03-30 11:35:17 +00:00
|
|
|
#[derive(Clone, Deserialize, Default)]
|
|
|
|
pub struct FindEditor {
|
|
|
|
#[serde(flatten)]
|
|
|
|
pub input: FieldEditor,
|
2022-03-31 17:44:16 +00:00
|
|
|
pub min_width: f32,
|
2022-03-30 11:35:17 +00:00
|
|
|
pub max_width: f32,
|
|
|
|
}
|
|
|
|
|
2021-11-03 16:27:51 +00:00
|
|
|
#[derive(Deserialize, Default)]
|
|
|
|
pub struct StatusBar {
|
|
|
|
#[serde(flatten)]
|
|
|
|
pub container: ContainerStyle,
|
|
|
|
pub height: f32,
|
2022-01-25 23:33:49 +00:00
|
|
|
pub item_spacing: f32,
|
2021-11-03 16:27:51 +00:00
|
|
|
pub cursor_position: TextStyle,
|
2022-04-04 21:57:21 +00:00
|
|
|
pub auto_update_progress_message: TextStyle,
|
|
|
|
pub auto_update_done_message: TextStyle,
|
2022-04-28 17:59:32 +00:00
|
|
|
pub lsp_status: Interactive<StatusBarLspStatus>,
|
2022-04-27 19:14:34 +00:00
|
|
|
pub sidebar_buttons: StatusBarSidebarButtons,
|
2022-04-28 19:35:20 +00:00
|
|
|
pub diagnostic_summary: Interactive<StatusBarDiagnosticSummary>,
|
|
|
|
pub diagnostic_message: Interactive<ContainedText>,
|
2022-04-27 19:14:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Deserialize, Default)]
|
|
|
|
pub struct StatusBarSidebarButtons {
|
|
|
|
pub group_left: ContainerStyle,
|
|
|
|
pub group_right: ContainerStyle,
|
2022-04-28 17:59:32 +00:00
|
|
|
pub item: Interactive<SidebarItem>,
|
2022-04-27 19:14:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Deserialize, Default)]
|
2022-04-28 19:35:20 +00:00
|
|
|
pub struct StatusBarDiagnosticSummary {
|
|
|
|
pub container_ok: ContainerStyle,
|
|
|
|
pub container_warning: ContainerStyle,
|
|
|
|
pub container_error: ContainerStyle,
|
|
|
|
pub text: TextStyle,
|
2022-04-27 19:14:34 +00:00
|
|
|
pub icon_color_ok: Color,
|
|
|
|
pub icon_color_warning: Color,
|
2022-04-28 19:35:20 +00:00
|
|
|
pub icon_color_error: Color,
|
2022-04-27 19:14:34 +00:00
|
|
|
pub height: f32,
|
|
|
|
pub icon_width: f32,
|
|
|
|
pub icon_spacing: f32,
|
|
|
|
pub summary_spacing: f32,
|
2021-11-03 16:27:51 +00:00
|
|
|
}
|
|
|
|
|
2022-04-27 23:48:33 +00:00
|
|
|
#[derive(Deserialize, Default)]
|
|
|
|
pub struct StatusBarLspStatus {
|
|
|
|
#[serde(flatten)]
|
|
|
|
pub container: ContainerStyle,
|
|
|
|
pub height: f32,
|
|
|
|
pub icon_spacing: f32,
|
|
|
|
pub icon_color: Color,
|
|
|
|
pub icon_width: f32,
|
|
|
|
pub message: TextStyle,
|
|
|
|
}
|
|
|
|
|
2022-04-27 16:38:31 +00:00
|
|
|
#[derive(Deserialize, Default)]
|
|
|
|
pub struct Sidebar {
|
|
|
|
pub resize_handle: ContainerStyle,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Clone, Copy, Deserialize, Default)]
|
|
|
|
pub struct SidebarItem {
|
|
|
|
#[serde(flatten)]
|
|
|
|
pub container: ContainerStyle,
|
|
|
|
pub icon_color: Color,
|
|
|
|
pub icon_size: f32,
|
|
|
|
}
|
|
|
|
|
2021-10-05 11:45:19 +00:00
|
|
|
#[derive(Deserialize, Default)]
|
2021-08-24 23:46:23 +00:00
|
|
|
pub struct ChatPanel {
|
2021-08-25 22:22:14 +00:00
|
|
|
#[serde(flatten)]
|
|
|
|
pub container: ContainerStyle,
|
2021-08-24 23:46:23 +00:00
|
|
|
pub message: ChatMessage,
|
2021-09-15 13:12:16 +00:00
|
|
|
pub pending_message: ChatMessage,
|
2021-08-31 00:59:13 +00:00
|
|
|
pub channel_select: ChannelSelect,
|
2022-02-24 23:27:11 +00:00
|
|
|
pub input_editor: FieldEditor,
|
2021-09-07 10:27:43 +00:00
|
|
|
pub sign_in_prompt: TextStyle,
|
|
|
|
pub hovered_sign_in_prompt: TextStyle,
|
2021-08-24 23:46:23 +00:00
|
|
|
}
|
|
|
|
|
2022-05-02 20:19:58 +00:00
|
|
|
#[derive(Deserialize, Default)]
|
2021-09-24 01:14:15 +00:00
|
|
|
pub struct ProjectPanel {
|
|
|
|
#[serde(flatten)]
|
|
|
|
pub container: ContainerStyle,
|
2022-04-29 18:08:25 +00:00
|
|
|
pub entry: Interactive<ProjectPanelEntry>,
|
2022-05-02 20:19:58 +00:00
|
|
|
pub filename_editor: FieldEditor,
|
2022-04-29 18:08:25 +00:00
|
|
|
pub indent_width: f32,
|
2021-09-30 17:24:47 +00:00
|
|
|
}
|
|
|
|
|
2021-10-05 11:45:19 +00:00
|
|
|
#[derive(Debug, Deserialize, Default)]
|
2021-09-30 17:24:47 +00:00
|
|
|
pub struct ProjectPanelEntry {
|
2021-09-30 20:30:24 +00:00
|
|
|
pub height: f32,
|
2021-09-30 17:24:47 +00:00
|
|
|
#[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
|
|
|
}
|
|
|
|
|
2022-04-14 23:04:32 +00:00
|
|
|
#[derive(Debug, Deserialize, Default)]
|
|
|
|
pub struct CommandPalette {
|
2022-04-28 22:17:56 +00:00
|
|
|
pub key: Interactive<ContainedLabel>,
|
2022-04-14 23:04:32 +00:00
|
|
|
pub keystroke_spacing: f32,
|
|
|
|
}
|
|
|
|
|
2021-10-05 11:45:19 +00:00
|
|
|
#[derive(Deserialize, Default)]
|
2021-11-26 18:13:05 +00:00
|
|
|
pub struct ContactsPanel {
|
2021-09-20 18:04:48 +00:00
|
|
|
#[serde(flatten)]
|
|
|
|
pub container: ContainerStyle,
|
2022-05-05 21:14:44 +00:00
|
|
|
pub header: ContainedText,
|
2022-05-05 16:24:21 +00:00
|
|
|
pub user_query_editor: FieldEditor,
|
2022-05-10 18:14:31 +00:00
|
|
|
pub user_query_editor_height: f32,
|
2022-05-10 16:25:47 +00:00
|
|
|
pub add_contact_button: IconButton,
|
2022-05-10 18:14:31 +00:00
|
|
|
pub row: ContainerStyle,
|
2022-05-05 21:14:44 +00:00
|
|
|
pub row_height: f32,
|
|
|
|
pub contact_avatar: ImageStyle,
|
|
|
|
pub contact_username: ContainedText,
|
2022-05-10 17:47:25 +00:00
|
|
|
pub contact_button: Interactive<IconButton>,
|
2022-05-10 16:25:47 +00:00
|
|
|
pub disabled_contact_button: IconButton,
|
2021-09-22 15:02:50 +00:00
|
|
|
pub tree_branch_width: f32,
|
|
|
|
pub tree_branch_color: Color,
|
2022-05-05 21:14:44 +00:00
|
|
|
pub shared_project: ProjectRow,
|
|
|
|
pub hovered_shared_project: ProjectRow,
|
|
|
|
pub unshared_project: ProjectRow,
|
|
|
|
pub hovered_unshared_project: ProjectRow,
|
2021-09-21 16:13:02 +00:00
|
|
|
}
|
|
|
|
|
2022-05-10 13:24:14 +00:00
|
|
|
#[derive(Deserialize, Default)]
|
|
|
|
pub struct ContactFinder {
|
|
|
|
pub row_height: f32,
|
|
|
|
pub contact_avatar: ImageStyle,
|
2022-05-10 14:43:51 +00:00
|
|
|
pub contact_username: ContainerStyle,
|
2022-05-10 16:25:47 +00:00
|
|
|
pub contact_button: IconButton,
|
|
|
|
pub disabled_contact_button: IconButton,
|
2022-05-10 13:24:14 +00:00
|
|
|
}
|
|
|
|
|
2022-05-10 10:09:24 +00:00
|
|
|
#[derive(Deserialize, Default)]
|
2022-05-10 16:25:47 +00:00
|
|
|
pub struct IconButton {
|
2022-05-10 10:09:24 +00:00
|
|
|
#[serde(flatten)]
|
|
|
|
pub container: ContainerStyle,
|
|
|
|
pub color: Color,
|
2022-05-10 16:25:47 +00:00
|
|
|
pub icon_width: f32,
|
|
|
|
pub button_width: f32,
|
2022-05-10 10:09:24 +00:00
|
|
|
}
|
|
|
|
|
2021-10-05 11:45:19 +00:00
|
|
|
#[derive(Deserialize, Default)]
|
2022-05-05 21:14:44 +00:00
|
|
|
pub struct ProjectRow {
|
2021-09-22 15:02:50 +00:00
|
|
|
#[serde(flatten)]
|
|
|
|
pub container: ContainerStyle,
|
|
|
|
pub height: f32,
|
|
|
|
pub name: ContainedText,
|
|
|
|
pub guest_avatar: ImageStyle,
|
|
|
|
pub guest_avatar_spacing: f32,
|
2021-09-20 18:04:48 +00:00
|
|
|
}
|
|
|
|
|
2021-10-05 11:45:19 +00:00
|
|
|
#[derive(Deserialize, Default)]
|
2021-08-24 23:46:23 +00:00
|
|
|
pub struct ChatMessage {
|
2021-09-01 23:14:51 +00:00
|
|
|
#[serde(flatten)]
|
|
|
|
pub container: ContainerStyle,
|
2021-08-25 14:42:35 +00:00
|
|
|
pub body: TextStyle,
|
2021-08-31 00:59:13 +00:00
|
|
|
pub sender: ContainedText,
|
|
|
|
pub timestamp: ContainedText,
|
|
|
|
}
|
|
|
|
|
2021-10-05 11:45:19 +00:00
|
|
|
#[derive(Deserialize, Default)]
|
2021-08-31 00:59:13 +00:00
|
|
|
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,
|
|
|
|
}
|
|
|
|
|
2021-10-05 11:45:19 +00:00
|
|
|
#[derive(Deserialize, Default)]
|
2021-08-31 00:59:13 +00:00
|
|
|
pub struct ChannelName {
|
|
|
|
#[serde(flatten)]
|
|
|
|
pub container: ContainerStyle,
|
|
|
|
pub hash: ContainedText,
|
|
|
|
pub name: TextStyle,
|
2021-08-24 23:46:23 +00:00
|
|
|
}
|
|
|
|
|
2021-10-05 11:45:19 +00:00
|
|
|
#[derive(Deserialize, Default)]
|
2022-04-28 21:45:32 +00:00
|
|
|
pub struct Picker {
|
2021-08-03 20:36:58 +00:00
|
|
|
#[serde(flatten)]
|
|
|
|
pub container: ContainerStyle,
|
2021-09-07 21:42:19 +00:00
|
|
|
pub empty: ContainedLabel,
|
2022-02-24 23:27:11 +00:00
|
|
|
pub input_editor: FieldEditor,
|
2022-04-28 22:17:56 +00:00
|
|
|
pub item: Interactive<ContainedLabel>,
|
2021-08-03 20:36:58 +00:00
|
|
|
}
|
|
|
|
|
2021-10-05 11:45:19 +00:00
|
|
|
#[derive(Clone, Debug, Deserialize, Default)]
|
2021-08-31 00:59:13 +00:00
|
|
|
pub struct ContainedText {
|
|
|
|
#[serde(flatten)]
|
|
|
|
pub container: ContainerStyle,
|
|
|
|
#[serde(flatten)]
|
|
|
|
pub text: TextStyle,
|
|
|
|
}
|
|
|
|
|
2022-04-14 23:04:32 +00:00
|
|
|
#[derive(Clone, Debug, Deserialize, Default)]
|
2021-08-25 22:22:14 +00:00
|
|
|
pub struct ContainedLabel {
|
2021-08-03 20:36:58 +00:00
|
|
|
#[serde(flatten)]
|
|
|
|
pub container: ContainerStyle,
|
|
|
|
#[serde(flatten)]
|
|
|
|
pub label: LabelStyle,
|
|
|
|
}
|
|
|
|
|
2022-01-05 16:25:03 +00:00
|
|
|
#[derive(Clone, Deserialize, Default)]
|
|
|
|
pub struct ProjectDiagnostics {
|
|
|
|
#[serde(flatten)]
|
|
|
|
pub container: ContainerStyle,
|
|
|
|
pub empty_message: TextStyle,
|
2022-01-12 01:23:11 +00:00
|
|
|
pub tab_icon_width: f32,
|
|
|
|
pub tab_icon_spacing: f32,
|
|
|
|
pub tab_summary_spacing: f32,
|
2022-01-05 16:25:03 +00:00
|
|
|
}
|
|
|
|
|
2022-05-11 13:13:37 +00:00
|
|
|
#[derive(Deserialize, Default)]
|
|
|
|
pub struct IncomingRequestNotification {
|
|
|
|
pub header_avatar: ImageStyle,
|
|
|
|
pub header_message: ContainedText,
|
|
|
|
pub header_height: f32,
|
|
|
|
pub body_message: ContainedText,
|
|
|
|
pub button: ContainedText,
|
|
|
|
pub dismiss_button: IconButton,
|
|
|
|
}
|
|
|
|
|
2021-10-05 17:21:13 +00:00
|
|
|
#[derive(Clone, Deserialize, Default)]
|
2022-02-24 23:27:11 +00:00
|
|
|
pub struct Editor {
|
|
|
|
pub text_color: Color,
|
2021-10-05 17:21:13 +00:00
|
|
|
#[serde(default)]
|
|
|
|
pub background: Color,
|
|
|
|
pub selection: SelectionStyle,
|
|
|
|
pub gutter_background: Color,
|
2022-01-25 19:40:53 +00:00
|
|
|
pub gutter_padding_factor: f32,
|
2021-10-05 17:21:13 +00:00
|
|
|
pub active_line_background: Color,
|
2021-11-24 22:23:45 +00:00
|
|
|
pub highlighted_line_background: Color,
|
2022-03-10 21:55:31 +00:00
|
|
|
pub rename_fade: f32,
|
2022-02-23 01:05:55 +00:00
|
|
|
pub document_highlight_read_background: Color,
|
|
|
|
pub document_highlight_write_background: Color,
|
2022-02-18 21:15:22 +00:00
|
|
|
pub diff_background_deleted: Color,
|
|
|
|
pub diff_background_inserted: Color,
|
2021-10-05 17:21:13 +00:00
|
|
|
pub line_number: Color,
|
|
|
|
pub line_number_active: Color,
|
|
|
|
pub guest_selections: Vec<SelectionStyle>,
|
|
|
|
pub syntax: Arc<SyntaxTheme>,
|
2022-01-25 11:23:24 +00:00
|
|
|
pub diagnostic_path_header: DiagnosticPathHeader,
|
|
|
|
pub diagnostic_header: DiagnosticHeader,
|
2021-11-19 13:35:00 +00:00
|
|
|
pub error_diagnostic: DiagnosticStyle,
|
|
|
|
pub invalid_error_diagnostic: DiagnosticStyle,
|
|
|
|
pub warning_diagnostic: DiagnosticStyle,
|
|
|
|
pub invalid_warning_diagnostic: DiagnosticStyle,
|
|
|
|
pub information_diagnostic: DiagnosticStyle,
|
|
|
|
pub invalid_information_diagnostic: DiagnosticStyle,
|
|
|
|
pub hint_diagnostic: DiagnosticStyle,
|
|
|
|
pub invalid_hint_diagnostic: DiagnosticStyle,
|
2022-01-31 21:01:20 +00:00
|
|
|
pub autocomplete: AutocompleteStyle,
|
2022-02-11 15:01:15 +00:00
|
|
|
pub code_actions_indicator: Color,
|
2022-03-15 14:51:59 +00:00
|
|
|
pub unnecessary_code_fade: f32,
|
2021-11-19 02:16:35 +00:00
|
|
|
}
|
|
|
|
|
2022-01-25 11:23:24 +00:00
|
|
|
#[derive(Clone, Deserialize, Default)]
|
|
|
|
pub struct DiagnosticPathHeader {
|
|
|
|
#[serde(flatten)]
|
|
|
|
pub container: ContainerStyle,
|
|
|
|
pub filename: ContainedText,
|
|
|
|
pub path: ContainedText,
|
2022-01-25 20:10:11 +00:00
|
|
|
pub text_scale_factor: f32,
|
2022-01-25 11:23:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Clone, Deserialize, Default)]
|
|
|
|
pub struct DiagnosticHeader {
|
|
|
|
#[serde(flatten)]
|
|
|
|
pub container: ContainerStyle,
|
2022-01-25 14:46:33 +00:00
|
|
|
pub message: ContainedLabel,
|
2022-01-25 14:23:58 +00:00
|
|
|
pub code: ContainedText,
|
2022-01-25 20:10:11 +00:00
|
|
|
pub text_scale_factor: f32,
|
2022-01-25 19:40:53 +00:00
|
|
|
pub icon_width_factor: f32,
|
2022-01-25 11:23:24 +00:00
|
|
|
}
|
|
|
|
|
2022-01-25 16:07:12 +00:00
|
|
|
#[derive(Clone, Deserialize, Default)]
|
2021-11-19 02:16:35 +00:00
|
|
|
pub struct DiagnosticStyle {
|
2022-01-25 16:07:12 +00:00
|
|
|
pub message: LabelStyle,
|
2022-01-07 01:55:56 +00:00
|
|
|
#[serde(default)]
|
|
|
|
pub header: ContainerStyle,
|
2022-01-25 20:10:11 +00:00
|
|
|
pub text_scale_factor: f32,
|
2021-10-05 17:21:13 +00:00
|
|
|
}
|
|
|
|
|
2022-01-31 21:01:20 +00:00
|
|
|
#[derive(Clone, Deserialize, Default)]
|
|
|
|
pub struct AutocompleteStyle {
|
|
|
|
#[serde(flatten)]
|
|
|
|
pub container: ContainerStyle,
|
|
|
|
pub item: ContainerStyle,
|
2022-01-31 21:25:46 +00:00
|
|
|
pub selected_item: ContainerStyle,
|
2022-02-03 10:39:19 +00:00
|
|
|
pub hovered_item: ContainerStyle,
|
2022-02-01 14:11:20 +00:00
|
|
|
pub match_highlight: HighlightStyle,
|
2022-01-31 21:01:20 +00:00
|
|
|
}
|
|
|
|
|
2021-10-05 17:21:13 +00:00
|
|
|
#[derive(Clone, Copy, Default, Deserialize)]
|
|
|
|
pub struct SelectionStyle {
|
|
|
|
pub cursor: Color,
|
|
|
|
pub selection: Color,
|
|
|
|
}
|
|
|
|
|
2021-10-05 11:45:19 +00:00
|
|
|
#[derive(Clone, Deserialize, Default)]
|
2022-02-24 23:27:11 +00:00
|
|
|
pub struct FieldEditor {
|
2021-09-07 21:42:19 +00:00
|
|
|
#[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>,
|
2021-09-02 18:20:30 +00:00
|
|
|
pub selection: SelectionStyle,
|
2021-08-24 23:39:56 +00:00
|
|
|
}
|
|
|
|
|
2022-04-28 21:45:32 +00:00
|
|
|
#[derive(Debug, Default, Clone, Copy)]
|
2022-04-28 17:59:32 +00:00
|
|
|
pub struct Interactive<T> {
|
|
|
|
pub default: T,
|
|
|
|
pub hover: Option<T>,
|
|
|
|
pub active: Option<T>,
|
2022-04-28 19:08:15 +00:00
|
|
|
pub active_hover: Option<T>,
|
2022-04-28 17:59:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
impl<T> Interactive<T> {
|
2022-04-28 22:17:56 +00:00
|
|
|
pub fn style_for(&self, state: &MouseState, active: bool) -> &T {
|
|
|
|
if active {
|
|
|
|
if state.hovered {
|
|
|
|
self.active_hover
|
|
|
|
.as_ref()
|
|
|
|
.or(self.active.as_ref())
|
|
|
|
.unwrap_or(&self.default)
|
|
|
|
} else {
|
|
|
|
self.active.as_ref().unwrap_or(&self.default)
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if state.hovered {
|
|
|
|
self.hover.as_ref().unwrap_or(&self.default)
|
|
|
|
} else {
|
|
|
|
&self.default
|
|
|
|
}
|
|
|
|
}
|
2022-04-28 19:08:15 +00:00
|
|
|
}
|
2022-04-28 17:59:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
impl<'de, T: DeserializeOwned> Deserialize<'de> for Interactive<T> {
|
|
|
|
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
|
|
|
where
|
|
|
|
D: serde::Deserializer<'de>,
|
|
|
|
{
|
|
|
|
#[derive(Deserialize)]
|
|
|
|
struct Helper {
|
|
|
|
#[serde(flatten)]
|
|
|
|
default: Value,
|
|
|
|
hover: Option<Value>,
|
|
|
|
active: Option<Value>,
|
2022-04-28 19:08:15 +00:00
|
|
|
active_hover: Option<Value>,
|
2022-04-28 17:59:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
let json = Helper::deserialize(deserializer)?;
|
|
|
|
|
2022-04-28 19:08:15 +00:00
|
|
|
let deserialize_state = |state_json: Option<Value>| -> Result<Option<T>, D::Error> {
|
|
|
|
if let Some(mut state_json) = state_json {
|
|
|
|
if let Value::Object(state_json) = &mut state_json {
|
|
|
|
if let Value::Object(default) = &json.default {
|
|
|
|
for (key, value) in default {
|
|
|
|
if !state_json.contains_key(key) {
|
|
|
|
state_json.insert(key.clone(), value.clone());
|
|
|
|
}
|
2022-04-28 17:59:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-04-28 19:08:15 +00:00
|
|
|
Ok(Some(
|
|
|
|
serde_json::from_value::<T>(state_json).map_err(serde::de::Error::custom)?,
|
|
|
|
))
|
|
|
|
} else {
|
|
|
|
Ok(None)
|
2022-04-28 17:59:32 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2022-04-28 19:08:15 +00:00
|
|
|
let hover = deserialize_state(json.hover)?;
|
|
|
|
let active = deserialize_state(json.active)?;
|
|
|
|
let active_hover = deserialize_state(json.active_hover)?;
|
2022-04-28 17:59:32 +00:00
|
|
|
let default = serde_json::from_value(json.default).map_err(serde::de::Error::custom)?;
|
|
|
|
|
|
|
|
Ok(Interactive {
|
|
|
|
default,
|
|
|
|
hover,
|
|
|
|
active,
|
2022-04-28 19:08:15 +00:00
|
|
|
active_hover,
|
2022-04-28 17:59:32 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-24 23:27:11 +00:00
|
|
|
impl Editor {
|
2021-11-28 20:25:05 +00:00
|
|
|
pub fn replica_selection_style(&self, replica_id: u16) -> &SelectionStyle {
|
|
|
|
let style_ix = replica_id as usize % (self.guest_selections.len() + 1);
|
|
|
|
if style_ix == 0 {
|
|
|
|
&self.selection
|
|
|
|
} else {
|
|
|
|
&self.guest_selections[style_ix - 1]
|
|
|
|
}
|
|
|
|
}
|
2021-10-05 17:21:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Default)]
|
|
|
|
pub struct SyntaxTheme {
|
|
|
|
pub highlights: Vec<(String, HighlightStyle)>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl SyntaxTheme {
|
|
|
|
pub fn new(highlights: Vec<(String, HighlightStyle)>) -> Self {
|
|
|
|
Self { highlights }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'de> Deserialize<'de> for SyntaxTheme {
|
|
|
|
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
|
|
|
where
|
|
|
|
D: serde::Deserializer<'de>,
|
|
|
|
{
|
|
|
|
let syntax_data: HashMap<String, HighlightStyle> = Deserialize::deserialize(deserializer)?;
|
|
|
|
|
|
|
|
let mut result = Self::new(Vec::new());
|
|
|
|
for (key, style) in syntax_data {
|
|
|
|
match result
|
|
|
|
.highlights
|
|
|
|
.binary_search_by(|(needle, _)| needle.cmp(&key))
|
|
|
|
{
|
|
|
|
Ok(i) | Err(i) => {
|
|
|
|
result.highlights.insert(i, (key, style));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Ok(result)
|
|
|
|
}
|
|
|
|
}
|