mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-17 07:49:29 +00:00
Use Refineable
for ThemeStyles
(#3196)
This PR updates the `ThemeStyles` struct to use the `Refineable` trait instead of a custom declarative macro for generating refinements. Release Notes: - N/A
This commit is contained in:
parent
36a73d657a
commit
272f856460
5 changed files with 17 additions and 60 deletions
|
@ -1,8 +1,9 @@
|
|||
use gpui2::Hsla;
|
||||
use refineable::Refineable;
|
||||
|
||||
use crate::{generate_struct_with_overrides, SyntaxTheme};
|
||||
use crate::SyntaxTheme;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct SystemColors {
|
||||
pub transparent: Hsla,
|
||||
pub mac_os_traffic_light_red: Hsla,
|
||||
|
@ -17,6 +18,7 @@ pub struct PlayerColor {
|
|||
pub selection: Hsla,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct PlayerColors(pub Vec<PlayerColor>);
|
||||
|
||||
#[derive(Refineable, Clone, Debug)]
|
||||
|
@ -46,7 +48,7 @@ pub struct GitStatusColors {
|
|||
pub renamed: Hsla,
|
||||
}
|
||||
|
||||
#[derive(Refineable, Clone, Debug)]
|
||||
#[derive(Refineable, Clone, Debug, Default)]
|
||||
#[refineable(debug)]
|
||||
pub struct ThemeColors {
|
||||
pub border: Hsla,
|
||||
|
@ -86,15 +88,14 @@ pub struct ThemeColors {
|
|||
pub editor_active_line: Hsla,
|
||||
}
|
||||
|
||||
generate_struct_with_overrides! {
|
||||
ThemeStyle,
|
||||
ThemeStyleOverrides,
|
||||
system: SystemColors,
|
||||
colors: ThemeColors,
|
||||
status: StatusColors,
|
||||
git: GitStatusColors,
|
||||
player: PlayerColors,
|
||||
syntax: SyntaxTheme
|
||||
#[derive(Refineable, Clone)]
|
||||
pub struct ThemeStyles {
|
||||
pub system: SystemColors,
|
||||
pub colors: ThemeColors,
|
||||
pub status: StatusColors,
|
||||
pub git: GitStatusColors,
|
||||
pub player: PlayerColors,
|
||||
pub syntax: SyntaxTheme,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use crate::{
|
||||
colors::{GitStatusColors, PlayerColors, StatusColors, SystemColors, ThemeColors, ThemeStyle},
|
||||
colors::{GitStatusColors, PlayerColors, StatusColors, SystemColors, ThemeColors, ThemeStyles},
|
||||
default_color_scales, Appearance, SyntaxTheme, ThemeFamily, ThemeVariant,
|
||||
};
|
||||
|
||||
|
@ -8,7 +8,7 @@ fn zed_pro_daylight() -> ThemeVariant {
|
|||
id: "zed_pro_daylight".to_string(),
|
||||
name: "Zed Pro Daylight".into(),
|
||||
appearance: Appearance::Light,
|
||||
styles: ThemeStyle {
|
||||
styles: ThemeStyles {
|
||||
system: SystemColors::default(),
|
||||
colors: ThemeColors::default_light(),
|
||||
status: StatusColors::default(),
|
||||
|
@ -24,7 +24,7 @@ pub(crate) fn zed_pro_moonlight() -> ThemeVariant {
|
|||
id: "zed_pro_moonlight".to_string(),
|
||||
name: "Zed Pro Moonlight".into(),
|
||||
appearance: Appearance::Dark,
|
||||
styles: ThemeStyle {
|
||||
styles: ThemeStyles {
|
||||
system: SystemColors::default(),
|
||||
colors: ThemeColors::default_dark(),
|
||||
status: StatusColors::default(),
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use gpui2::{HighlightStyle, Hsla};
|
||||
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, Default)]
|
||||
pub struct SyntaxTheme {
|
||||
pub highlights: Vec<(String, HighlightStyle)>,
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@ mod registry;
|
|||
mod scale;
|
||||
mod settings;
|
||||
mod syntax;
|
||||
mod utils;
|
||||
|
||||
pub use colors::*;
|
||||
pub use default_colors::*;
|
||||
|
@ -55,7 +54,7 @@ pub struct ThemeVariant {
|
|||
pub(crate) id: String,
|
||||
pub name: SharedString,
|
||||
pub appearance: Appearance,
|
||||
pub styles: ThemeStyle,
|
||||
pub styles: ThemeStyles,
|
||||
}
|
||||
|
||||
impl ThemeVariant {
|
||||
|
|
|
@ -1,43 +0,0 @@
|
|||
/// This macro generates a struct and a corresponding struct with optional fields.
|
||||
///
|
||||
/// It takes as input the name of the struct to be generated, the name of the struct with optional fields,
|
||||
/// and a list of field names along with their types.
|
||||
///
|
||||
/// # Example
|
||||
/// ```
|
||||
/// generate_struct_with_overrides!(
|
||||
/// MyStruct,
|
||||
/// MyStructOverride,
|
||||
/// field1: i32,
|
||||
/// field2: String
|
||||
/// );
|
||||
/// ```
|
||||
/// This will generate the following structs:
|
||||
/// ```
|
||||
/// pub struct MyStruct {
|
||||
/// pub field1: i32,
|
||||
/// pub field2: String,
|
||||
/// }
|
||||
///
|
||||
/// pub struct MyStructOverride {
|
||||
/// pub field1: Option<i32>,
|
||||
/// pub field2: Option<String>,
|
||||
/// }
|
||||
/// ```
|
||||
#[macro_export]
|
||||
macro_rules! generate_struct_with_overrides {
|
||||
($struct_name:ident, $struct_override_name:ident, $($field:ident: $type:ty),*) => {
|
||||
pub struct $struct_name {
|
||||
$(
|
||||
pub $field: $type,
|
||||
)*
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub struct $struct_override_name {
|
||||
$(
|
||||
pub $field: Option<$type>,
|
||||
)*
|
||||
}
|
||||
};
|
||||
}
|
Loading…
Reference in a new issue