diff --git a/examples/aqua_dark.rs b/examples/aqua_dark.rs index a725753..8ccc31a 100644 --- a/examples/aqua_dark.rs +++ b/examples/aqua_dark.rs @@ -1,12 +1,18 @@ -use fltk::{prelude::*, *}; -use fltk_theme::{widget_themes, WidgetTheme, ThemeType}; +use fltk::{prelude::*, enums::*, *}; +use fltk_theme::{WidgetScheme, SchemeType}; +use fltk_theme::widget_schemes::aqua::dark::*; // get all the dark aqua colors fn main() { let a = app::App::default(); - let widget_theme = WidgetTheme::new(ThemeType::AquaDark); - widget_theme.apply(); + app::background(BG_COL.0, BG_COL.1, BG_COL.2); + app::background2(CTRL_ACC_COL.0, CTRL_ACC_COL.1, CTRL_ACC_COL.2); + app::foreground(FG_COL.0, FG_COL.1, FG_COL.2); + app::set_color(Color::Selection, 255, 255, 255); + let widget_scheme = WidgetScheme::new(SchemeType::Aqua); + widget_scheme.apply(); let mut win = window::Window::default().with_size(400, 300); - input::Input::new(50, 50, 300, 30, None); + let mut inp = input::Input::new(50, 50, 300, 30, None); + inp.set_color(Color::from_rgb(FRAME_COL.0, FRAME_COL.1, FRAME_COL.2)); let mut check = button::CheckButton::new(160, 150, 80, 30, " Check"); check.set_value(true); check.set_frame(enums::FrameType::FlatBox); @@ -14,7 +20,8 @@ fn main() { round.set_value(true); round.set_frame(enums::FrameType::FlatBox); let mut btn = button::Button::new(160, 230, 80, 30, "Hello"); - btn.set_frame(widget_themes::OS_DEFAULT_BUTTON_UP_BOX); + btn.set_color(Color::from_rgb(CTRL_COL.0, CTRL_COL.1, CTRL_COL.2)); + btn.set_selection_color(Color::from_rgb(SYS_CYAN.0, SYS_CYAN.1, SYS_CYAN.2)); win.end(); win.make_resizable(true); win.show(); diff --git a/src/lib.rs b/src/lib.rs index 81470b2..dd76dbf 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -134,10 +134,6 @@ pub enum ThemeType { Metro, /// Classic MacOS AquaClassic, - /// Modern MacOS using system colors, Dark theme - AquaDark, - /// Modern MacOS using system colors, light theme - AquaLight, /// Xfce Greybird, /// Windows 2000 @@ -167,8 +163,6 @@ impl WidgetTheme { ThemeType::Classic => widget_themes::classic::use_classic_theme(), ThemeType::Aero => widget_themes::aero::use_aero_theme(), ThemeType::AquaClassic => widget_themes::aqua_classic::use_aqua_classic_theme(), - ThemeType::AquaDark => widget_themes::aqua_dark::use_aqua_dark_theme(), - ThemeType::AquaLight => widget_themes::aqua_light::use_aqua_light_theme(), ThemeType::Dark => widget_themes::dark::use_dark_theme(), ThemeType::HighContrast => widget_themes::high_contrast::use_high_contrast_theme(), ThemeType::Blue => widget_themes::blue::use_blue_theme(), @@ -182,6 +176,8 @@ impl WidgetTheme { /// Lists supported schemes #[derive(Debug, Clone, Copy)] pub enum SchemeType { + /// A scheme mimicking modern Aqua + Aqua, /// Taken from the NTK fork Clean, /// Taken from the NTK fork @@ -214,6 +210,7 @@ impl WidgetScheme { /// Apply the widget theme pub fn apply(&self) { match self.scheme { + SchemeType::Aqua => widget_schemes::aqua::use_aqua_scheme(), SchemeType::Clean => widget_schemes::clean::use_clean_scheme(), SchemeType::Crystal => widget_schemes::crystal::use_crystal_scheme(), SchemeType::Gleam => widget_schemes::gleam::use_gleam_scheme(), diff --git a/src/widget_schemes/aqua.rs b/src/widget_schemes/aqua.rs new file mode 100644 index 0000000..9e65c76 --- /dev/null +++ b/src/widget_schemes/aqua.rs @@ -0,0 +1,260 @@ +#[cfg(target_os = "macos")] +use crate::cocoa_helper::*; +use fltk::{app, enums::{Color, FrameType}, image, prelude::ImageExt}; + +#[cfg(target_os = "macos")] +fn convert_colors(colors: (f64, f64, f64, f64)) -> (u8, u8, u8, u8) { + let r = (colors.0 * 255.0) as u8; + let g = (colors.1 * 255.0) as u8; + let b = (colors.2 * 255.0) as u8; + let a = (colors.3 * 255.0) as u8; + (r, g, b, a) +} + +#[cfg(target_os = "macos")] +macro_rules! get_colors { + ($s:ident) => {{ + let mut r = 1.0; + let mut g = 1.0; + let mut b = 1.0; + let mut a = 1.0; + unsafe { + $s(&mut r, &mut g, &mut b, &mut a); + } + convert_colors((r, g, b, a)) + }}; +} + +#[cfg(target_os = "macos")] +mod sys { + lazy_static::lazy_static! { + pub static ref BG_COL: (u8, u8, u8, u8) = get_colors!(my_windowBackgroundColor); + pub static ref FG_COL: (u8, u8, u8, u8) = get_colors!(my_labelColor); + pub static ref CTRL_BG_COL: (u8, u8, u8, u8) = get_colors!(my_controlBackgroundColor); + pub static ref FRAME_COL: (u8, u8, u8, u8) = get_colors!(my_windowFrameColor); + pub static ref LABEL2_COL: (u8, u8, u8, u8) = get_colors!(my_secondaryLabelColor); + pub static ref LABEL3_COL: (u8, u8, u8, u8) = get_colors!(my_tertiaryLabelColor); + pub static ref LABEL4_COL: (u8, u8, u8, u8) = get_colors!(my_quaternaryLabelColor); + pub static ref TXT_COL: (u8, u8, u8, u8) = get_colors!(my_textColor); + pub static ref PH_TXT_COL: (u8, u8, u8, u8) = get_colors!(my_placeholderTextColor); + pub static ref SEL_TXT_COL: (u8, u8, u8, u8) = get_colors!(my_selectedTextColor); + pub static ref TXT_BG_COL: (u8, u8, u8, u8) = get_colors!(my_textBackgroundColor); + pub static ref SEL_TXT_BG_COL: (u8, u8, u8, u8) = get_colors!(my_selectedTextBackgroundColor); + pub static ref KB_IND_COL: (u8, u8, u8, u8) = get_colors!(my_keyboardFocusIndicatorColor); + pub static ref SEL_TXT2_COL: (u8, u8, u8, u8) = get_colors!(my_unemphasizedSelectedTextColor); + pub static ref SEL_TXT_BG2_COL: (u8, u8, u8, u8) = get_colors!(my_unemphasizedSelectedTextBackgroundColor); + pub static ref LINK_COL: (u8, u8, u8, u8) = get_colors!(my_linkColor); + pub static ref SEP_COL: (u8, u8, u8, u8) = get_colors!(my_separatorColor); + pub static ref SEL_BG_COL: (u8, u8, u8, u8) = get_colors!(my_selectedContentBackgroundColor); + pub static ref SEL_BG2_COL: (u8, u8, u8, u8) = get_colors!(my_unemphasizedSelectedContentBackgroundColor); + pub static ref SEL_MEN_TXT_COL: (u8, u8, u8, u8) = get_colors!(my_selectedMenuItemTextColor); + pub static ref GRID_COL: (u8, u8, u8, u8) = get_colors!(my_gridColor); + pub static ref HDR_COL: (u8, u8, u8, u8) = get_colors!(my_headerTextColor); + pub static ref CTRL_ACC_COL: (u8, u8, u8, u8) = get_colors!(my_controlAccentColor); + pub static ref CTRL_COL: (u8, u8, u8, u8) = get_colors!(my_controlColor); + pub static ref CTRL_TXT_COL: (u8, u8, u8, u8) = get_colors!(my_controlTextColor); + pub static ref DIS_CTRL_TXT_COL: (u8, u8, u8, u8) = get_colors!(my_disabledControlTextColor); + pub static ref SEL_CTRL_COL: (u8, u8, u8, u8) = get_colors!(my_selectedControlColor); + pub static ref SEL_CTRL_TXT_COL: (u8, u8, u8, u8) = get_colors!(my_selectedControlTextColor); + pub static ref ALT_SEL_CTRL_TXT_COL: (u8, u8, u8, u8) = get_colors!(my_alternateSelectedControlTextColor); + pub static ref SCRUB_BG_COL: (u8, u8, u8, u8) = get_colors!(my_scrubberTexturedBackgroundColor); + pub static ref WIN_FRM_TXT_COL: (u8, u8, u8, u8) = get_colors!(my_windowFrameTextColor); + pub static ref PAGE_BG_COL: (u8, u8, u8, u8) = get_colors!(my_underPageBackgroundColor); + pub static ref FIND_HLT_COL: (u8, u8, u8, u8) = get_colors!(my_findHighlightColor); + pub static ref HLT_COL: (u8, u8, u8, u8) = get_colors!(my_highlightColor); + pub static ref SHDW_COL: (u8, u8, u8, u8) = get_colors!(my_shadowColor); + } +} + +pub mod dark { + lazy_static::lazy_static! { + pub static ref BG2_COL: (u8, u8, u8, u8) = (0, 0, 0, 255); + pub static ref SYS_CYAN: (u8, u8, u8, u8) = (90, 200 , 245, 255); + pub static ref BG_COL: (u8, u8, u8, u8) = (37, 37, 37, 255); + pub static ref FG_COL: (u8, u8, u8, u8) = (255, 254, 254, 216); + pub static ref CTRL_BG_COL: (u8, u8, u8, u8) = (22, 22, 22, 255); + pub static ref FRAME_COL: (u8, u8, u8, u8) = (153, 153, 153, 255); + pub static ref LABEL2_COL: (u8, u8, u8, u8) = (255, 254, 254, 140); + pub static ref LABEL3_COL: (u8, u8, u8, u8) = (255, 254, 254, 63); + pub static ref LABEL4_COL: (u8, u8, u8, u8) = (255, 254, 254, 25); + pub static ref TXT_COL: (u8, u8, u8, u8) = (255, 254, 254, 255); + pub static ref PH_TXT_COL: (u8, u8, u8, u8) = (255, 254, 254, 63); + pub static ref SEL_TXT_COL: (u8, u8, u8, u8) = (255, 255, 255, 255); + pub static ref TXT_BG_COL: (u8, u8, u8, u8) = (22, 22, 22, 255); + pub static ref SEL_TXT_BG_COL: (u8, u8, u8, u8) = (48, 79, 120, 255); + pub static ref KB_IND_COL: (u8, u8, u8, u8) = (27, 149, 254, 76); + pub static ref SEL_TXT2_COL: (u8, u8, u8, u8) = (255, 255, 255, 255); + pub static ref SEL_TXT_BG2_COL: (u8, u8, u8, u8) = (54, 54, 54, 255); + pub static ref LINK_COL: (u8, u8, u8, u8) = (52, 134, 254, 255); + pub static ref SEP_COL: (u8, u8, u8, u8) = (255, 254, 254, 25); + pub static ref SEL_BG_COL: (u8, u8, u8, u8) = (5, 63, 197, 255); + pub static ref SEL_BG2_COL: (u8, u8, u8, u8) = (54, 54, 54, 255); + pub static ref SEL_MEN_TXT_COL: (u8, u8, u8, u8) = (255, 254, 254, 255); + pub static ref GRID_COL: (u8, u8, u8, u8) = (20, 20, 20, 255); + pub static ref HDR_COL: (u8, u8, u8, u8) = (255, 254, 254, 255); + pub static ref CTRL_ACC_COL: (u8, u8, u8, u8) = (10, 95, 254, 255); + pub static ref CTRL_COL: (u8, u8, u8, u8) = (255, 254, 254, 63); + pub static ref CTRL_TXT_COL: (u8, u8, u8, u8) = (255, 254, 254, 216); + pub static ref DIS_CTRL_TXT_COL: (u8, u8, u8, u8) = (255, 254, 254, 63); + pub static ref SEL_CTRL_COL: (u8, u8, u8, u8) = (48, 79, 120, 255); + pub static ref SEL_CTRL_TXT_COL: (u8, u8, u8, u8) = (255, 254, 254, 216); + pub static ref ALT_SEL_CTRL_TXT_COL: (u8, u8, u8, u8) = (255, 254, 254, 255); + pub static ref SCRUB_BG_COL: (u8, u8, u8, u8) = (255, 254, 254, 255); + pub static ref WIN_FRM_TXT_COL: (u8, u8, u8, u8) = (255, 254, 254, 216); + pub static ref PAGE_BG_COL: (u8, u8, u8, u8) = (29, 29, 29, 255); + pub static ref FIND_HLT_COL: (u8, u8, u8, u8) = (255, 255, 10, 255); + pub static ref HLT_COL: (u8, u8, u8, u8) = (164, 164, 164, 255); + pub static ref SHDW_COL: (u8, u8, u8, u8) = (0, 0, 0, 255); + } +} + +pub mod light { + lazy_static::lazy_static! { + pub static ref BG2_COL: (u8, u8, u8, u8) = (255, 255, 255, 255); + pub static ref SYS_CYAN: (u8, u8, u8, u8) = (85, 190 , 240, 255); + pub static ref BG_COL: (u8, u8, u8, u8) = (231, 231, 231, 255); + pub static ref FG_COL: (u8, u8, u8, u8) = (0, 0, 0, 216); + pub static ref CTRL_BG_COL: (u8, u8, u8, u8) = (255, 254, 254, 255); + pub static ref FRAME_COL: (u8, u8, u8, u8) = (153, 153, 153, 255); + pub static ref LABEL2_COL: (u8, u8, u8, u8) = (0, 0, 0, 127); + pub static ref LABEL3_COL: (u8, u8, u8, u8) = (0, 0, 0, 66); + pub static ref LABEL4_COL: (u8, u8, u8, u8) = (0, 0, 0, 25); + pub static ref TXT_COL: (u8, u8, u8, u8) = (0, 0, 0, 255); + pub static ref PH_TXT_COL: (u8, u8, u8, u8) = (0, 0, 0, 63); + pub static ref SEL_TXT_COL: (u8, u8, u8, u8) = (0, 0, 0, 255); + pub static ref TXT_BG_COL: (u8, u8, u8, u8) = (255, 254, 254, 255); + pub static ref SEL_TXT_BG_COL: (u8, u8, u8, u8) = (164, 204, 254, 255); + pub static ref KB_IND_COL: (u8, u8, u8, u8) = (7, 75, 240, 63); + pub static ref SEL_TXT2_COL: (u8, u8, u8, u8) = (0, 0, 0, 255); + pub static ref SEL_TXT_BG2_COL: (u8, u8, u8, u8) = (211, 211, 211, 255); + pub static ref LINK_COL: (u8, u8, u8, u8) = (8, 79, 209, 255); + pub static ref SEP_COL: (u8, u8, u8, u8) = (0, 0, 0, 25); + pub static ref SEL_BG_COL: (u8, u8, u8, u8) = (7, 73, 217, 255); + pub static ref SEL_BG2_COL: (u8, u8, u8, u8) = (211, 211, 211, 255); + pub static ref SEL_MEN_TXT_COL: (u8, u8, u8, u8) = (255, 254, 254, 255); + pub static ref GRID_COL: (u8, u8, u8, u8) = (223, 223, 223, 255); + pub static ref HDR_COL: (u8, u8, u8, u8) = (0, 0, 0, 216); + pub static ref CTRL_ACC_COL: (u8, u8, u8, u8) = (10, 95, 254, 255); + pub static ref CTRL_COL: (u8, u8, u8, u8) = (255, 254, 254, 255); + pub static ref CTRL_TXT_COL: (u8, u8, u8, u8) = (0, 0, 0, 216); + pub static ref DIS_CTRL_TXT_COL: (u8, u8, u8, u8) = (0, 0, 0, 63); + pub static ref SEL_CTRL_COL: (u8, u8, u8, u8) = (164, 204, 254, 255); + pub static ref SEL_CTRL_TXT_COL: (u8, u8, u8, u8) = (0, 0, 0, 216); + pub static ref ALT_SEL_CTRL_TXT_COL: (u8, u8, u8, u8) = (255, 254, 254, 255); + pub static ref SCRUB_BG_COL: (u8, u8, u8, u8) = (255, 254, 254, 255); + pub static ref WIN_FRM_TXT_COL: (u8, u8, u8, u8) = (0, 0, 0, 216); + pub static ref PAGE_BG_COL: (u8, u8, u8, u8) = (131, 131, 131, 229); + pub static ref FIND_HLT_COL: (u8, u8, u8, u8) = (255, 255, 10, 255); + pub static ref HLT_COL: (u8, u8, u8, u8) = (255, 254, 254, 255); + pub static ref SHDW_COL: (u8, u8, u8, u8) = (0, 0, 0, 255); + } +} + +fn button_up_box(x: i32, y: i32, w: i32, h: i32, c: Color) { + let col = c.to_rgb(); + let bg = Color::BackGround.to_rgb(); + let svg = format!( + " + + + + + + + + + ", + w, + h, + col.0, + col.1, + col.2, + if bg.0 > 230 && bg.1 > 230 && bg.2 > 230 { + 1.0 + } else { + 63 as f64 / 255.0 + }, + col.0 - 10, + col.1 - 10, + col.2 - 10, + h / 4, + bg.0, + bg.1, + bg.2 + ); + let mut image = image::SvgImage::from_data(&svg).unwrap(); + image.draw(x, y, w, h); +} + +fn depressed_down_box(x: i32, y: i32, w: i32, h: i32, c: Color) { + let col = c.to_rgb(); + let svg = format!( + " + + + + + + + + ", + w, + h, + col.0 - 10, + col.1 - 10, + col.2 - 10, + col.0, + col.1, + col.2, + h / 4 + ); + let mut image = image::SvgImage::from_data(&svg).unwrap(); + image.draw(x, y, w, h); +} + +fn radio_round_down_box(x: i32, y: i32, w: i32, h: i32, c: Color) { + let col = c.to_rgb(); + let svg = format!( + " + + ", + w, + h, + w / 2, + h / 2, + w / 2, + col.0, + col.1, + col.2 + ); + let mut image = image::SvgImage::from_data(&svg).unwrap(); + image.draw(x, y, w, h); +} + +fn use_scheme() { + app::set_scheme(app::Scheme::Gtk); + app::set_frame_type_cb(FrameType::UpBox, button_up_box, 1, 1, 2, 2); + app::set_frame_type_cb( + FrameType::DownBox, + depressed_down_box, + 1, + 1, + 2, + 2, + ); + app::set_frame_type_cb( + FrameType::RoundDownBox, + radio_round_down_box, + 2, + 2, + 4, + 4, + ); + // app::set_frame_type_cb(OS_BG_DOWN_BOX, OS_BG_BOX); +} + +pub(crate) fn use_aqua_scheme() { + use_scheme(); + app::set_visible_focus(false); + app::set_scrollbar_size(15); +} diff --git a/src/widget_schemes/mod.rs b/src/widget_schemes/mod.rs index 6e467a9..97d50c7 100644 --- a/src/widget_schemes/mod.rs +++ b/src/widget_schemes/mod.rs @@ -4,7 +4,7 @@ use crate::activated_color; use fltk::{app, draw::*, enums::Color}; -// taken from NTK's themes +pub mod aqua; pub(crate) mod clean; pub(crate) mod crystal; pub(crate) mod gleam; diff --git a/src/widget_themes/aqua_dark.rs b/src/widget_themes/aqua_dark.rs deleted file mode 100644 index fa867a4..0000000 --- a/src/widget_themes/aqua_dark.rs +++ /dev/null @@ -1,229 +0,0 @@ -use super::*; -#[cfg(target_os = "macos")] -use crate::cocoa_helper::*; -use fltk::{app, enums::Color, image, misc::Tooltip, prelude::ImageExt}; - -#[cfg(target_os = "macos")] -fn convert_colors(colors: (f64, f64, f64, f64)) -> (u8, u8, u8, u8) { - let r = (colors.0 * 255.0) as u8; - let g = (colors.1 * 255.0) as u8; - let b = (colors.2 * 255.0) as u8; - let a = (colors.3 * 255.0) as u8; - (r, g, b, a) -} - -#[cfg(target_os = "macos")] -macro_rules! get_colors { - ($s:ident) => {{ - let mut r = 1.0; - let mut g = 1.0; - let mut b = 1.0; - let mut a = 1.0; - unsafe { - $s(&mut r, &mut g, &mut b, &mut a); - } - convert_colors((r, g, b, a)) - }}; -} - -#[cfg(target_os = "macos")] -lazy_static::lazy_static! { - static ref BG2_COL: (u8, u8, u8, u8) = (0, 0, 0, 255); - static ref SYS_CYAN: (u8, u8, u8, u8) = (90, 200 , 245, 255); //beta! - static ref BG_COL: (u8, u8, u8, u8) = get_colors!(my_windowBackgroundColor); - static ref FG_COL: (u8, u8, u8, u8) = get_colors!(my_labelColor); - static ref CTRL_BG_COL: (u8, u8, u8, u8) = get_colors!(my_controlBackgroundColor); - static ref FRAME_COL: (u8, u8, u8, u8) = get_colors!(my_windowFrameColor); - static ref LABEL2_COL: (u8, u8, u8, u8) = get_colors!(my_secondaryLabelColor); - static ref LABEL3_COL: (u8, u8, u8, u8) = get_colors!(my_tertiaryLabelColor); - static ref LABEL4_COL: (u8, u8, u8, u8) = get_colors!(my_quaternaryLabelColor); - static ref TXT_COL: (u8, u8, u8, u8) = get_colors!(my_textColor); - static ref PH_TXT_COL: (u8, u8, u8, u8) = get_colors!(my_placeholderTextColor); - static ref SEL_TXT_COL: (u8, u8, u8, u8) = get_colors!(my_selectedTextColor); - static ref TXT_BG_COL: (u8, u8, u8, u8) = get_colors!(my_textBackgroundColor); - static ref SEL_TXT_BG_COL: (u8, u8, u8, u8) = get_colors!(my_selectedTextBackgroundColor); - static ref KB_IND_COL: (u8, u8, u8, u8) = get_colors!(my_keyboardFocusIndicatorColor); - static ref SEL_TXT2_COL: (u8, u8, u8, u8) = get_colors!(my_unemphasizedSelectedTextColor); - static ref SEL_TXT_BG2_COL: (u8, u8, u8, u8) = get_colors!(my_unemphasizedSelectedTextBackgroundColor); - static ref LINK_COL: (u8, u8, u8, u8) = get_colors!(my_linkColor); - static ref SEP_COL: (u8, u8, u8, u8) = get_colors!(my_separatorColor); - static ref SEL_BG_COL: (u8, u8, u8, u8) = get_colors!(my_selectedContentBackgroundColor); - static ref SEL_BG2_COL: (u8, u8, u8, u8) = get_colors!(my_unemphasizedSelectedContentBackgroundColor); - static ref SEL_MEN_TXT_COL: (u8, u8, u8, u8) = get_colors!(my_selectedMenuItemTextColor); - static ref GRID_COL: (u8, u8, u8, u8) = get_colors!(my_gridColor); - static ref HDR_COL: (u8, u8, u8, u8) = get_colors!(my_headerTextColor); - static ref CTRL_ACC_COL: (u8, u8, u8, u8) = get_colors!(my_controlAccentColor); - static ref CTRL_COL: (u8, u8, u8, u8) = get_colors!(my_controlColor); - static ref CTRL_TXT_COL: (u8, u8, u8, u8) = get_colors!(my_controlTextColor); - static ref DIS_CTRL_TXT_COL: (u8, u8, u8, u8) = get_colors!(my_disabledControlTextColor); - static ref SEL_CTRL_COL: (u8, u8, u8, u8) = get_colors!(my_selectedControlColor); - static ref SEL_CTRL_TXT_COL: (u8, u8, u8, u8) = get_colors!(my_selectedControlTextColor); - static ref ALT_SEL_CTRL_TXT_COL: (u8, u8, u8, u8) = get_colors!(my_alternateSelectedControlTextColor); - static ref SCRUB_BG_COL: (u8, u8, u8, u8) = get_colors!(my_scrubberTexturedBackgroundColor); - static ref WIN_FRM_TXT_COL: (u8, u8, u8, u8) = get_colors!(my_windowFrameTextColor); - static ref PAGE_BG_COL: (u8, u8, u8, u8) = get_colors!(my_underPageBackgroundColor); - static ref FIND_HLT_COL: (u8, u8, u8, u8) = get_colors!(my_findHighlightColor); - static ref HLT_COL: (u8, u8, u8, u8) = get_colors!(my_highlightColor); - static ref SHDW_COL: (u8, u8, u8, u8) = get_colors!(my_shadowColor); -} - -#[cfg(not(target_os = "macos"))] -lazy_static::lazy_static! { - static ref BG2_COL: (u8, u8, u8, u8) = (0, 0, 0, 255); - static ref SYS_CYAN: (u8, u8, u8, u8) = (90, 200 , 245, 255); - static ref BG_COL: (u8, u8, u8, u8) = (37, 37, 37, 255); - static ref FG_COL: (u8, u8, u8, u8) = (255, 254, 254, 216); - static ref CTRL_BG_COL: (u8, u8, u8, u8) = (22, 22, 22, 255); - static ref FRAME_COL: (u8, u8, u8, u8) = (153, 153, 153, 255); - static ref LABEL2_COL: (u8, u8, u8, u8) = (255, 254, 254, 140); - static ref LABEL3_COL: (u8, u8, u8, u8) = (255, 254, 254, 63); - static ref LABEL4_COL: (u8, u8, u8, u8) = (255, 254, 254, 25); - static ref TXT_COL: (u8, u8, u8, u8) = (255, 254, 254, 255); - static ref PH_TXT_COL: (u8, u8, u8, u8) = (255, 254, 254, 63); - static ref SEL_TXT_COL: (u8, u8, u8, u8) = (255, 255, 255, 255); - static ref TXT_BG_COL: (u8, u8, u8, u8) = (22, 22, 22, 255); - static ref SEL_TXT_BG_COL: (u8, u8, u8, u8) = (48, 79, 120, 255); - static ref KB_IND_COL: (u8, u8, u8, u8) = (27, 149, 254, 76); - static ref SEL_TXT2_COL: (u8, u8, u8, u8) = (255, 255, 255, 255); - static ref SEL_TXT_BG2_COL: (u8, u8, u8, u8) = (54, 54, 54, 255); - static ref LINK_COL: (u8, u8, u8, u8) = (52, 134, 254, 255); - static ref SEP_COL: (u8, u8, u8, u8) = (255, 254, 254, 25); - static ref SEL_BG_COL: (u8, u8, u8, u8) = (5, 63, 197, 255); - static ref SEL_BG2_COL: (u8, u8, u8, u8) = (54, 54, 54, 255); - static ref SEL_MEN_TXT_COL: (u8, u8, u8, u8) = (255, 254, 254, 255); - static ref GRID_COL: (u8, u8, u8, u8) = (20, 20, 20, 255); - static ref HDR_COL: (u8, u8, u8, u8) = (255, 254, 254, 255); - static ref CTRL_ACC_COL: (u8, u8, u8, u8) = (10, 95, 254, 255); - static ref CTRL_COL: (u8, u8, u8, u8) = (255, 254, 254, 63); - static ref CTRL_TXT_COL: (u8, u8, u8, u8) = (255, 254, 254, 216); - static ref DIS_CTRL_TXT_COL: (u8, u8, u8, u8) = (255, 254, 254, 63); - static ref SEL_CTRL_COL: (u8, u8, u8, u8) = (48, 79, 120, 255); - static ref SEL_CTRL_TXT_COL: (u8, u8, u8, u8) = (255, 254, 254, 216); - static ref ALT_SEL_CTRL_TXT_COL: (u8, u8, u8, u8) = (255, 254, 254, 255); - static ref SCRUB_BG_COL: (u8, u8, u8, u8) = (255, 254, 254, 255); - static ref WIN_FRM_TXT_COL: (u8, u8, u8, u8) = (255, 254, 254, 216); - static ref PAGE_BG_COL: (u8, u8, u8, u8) = (29, 29, 29, 255); - static ref FIND_HLT_COL: (u8, u8, u8, u8) = (255, 255, 10, 255); - static ref HLT_COL: (u8, u8, u8, u8) = (164, 164, 164, 255); - static ref SHDW_COL: (u8, u8, u8, u8) = (0, 0, 0, 255); -} - -fn aqua_dark_button_up_box(x: i32, y: i32, w: i32, h: i32, c: Color) { - let col = &CTRL_COL; - let bg = &BG_COL; - let svg = format!( - " - - - - - - - - - ", - w, - h, - col.0, - col.1, - col.2, - col.3 as f64 / 255.0, - col.0 - 10, - col.1 - 10, - col.2 - 10, - h / 4, - bg.0, - bg.1, - bg.2 - ); - let mut image = image::SvgImage::from_data(&svg).unwrap(); - image.draw(x, y, w, h); -} - -fn aqua_dark_depressed_down_box(x: i32, y: i32, w: i32, h: i32, c: Color) { - let col = &SYS_CYAN; - let svg = format!( - " - - - - - - - - ", - w, - h, - col.0 - 10, - col.1 - 10, - col.2 - 10, - col.0, - col.1, - col.2, - h / 4 - ); - let mut image = image::SvgImage::from_data(&svg).unwrap(); - image.draw(x, y, w, h); -} - -fn aqua_dark_radio_round_down_box(x: i32, y: i32, w: i32, h: i32, c: Color) { - let col = &CTRL_ACC_COL; - let svg = format!( - " - - ", - w, - h, - w / 2, - h / 2, - w / 2, - col.0, - col.1, - col.2 - ); - let mut image = image::SvgImage::from_data(&svg).unwrap(); - image.draw(x, y, w, h); -} - -fn use_aqua_dark_scheme() { - app::set_scheme(app::Scheme::Gtk); - app::set_frame_type_cb(FrameType::UpBox, aqua_dark_button_up_box, 1, 1, 2, 2); - app::set_frame_type2(FrameType::DownBox, FrameType::UpBox); - app::set_frame_type2(OS_DEFAULT_BUTTON_UP_BOX, FrameType::UpBox); - app::set_frame_type_cb( - OS_DEFAULT_DEPRESSED_DOWN_BOX, - aqua_dark_depressed_down_box, - 1, - 1, - 2, - 2, - ); - app::set_frame_type_cb( - OS_RADIO_ROUND_DOWN_BOX, - aqua_dark_radio_round_down_box, - 2, - 2, - 4, - 4, - ); - app::set_frame_type2(FrameType::RoundDownBox, OS_RADIO_ROUND_DOWN_BOX); - app::set_frame_type2(OS_BG_BOX, FrameType::FlatBox); - // app::set_frame_type_cb(OS_BG_DOWN_BOX, OS_BG_BOX); -} - -fn use_aqua_dark_colors() { - app::background(BG_COL.0, BG_COL.1, BG_COL.2); - app::foreground(FG_COL.0, FG_COL.1, FG_COL.2); - app::background2(BG2_COL.0, BG2_COL.1, BG2_COL.2); - app::set_color(Color::Inactive, 0x4D, 0x4D, 0x69); - app::set_color(Color::Selection, 255, 255, 255); - app::set_color(Color::Free, 0xFB, 0xFB, 0xFB); - Tooltip::set_color(Color::from_rgb(0xFF, 0xFF, 0xC7)); - Tooltip::set_text_color(Color::ForeGround); -} - -pub(crate) fn use_aqua_dark_theme() { - use_aqua_dark_scheme(); - use_aqua_dark_colors(); - use_native_settings(); -} diff --git a/src/widget_themes/aqua_light.rs b/src/widget_themes/aqua_light.rs deleted file mode 100644 index e035787..0000000 --- a/src/widget_themes/aqua_light.rs +++ /dev/null @@ -1,223 +0,0 @@ -use super::*; -#[cfg(target_os = "macos")] -use crate::cocoa_helper::*; -use fltk::{app, enums::Color, image, misc::Tooltip, prelude::ImageExt}; - -#[cfg(target_os = "macos")] -fn convert_colors(colors: (f64, f64, f64, f64)) -> (u8, u8, u8, u8) { - let r = (colors.0 * 255.0) as u8; - let g = (colors.1 * 255.0) as u8; - let b = (colors.2 * 255.0) as u8; - let a = (colors.3 * 255.0) as u8; - (r, g, b, a) -} - -#[cfg(target_os = "macos")] -macro_rules! get_colors { - ($s:ident) => {{ - let mut r = 1.0; - let mut g = 1.0; - let mut b = 1.0; - let mut a = 1.0; - unsafe { - $s(&mut r, &mut g, &mut b, &mut a); - } - convert_colors((r, g, b, a)) - }}; -} - -#[cfg(target_os = "macos")] -lazy_static::lazy_static! { - static ref BG2_COL: (u8, u8, u8, u8) = (255, 255, 255, 255); - static ref SYS_CYAN: (u8, u8, u8, u8) = (85, 190 , 240, 255); - static ref BG_COL: (u8, u8, u8, u8) = get_colors!(my_windowBackgroundColor); - static ref FG_COL: (u8, u8, u8, u8) = get_colors!(my_labelColor); - static ref CTRL_BG_COL: (u8, u8, u8, u8) = get_colors!(my_controlBackgroundColor); - static ref FRAME_COL: (u8, u8, u8, u8) = get_colors!(my_windowFrameColor); - static ref LABEL2_COL: (u8, u8, u8, u8) = get_colors!(my_secondaryLabelColor); - static ref LABEL3_COL: (u8, u8, u8, u8) = get_colors!(my_tertiaryLabelColor); - static ref LABEL4_COL: (u8, u8, u8, u8) = get_colors!(my_quaternaryLabelColor); - static ref TXT_COL: (u8, u8, u8, u8) = get_colors!(my_textColor); - static ref PH_TXT_COL: (u8, u8, u8, u8) = get_colors!(my_placeholderTextColor); - static ref SEL_TXT_COL: (u8, u8, u8, u8) = get_colors!(my_selectedTextColor); - static ref TXT_BG_COL: (u8, u8, u8, u8) = get_colors!(my_textBackgroundColor); - static ref SEL_TXT_BG_COL: (u8, u8, u8, u8) = get_colors!(my_selectedTextBackgroundColor); - static ref KB_IND_COL: (u8, u8, u8, u8) = get_colors!(my_keyboardFocusIndicatorColor); - static ref SEL_TXT2_COL: (u8, u8, u8, u8) = get_colors!(my_unemphasizedSelectedTextColor); - static ref SEL_TXT_BG2_COL: (u8, u8, u8, u8) = get_colors!(my_unemphasizedSelectedTextBackgroundColor); - static ref LINK_COL: (u8, u8, u8, u8) = get_colors!(my_linkColor); - static ref SEP_COL: (u8, u8, u8, u8) = get_colors!(my_separatorColor); - static ref SEL_BG_COL: (u8, u8, u8, u8) = get_colors!(my_selectedContentBackgroundColor); - static ref SEL_BG2_COL: (u8, u8, u8, u8) = get_colors!(my_unemphasizedSelectedContentBackgroundColor); - static ref SEL_MEN_TXT_COL: (u8, u8, u8, u8) = get_colors!(my_selectedMenuItemTextColor); - static ref GRID_COL: (u8, u8, u8, u8) = get_colors!(my_gridColor); - static ref HDR_COL: (u8, u8, u8, u8) = get_colors!(my_headerTextColor); - static ref CTRL_ACC_COL: (u8, u8, u8, u8) = get_colors!(my_controlAccentColor); - static ref CTRL_COL: (u8, u8, u8, u8) = get_colors!(my_controlColor); - static ref CTRL_TXT_COL: (u8, u8, u8, u8) = get_colors!(my_controlTextColor); - static ref DIS_CTRL_TXT_COL: (u8, u8, u8, u8) = get_colors!(my_disabledControlTextColor); - static ref SEL_CTRL_COL: (u8, u8, u8, u8) = get_colors!(my_selectedControlColor); - static ref SEL_CTRL_TXT_COL: (u8, u8, u8, u8) = get_colors!(my_selectedControlTextColor); - static ref ALT_SEL_CTRL_TXT_COL: (u8, u8, u8, u8) = get_colors!(my_alternateSelectedControlTextColor); - static ref SCRUB_BG_COL: (u8, u8, u8, u8) = get_colors!(my_scrubberTexturedBackgroundColor); - static ref WIN_FRM_TXT_COL: (u8, u8, u8, u8) = get_colors!(my_windowFrameTextColor); - static ref PAGE_BG_COL: (u8, u8, u8, u8) = get_colors!(my_underPageBackgroundColor); - static ref FIND_HLT_COL: (u8, u8, u8, u8) = get_colors!(my_findHighlightColor); - static ref HLT_COL: (u8, u8, u8, u8) = get_colors!(my_highlightColor); - static ref SHDW_COL: (u8, u8, u8, u8) = get_colors!(my_shadowColor); -} - -#[cfg(not(target_os = "macos"))] -lazy_static::lazy_static! { - static ref BG2_COL: (u8, u8, u8, u8) = (255, 255, 255, 255); - static ref SYS_CYAN: (u8, u8, u8, u8) = (85, 190 , 240, 255); - static ref BG_COL: (u8, u8, u8, u8) = (231, 231, 231, 255); - static ref FG_COL: (u8, u8, u8, u8) = (0, 0, 0, 216); - static ref CTRL_BG_COL: (u8, u8, u8, u8) = (255, 254, 254, 255); - static ref FRAME_COL: (u8, u8, u8, u8) = (153, 153, 153, 255); - static ref LABEL2_COL: (u8, u8, u8, u8) = (0, 0, 0, 127); - static ref LABEL3_COL: (u8, u8, u8, u8) = (0, 0, 0, 66); - static ref LABEL4_COL: (u8, u8, u8, u8) = (0, 0, 0, 25); - static ref TXT_COL: (u8, u8, u8, u8) = (0, 0, 0, 255); - static ref PH_TXT_COL: (u8, u8, u8, u8) = (0, 0, 0, 63); - static ref SEL_TXT_COL: (u8, u8, u8, u8) = (0, 0, 0, 255); - static ref TXT_BG_COL: (u8, u8, u8, u8) = (255, 254, 254, 255); - static ref SEL_TXT_BG_COL: (u8, u8, u8, u8) = (164, 204, 254, 255); - static ref KB_IND_COL: (u8, u8, u8, u8) = (7, 75, 240, 63); - static ref SEL_TXT2_COL: (u8, u8, u8, u8) = (0, 0, 0, 255); - static ref SEL_TXT_BG2_COL: (u8, u8, u8, u8) = (211, 211, 211, 255); - static ref LINK_COL: (u8, u8, u8, u8) = (8, 79, 209, 255); - static ref SEP_COL: (u8, u8, u8, u8) = (0, 0, 0, 25); - static ref SEL_BG_COL: (u8, u8, u8, u8) = (7, 73, 217, 255); - static ref SEL_BG2_COL: (u8, u8, u8, u8) = (211, 211, 211, 255); - static ref SEL_MEN_TXT_COL: (u8, u8, u8, u8) = (255, 254, 254, 255); - static ref GRID_COL: (u8, u8, u8, u8) = (223, 223, 223, 255); - static ref HDR_COL: (u8, u8, u8, u8) = (0, 0, 0, 216); - static ref CTRL_ACC_COL: (u8, u8, u8, u8) = (10, 95, 254, 255); - static ref CTRL_COL: (u8, u8, u8, u8) = (255, 254, 254, 255); - static ref CTRL_TXT_COL: (u8, u8, u8, u8) = (0, 0, 0, 216); - static ref DIS_CTRL_TXT_COL: (u8, u8, u8, u8) = (0, 0, 0, 63); - static ref SEL_CTRL_COL: (u8, u8, u8, u8) = (164, 204, 254, 255); - static ref SEL_CTRL_TXT_COL: (u8, u8, u8, u8) = (0, 0, 0, 216); - static ref ALT_SEL_CTRL_TXT_COL: (u8, u8, u8, u8) = (255, 254, 254, 255); - static ref SCRUB_BG_COL: (u8, u8, u8, u8) = (255, 254, 254, 255); - static ref WIN_FRM_TXT_COL: (u8, u8, u8, u8) = (0, 0, 0, 216); - static ref PAGE_BG_COL: (u8, u8, u8, u8) = (131, 131, 131, 229); - static ref FIND_HLT_COL: (u8, u8, u8, u8) = (255, 255, 10, 255); - static ref HLT_COL: (u8, u8, u8, u8) = (255, 254, 254, 255); - static ref SHDW_COL: (u8, u8, u8, u8) = (0, 0, 0, 255); -} - -fn aqua_light_button_up_box(x: i32, y: i32, w: i32, h: i32, c: Color) { - let col = &CTRL_COL; - let svg = format!( - " - - - - - - - - ", - w, - h, - col.0 - 10, - col.1 - 10, - col.2 - 10, - col.0, - col.1, - col.2, - h / 4 - ); - let mut image = image::SvgImage::from_data(&svg).unwrap(); - image.draw(x, y, w, h); -} - -fn aqua_light_depressed_down_box(x: i32, y: i32, w: i32, h: i32, c: Color) { - let col = &SYS_CYAN; - let svg = format!( - " - - - - - - - - ", - w, - h, - col.0 - 10, - col.1 - 10, - col.2 - 10, - col.0, - col.1, - col.2, - h / 4 - ); - let mut image = image::SvgImage::from_data(&svg).unwrap(); - image.draw(x, y, w, h); -} - -fn aqua_light_radio_round_down_box(x: i32, y: i32, w: i32, h: i32, c: Color) { - let col = &CTRL_ACC_COL; - let svg = format!( - " - - ", - w, - h, - w / 2, - h / 2, - w / 2, - col.0, - col.1, - col.2 - ); - let mut image = image::SvgImage::from_data(&svg).unwrap(); - image.draw(x, y, w, h); -} - -fn use_aqua_light_scheme() { - app::set_scheme(app::Scheme::Gtk); - app::set_frame_type_cb(FrameType::UpBox, aqua_light_button_up_box, 1, 1, 2, 2); - app::set_frame_type2(FrameType::DownBox, FrameType::UpBox); - app::set_frame_type2(OS_DEFAULT_BUTTON_UP_BOX, FrameType::UpBox); - app::set_frame_type_cb( - OS_DEFAULT_DEPRESSED_DOWN_BOX, - aqua_light_depressed_down_box, - 1, - 1, - 2, - 2, - ); - app::set_frame_type_cb( - OS_RADIO_ROUND_DOWN_BOX, - aqua_light_radio_round_down_box, - 2, - 2, - 4, - 4, - ); - app::set_frame_type2(FrameType::RoundDownBox, OS_RADIO_ROUND_DOWN_BOX); - app::set_frame_type2(OS_BG_BOX, FrameType::FlatBox); - // app::set_frame_type_cb(OS_BG_DOWN_BOX, OS_BG_BOX); -} - -fn use_aqua_light_colors() { - app::background(BG_COL.0, BG_COL.1, BG_COL.2); - app::foreground(FG_COL.0, FG_COL.1, FG_COL.2); - app::background2(BG2_COL.0, BG2_COL.1, BG2_COL.2); - app::set_color(Color::Inactive, 0x4D, 0x4D, 0x69); - app::set_color(Color::Selection, 255, 255, 255); - app::set_color(Color::Free, 0xFB, 0xFB, 0xFB); - Tooltip::set_color(Color::from_rgb(0xFF, 0xFF, 0xC7)); - Tooltip::set_text_color(Color::ForeGround); -} - -pub(crate) fn use_aqua_light_theme() { - use_aqua_light_scheme(); - use_aqua_light_colors(); - use_native_settings(); -} diff --git a/src/widget_themes/mod.rs b/src/widget_themes/mod.rs index 2505f14..63de0f4 100644 --- a/src/widget_themes/mod.rs +++ b/src/widget_themes/mod.rs @@ -11,8 +11,6 @@ use fltk::{ pub(crate) mod aero; pub(crate) mod aqua_classic; -pub(crate) mod aqua_dark; -pub(crate) mod aqua_light; pub(crate) mod blue; pub(crate) mod classic; pub(crate) mod dark;