Skip to content

Commit

Permalink
add prelim aqua_dark and aqua_light
Browse files Browse the repository at this point in the history
  • Loading branch information
MoAlyousef committed Sep 25, 2021
1 parent 0fe81df commit 7dde19a
Show file tree
Hide file tree
Showing 10 changed files with 730 additions and 134 deletions.
2 changes: 0 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ exclude = ["/screenshots", "./examples"]

[dependencies]
fltk = "1.1.6"

[target.'cfg(target_os = "macos")'.dependencies]
lazy_static = "1.4"

[target.'cfg(target_os = "macos")'.build-dependencies]
Expand Down
18 changes: 0 additions & 18 deletions examples/aqua2.rs

This file was deleted.

14 changes: 14 additions & 0 deletions examples/aqua_dark.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
use fltk::{prelude::*, *};
use fltk_theme::{widget_themes, WidgetTheme, ThemeType};

fn main() {
let a = app::App::default();
let widget_theme = WidgetTheme::new(ThemeType::AquaLight);
widget_theme.apply();
let mut win = window::Window::default().with_size(400, 300);
let mut btn = button::Button::new(160, 200, 80, 30, "Hello");
// btn.set_frame(widget_themes::OS_DEFAULT_BUTTON_UP_BOX);
win.end();
win.show();
a.run().unwrap();
}
4 changes: 2 additions & 2 deletions examples/frames.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ fn main() {
theme.apply();
let mut win = window::Window::default().with_size(800, 800);
let mut choice = menu::Choice::new(300, 10, 200, 30, None);
choice.add_choice("Classic|Aero|Metro|Aqua|Greybird|Blue|HighContrast|Dark|Fluent");
choice.add_choice("Classic|Aero|Metro|AquaClassic|Greybird|Blue|HighContrast|Dark|Fluent");
choice.set_value(6);
choice.set_frame(OS_PANEL_THIN_UP_BOX);
let mut vgrid = group::VGrid::new(50, 100, 700, 700, None);
Expand Down Expand Up @@ -105,7 +105,7 @@ fn main() {
0 => WidgetTheme::new(ThemeType::Classic),
1 => WidgetTheme::new(ThemeType::Aero),
2 => WidgetTheme::new(ThemeType::Metro),
3 => WidgetTheme::new(ThemeType::Aqua),
3 => WidgetTheme::new(ThemeType::AquaClassic),
4 => WidgetTheme::new(ThemeType::Greybird),
5 => WidgetTheme::new(ThemeType::Blue),
6 => WidgetTheme::new(ThemeType::HighContrast),
Expand Down
6 changes: 3 additions & 3 deletions examples/widget_theme.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ use fltk_theme::{widget_themes, ThemeType, WidgetTheme};

fn main() {
let a = app::App::default();
let theme = WidgetTheme::new(ThemeType::Aqua);
let theme = WidgetTheme::new(ThemeType::AquaClassic);
theme.apply();
let mut win = window::Window::default().with_size(400, 300);
let mut choice = menu::Choice::new(100, 100, 200, 30, None);
choice.add_choice("Classic|Aero|Metro|Aqua|Greybird|Blue|HighContrast|Dark|Fluent");
choice.add_choice("Classic|Aero|Metro|AquaClassic|Greybird|Blue|HighContrast|Dark|Fluent");
choice.set_value(3);
choice.set_frame(widget_themes::OS_PANEL_THIN_UP_BOX);
let mut check = button::CheckButton::new(160, 150, 80, 30, " Check");
Expand All @@ -25,7 +25,7 @@ fn main() {
0 => WidgetTheme::new(ThemeType::Classic),
1 => WidgetTheme::new(ThemeType::Aero),
2 => WidgetTheme::new(ThemeType::Metro),
3 => WidgetTheme::new(ThemeType::Aqua),
3 => WidgetTheme::new(ThemeType::AquaClassic),
4 => WidgetTheme::new(ThemeType::Greybird),
5 => WidgetTheme::new(ThemeType::Blue),
6 => WidgetTheme::new(ThemeType::HighContrast),
Expand Down
15 changes: 8 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,11 @@ pub enum ThemeType {
/// Windows 8
Metro,
/// Classic MacOS
Aqua,
#[cfg(target_os = "macos")]
/// Modern MacOS using system colors, supports Dark theme
Aqua2,
AquaClassic,
/// Modern MacOS using system colors, Dark theme
AquaDark,
/// Modern MacOS using system colors, light theme
AquaLight,
/// Xfce
Greybird,
/// Windows 2000
Expand Down Expand Up @@ -164,9 +165,9 @@ impl WidgetTheme {
match self.theme {
ThemeType::Classic => widget_themes::classic::use_classic_theme(),
ThemeType::Aero => widget_themes::aero::use_aero_theme(),
ThemeType::Aqua => widget_themes::aqua::use_aqua_theme(),
#[cfg(target_os = "macos")]
ThemeType::Aqua2 => widget_themes::aqua2::use_aqua2_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(),
Expand Down
92 changes: 46 additions & 46 deletions src/widget_themes/aqua.rs → src/widget_themes/aqua_classic.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use super::*;
use fltk::{app, enums::Color, misc::Tooltip};

fn aqua_button_up_frame(x: i32, y: i32, w: i32, h: i32, c: Color) {
fn aqua_classic_button_up_frame(x: i32, y: i32, w: i32, h: i32, c: Color) {
// top outer border
set_draw_color(activated_color(Color::from_rgb(0x9A, 0x9A, 0x9A)));
draw_xyline(x + 3, y, x + w - 4);
Expand Down Expand Up @@ -34,7 +34,7 @@ fn aqua_button_up_frame(x: i32, y: i32, w: i32, h: i32, c: Color) {
draw_arc(x + w - 8, y, 8, 8, 0.0, 90.0);
}

fn aqua_button_up_box(x: i32, y: i32, w: i32, h: i32, c: Color) {
fn aqua_classic_button_up_box(x: i32, y: i32, w: i32, h: i32, c: Color) {
if w >= h {
// top gradient
vertical_gradient(
Expand Down Expand Up @@ -68,21 +68,21 @@ fn aqua_button_up_box(x: i32, y: i32, w: i32, h: i32, c: Color) {
set_draw_color(activated_color(Color::from_rgb(0xEF, 0xEE, 0xEC)));
draw_yxline(x + w - 3, y + 2, y + h - 3);
}
aqua_button_up_frame(x, y, w, h, c);
aqua_classic_button_up_frame(x, y, w, h, c);
}

fn aqua_panel_thin_up_frame(x: i32, y: i32, w: i32, h: i32, c: Color) {
fn aqua_classic_panel_thin_up_frame(x: i32, y: i32, w: i32, h: i32, c: Color) {
set_draw_color(activated_color(devalued(c, 0.06751)));
draw_rect(x, y, w, h);
}

fn aqua_panel_thin_up_box(x: i32, y: i32, w: i32, h: i32, c: Color) {
fn aqua_classic_panel_thin_up_box(x: i32, y: i32, w: i32, h: i32, c: Color) {
set_draw_color(activated_color(c));
draw_rectf(x + 1, y + 1, w - 2, h - 2);
aqua_panel_thin_up_frame(x, y, w, h, c);
aqua_classic_panel_thin_up_frame(x, y, w, h, c);
}

fn aqua_spacer_thin_down_frame(x: i32, y: i32, w: i32, h: i32, c: Color) {
fn aqua_classic_spacer_thin_down_frame(x: i32, y: i32, w: i32, h: i32, c: Color) {
// top and left borders
set_draw_color(activated_color(Color::from_rgb(0xD6, 0xD6, 0xD6)));
draw_yxline2(x, y + h - 2, y, x + w - 2);
Expand All @@ -91,18 +91,18 @@ fn aqua_spacer_thin_down_frame(x: i32, y: i32, w: i32, h: i32, c: Color) {
draw_xyline2(x, y + h - 1, x + w - 1, y);
}

fn aqua_spacer_thin_down_box(x: i32, y: i32, w: i32, h: i32, c: Color) {
fn aqua_classic_spacer_thin_down_box(x: i32, y: i32, w: i32, h: i32, c: Color) {
set_draw_color(activated_color(c));
draw_rectf(x + 1, y + 1, w - 2, h - 2);
aqua_spacer_thin_down_frame(x, y, w, h, c);
aqua_classic_spacer_thin_down_frame(x, y, w, h, c);
}

fn aqua_radio_round_down_frame(x: i32, y: i32, w: i32, h: i32, c: Color) {
fn aqua_classic_radio_round_down_frame(x: i32, y: i32, w: i32, h: i32, c: Color) {
set_draw_color(activated_color(devalued(c, 0.42194)));
draw_arc(x, y, w, h, 0.0, 360.0);
}

fn aqua_radio_round_down_box(x: i32, y: i32, w: i32, h: i32, c: Color) {
fn aqua_classic_radio_round_down_box(x: i32, y: i32, w: i32, h: i32, c: Color) {
// top edges
set_draw_color(activated_color(Color::from_rgb(0xF6, 0xF6, 0xF6)));
draw_arc(x + 1, y + 1, w - 2, h - 2, 0.0, 180.0);
Expand All @@ -124,10 +124,10 @@ fn aqua_radio_round_down_box(x: i32, y: i32, w: i32, h: i32, c: Color) {
// bottom gradient
set_draw_color(activated_color(Color::from_rgb(0xEF, 0xEE, 0xEC)));
draw_xyline(x + 2, y + h - 3, x + w - 3);
aqua_radio_round_down_frame(x, y, w, h, c);
aqua_classic_radio_round_down_frame(x, y, w, h, c);
}

fn aqua_depressed_down_frame(x: i32, y: i32, w: i32, h: i32, c: Color) {
fn aqua_classic_depressed_down_frame(x: i32, y: i32, w: i32, h: i32, c: Color) {
// top outer border
set_draw_color(activated_color(Color::from_rgb(0x4C, 0x54, 0xAA)));
draw_xyline(x + 3, y, x + w - 4);
Expand Down Expand Up @@ -159,7 +159,7 @@ fn aqua_depressed_down_frame(x: i32, y: i32, w: i32, h: i32, c: Color) {
draw_arc(x + w - 8, y + h - 8, 8, 8, 270.0, 360.0);
}

fn aqua_depressed_down_box(x: i32, y: i32, w: i32, h: i32, c: Color) {
fn aqua_classic_depressed_down_box(x: i32, y: i32, w: i32, h: i32, c: Color) {
// top gradient
vertical_gradient(
x + 2,
Expand All @@ -178,10 +178,10 @@ fn aqua_depressed_down_box(x: i32, y: i32, w: i32, h: i32, c: Color) {
Color::from_rgb(0x46, 0x93, 0xE9),
Color::from_rgb(0xAA, 0xD4, 0xF0),
);
aqua_depressed_down_frame(x, y, w, h, c);
aqua_classic_depressed_down_frame(x, y, w, h, c);
}

fn aqua_input_thin_down_frame(x: i32, y: i32, w: i32, h: i32, c: Color) {
fn aqua_classic_input_thin_down_frame(x: i32, y: i32, w: i32, h: i32, c: Color) {
// top outer border
set_draw_color(activated_color(Color::from_rgb(0x9B, 0x9B, 0x9B)));
draw_xyline(x, y, x + w - 1);
Expand All @@ -196,13 +196,13 @@ fn aqua_input_thin_down_frame(x: i32, y: i32, w: i32, h: i32, c: Color) {
draw_yxline3(x + 1, y + h - 2, y + 2, x + w - 2, y + h - 2);
}

fn aqua_input_thin_down_box(x: i32, y: i32, w: i32, h: i32, c: Color) {
fn aqua_classic_input_thin_down_box(x: i32, y: i32, w: i32, h: i32, c: Color) {
set_draw_color(activated_color(Color::from_rgb(0xFF, 0xFF, 0xFF)));
draw_rectf(x + 2, y + 3, w - 4, h - 4);
aqua_input_thin_down_frame(x, y, w, h, c);
aqua_classic_input_thin_down_frame(x, y, w, h, c);
}

fn aqua_default_button_up_frame(x: i32, y: i32, w: i32, h: i32, c: Color) {
fn aqua_classic_default_button_up_frame(x: i32, y: i32, w: i32, h: i32, c: Color) {
// top outer border
set_draw_color(activated_color(Color::from_rgb(0x4E, 0x59, 0xA6)));
draw_xyline(x + 3, y, x + w - 4);
Expand Down Expand Up @@ -234,7 +234,7 @@ fn aqua_default_button_up_frame(x: i32, y: i32, w: i32, h: i32, c: Color) {
draw_arc(x + w - 8, y + h - 8, 8, 8, 270.0, 360.0);
}

fn aqua_default_button_up_box(x: i32, y: i32, w: i32, h: i32, c: Color) {
fn aqua_classic_default_button_up_box(x: i32, y: i32, w: i32, h: i32, c: Color) {
// top gradient
vertical_gradient(
x + 2,
Expand All @@ -253,10 +253,10 @@ fn aqua_default_button_up_box(x: i32, y: i32, w: i32, h: i32, c: Color) {
Color::from_rgb(0x59, 0xB5, 0xF1),
Color::from_rgb(0xBA, 0xE9, 0xF7),
);
aqua_default_button_up_frame(x, y, w, h, c);
aqua_classic_default_button_up_frame(x, y, w, h, c);
}

fn aqua_tabs_frame(x: i32, y: i32, w: i32, h: i32, c: Color) {
fn aqua_classic_tabs_frame(x: i32, y: i32, w: i32, h: i32, c: Color) {
// top outer border
set_draw_color(activated_color(Color::from_rgb(0xAE, 0xAE, 0xAE)));
draw_xyline(x + 3, y, x + w - 4);
Expand Down Expand Up @@ -287,13 +287,13 @@ fn aqua_tabs_frame(x: i32, y: i32, w: i32, h: i32, c: Color) {
draw_arc(x + w - 8, y + h - 8, 8, 8, 270.0, 360.0);
}

fn aqua_tabs_box(x: i32, y: i32, w: i32, h: i32, c: Color) {
fn aqua_classic_tabs_box(x: i32, y: i32, w: i32, h: i32, c: Color) {
set_draw_color(activated_color(c));
draw_rectf(x + 2, y + 2, w - 4, h - 4);
aqua_tabs_frame(x, y, w, h, c);
aqua_classic_tabs_frame(x, y, w, h, c);
}

fn aqua_swatch_frame(x: i32, y: i32, w: i32, h: i32, c: Color) {
fn aqua_classic_swatch_frame(x: i32, y: i32, w: i32, h: i32, c: Color) {
// outer border
set_draw_color(activated_color(Color::from_rgb(0xA3, 0xA3, 0xA3)));
draw_rect(x, y, w, h);
Expand All @@ -302,67 +302,67 @@ fn aqua_swatch_frame(x: i32, y: i32, w: i32, h: i32, c: Color) {
draw_rect(x + 1, y + 1, w - 2, h - 2);
}

fn aqua_swatch_box(x: i32, y: i32, w: i32, h: i32, c: Color) {
fn aqua_classic_swatch_box(x: i32, y: i32, w: i32, h: i32, c: Color) {
set_draw_color(activated_color(c));
draw_rectf(x + 2, y + 2, w - 4, h - 4);
aqua_swatch_frame(x, y, w, h, c);
aqua_classic_swatch_frame(x, y, w, h, c);
}

fn use_aqua_scheme() {
fn use_aqua_classic_scheme() {
app::set_scheme(app::Scheme::Gtk);
app::set_frame_type_cb(OS_BUTTON_UP_BOX, aqua_button_up_box, 1, 1, 2, 2);
app::set_frame_type_cb(OS_BUTTON_UP_BOX, aqua_classic_button_up_box, 1, 1, 2, 2);
app::set_frame_type2(OS_CHECK_DOWN_BOX, OS_BUTTON_UP_BOX);
app::set_frame_type_cb(OS_BUTTON_UP_FRAME, aqua_button_up_frame, 1, 1, 2, 2);
app::set_frame_type_cb(OS_BUTTON_UP_FRAME, aqua_classic_button_up_frame, 1, 1, 2, 2);
app::set_frame_type2(OS_CHECK_DOWN_FRAME, OS_BUTTON_UP_FRAME);
app::set_frame_type_cb(OS_PANEL_THIN_UP_BOX, aqua_panel_thin_up_box, 1, 1, 2, 2);
app::set_frame_type_cb(OS_PANEL_THIN_UP_BOX, aqua_classic_panel_thin_up_box, 1, 1, 2, 2);
app::set_frame_type_cb(
OS_SPACER_THIN_DOWN_BOX,
aqua_spacer_thin_down_box,
aqua_classic_spacer_thin_down_box,
1,
1,
2,
2,
);
app::set_frame_type_cb(OS_PANEL_THIN_UP_FRAME, aqua_panel_thin_up_frame, 1, 1, 2, 2);
app::set_frame_type_cb(OS_PANEL_THIN_UP_FRAME, aqua_classic_panel_thin_up_frame, 1, 1, 2, 2);
app::set_frame_type_cb(
OS_SPACER_THIN_DOWN_FRAME,
aqua_spacer_thin_down_frame,
aqua_classic_spacer_thin_down_frame,
1,
1,
2,
2,
);
app::set_frame_type_cb(
OS_RADIO_ROUND_DOWN_BOX,
aqua_radio_round_down_box,
aqua_classic_radio_round_down_box,
2,
2,
4,
4,
);
app::set_frame_type2(OS_HOVERED_UP_BOX, OS_BUTTON_UP_BOX);
app::set_frame_type_cb(OS_DEPRESSED_DOWN_BOX, aqua_depressed_down_box, 1, 1, 2, 2);
app::set_frame_type_cb(OS_DEPRESSED_DOWN_BOX, aqua_classic_depressed_down_box, 1, 1, 2, 2);
app::set_frame_type2(OS_HOVERED_UP_FRAME, OS_BUTTON_UP_FRAME);
app::set_frame_type_cb(
OS_DEPRESSED_DOWN_FRAME,
aqua_depressed_down_frame,
aqua_classic_depressed_down_frame,
1,
1,
2,
2,
);
app::set_frame_type_cb(OS_INPUT_THIN_DOWN_BOX, aqua_input_thin_down_box, 2, 3, 4, 6);
app::set_frame_type_cb(OS_INPUT_THIN_DOWN_BOX, aqua_classic_input_thin_down_box, 2, 3, 4, 6);
app::set_frame_type_cb(
OS_INPUT_THIN_DOWN_FRAME,
aqua_input_thin_down_frame,
aqua_classic_input_thin_down_frame,
2,
3,
4,
6,
);
app::set_frame_type_cb(
OS_DEFAULT_BUTTON_UP_BOX,
aqua_default_button_up_box,
aqua_classic_default_button_up_box,
1,
1,
2,
Expand All @@ -371,8 +371,8 @@ fn use_aqua_scheme() {
app::set_frame_type2(OS_DEFAULT_HOVERED_UP_BOX, OS_HOVERED_UP_BOX);
app::set_frame_type2(OS_DEFAULT_DEPRESSED_DOWN_BOX, OS_DEPRESSED_DOWN_BOX);
app::set_frame_type2(OS_TOOLBAR_BUTTON_HOVER_BOX, FrameType::FlatBox);
app::set_frame_type_cb(OS_TABS_BOX, aqua_tabs_box, 2, 1, 4, 2);
app::set_frame_type_cb(OS_SWATCH_BOX, aqua_swatch_box, 2, 2, 4, 4);
app::set_frame_type_cb(OS_TABS_BOX, aqua_classic_tabs_box, 2, 1, 4, 2);
app::set_frame_type_cb(OS_SWATCH_BOX, aqua_classic_swatch_box, 2, 2, 4, 4);
app::set_frame_type2(OS_MINI_BUTTON_UP_BOX, OS_BUTTON_UP_BOX);
app::set_frame_type2(OS_MINI_DEPRESSED_DOWN_BOX, OS_DEPRESSED_DOWN_BOX);
app::set_frame_type2(OS_MINI_BUTTON_UP_FRAME, OS_BUTTON_UP_FRAME);
Expand All @@ -384,7 +384,7 @@ fn use_aqua_scheme() {
// app::set_frame_type_cb(OS_BG_DOWN_BOX, OS_BG_BOX);
}

fn use_aqua_colors() {
fn use_aqua_classic_colors() {
app::background(0xED, 0xED, 0xED);
app::background2(0xFF, 0xFF, 0xFF);
app::foreground(0x00, 0x00, 0x00);
Expand All @@ -395,8 +395,8 @@ fn use_aqua_colors() {
Tooltip::set_text_color(Color::ForeGround);
}

pub(crate) fn use_aqua_theme() {
use_aqua_scheme();
use_aqua_colors();
pub(crate) fn use_aqua_classic_theme() {
use_aqua_classic_scheme();
use_aqua_classic_colors();
use_native_settings();
}
Loading

0 comments on commit 7dde19a

Please sign in to comment.