Skip to content

Commit

Permalink
Merge pull request #11 from StarterX4/sweet-theme
Browse files Browse the repository at this point in the history
"Sweet" Widget Scheme
  • Loading branch information
MoAlyousef authored Jan 27, 2025
2 parents f923b7f + 6107551 commit 4393a1c
Show file tree
Hide file tree
Showing 11 changed files with 274 additions and 1 deletion.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ You can check the frames example to see all `FrameType`'s you can apply to you w

## Widget Schemes

These provide schemes for widgets without color theming. Currently there are 6 schemes:
These provide schemes for widgets without color theming. Currently there are 7 schemes:
- Clean: Taken from NTK's clear scheme.
- ![alt_test](screenshots/clean.jpg)

Expand All @@ -186,6 +186,10 @@ These provide schemes for widgets without color theming. Currently there are 6 s
- SvgBased: This overrides FLTK's Base scheme round/rounded/oval FrameTypes which are drawn using scalable vector graphics.
- ![alt_test](screenshots/svgbased.jpg)

- Sweet: Tries to mimic the Sweet theme for GNOME/KDE.
- ![alt_test](screenshots/sweet_dark.png)
- ![alt_test](screenshots/sweet_light.png)

## Colors

The crate also provides colors, namely html colors and aqua colors.
Expand Down
53 changes: 53 additions & 0 deletions examples/sweet_dark.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
use fltk::{enums::*, prelude::*, *};
use fltk_theme::widget_schemes::sweet::frames::*;
use fltk_theme::{SchemeType, WidgetScheme};

use fltk_theme::colors::sweet::dark::*; // get all the dark sweet colors

// use fltk_theme::colors::sweet::light::*; // get all the light sweet colors

fn main() {
let a = app::App::default();
app::set_font_size(12);
let bg = windowBackgroundColor.to_rgb();
app::background(bg.0, bg.1, bg.2);
let ctrl = controlAccentColor.to_rgb();
app::background2(ctrl.0, ctrl.1, ctrl.2);
let lbl = labelColor.to_rgb();
app::foreground(lbl.0, lbl.1, lbl.2);
let txt_sel_bg = selectedTextBackgroundColor.to_rgb();
app::set_selection_color(txt_sel_bg.0, txt_sel_bg.1, txt_sel_bg.2);
//app::set_color(Color::Selection, 255, 255, 255);
let widget_scheme = WidgetScheme::new(SchemeType::Sweet);
widget_scheme.apply();
let mut win = window::Window::default()
.with_size(400, 300)
.with_label("Sweet Dark");
let mut col = group::Flex::default()
.with_size(340, 240)
.center_of_parent()
.column();
col.set_frame(FrameType::NoBox);
col.set_margins(100, 40, 100, 40);
let mut choice = menu::Choice::default();
choice.set_color(*controlColor);
choice.add_choice("Opt1|Opt2|Opt3");
choice.set_value(2);
let mut inp = input::Input::default();
inp.set_color(*controlColor);
let mut check = button::CheckButton::default().with_label(" Check");
check.set_value(true);
check.set_frame(enums::FrameType::FlatBox);
let mut round = button::RoundButton::default().with_label(" Round");
round.set_value(true);
round.set_frame(enums::FrameType::FlatBox);
let mut btn = button::Button::default().with_label("Hello");
btn.set_color(*controlColor);
btn.set_selection_color(*controlAccentColor);
btn.set_frame(OS_DEFAULT_BUTTON_UP_BOX);
col.end();
win.end();
win.make_resizable(true);
win.show();
a.run().unwrap();
}
Binary file added screenshots/sweet_dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screenshots/sweet_light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/colors/mod.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
pub mod aqua;
pub mod html;
pub mod sweet;
88 changes: 88 additions & 0 deletions src/colors/sweet/dark.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
#![allow(non_upper_case_globals)]

use fltk::enums::Color;
use fltk::utils::oncelock::Lazy;

pub static backgroundColor2: Lazy<Color> = Lazy::new(|| Color::from_rgba_tuple((22, 25, 37, 255)));
pub static windowBackgroundColor: Lazy<Color> =
Lazy::new(|| Color::from_rgba_tuple((24, 27, 40, 255)));
pub static labelColor: Lazy<Color> = Lazy::new(|| Color::from_rgba_tuple((195, 199, 209, 255)));
pub static controlBackgroundColor: Lazy<Color> =
Lazy::new(|| Color::from_rgba_tuple((30, 34, 51, 255)));
pub static secondaryLabelColor: Lazy<Color> =
Lazy::new(|| Color::from_rgba_tuple((102, 106, 115, 255)));
pub static tertiaryLabelColor: Lazy<Color> =
Lazy::new(|| Color::from_rgba_tuple((102, 106, 115, 191)));
pub static quaternaryLabelColor: Lazy<Color> =
Lazy::new(|| Color::from_rgba_tuple((102, 106, 115, 127)));
pub static textColor: Lazy<Color> = Lazy::new(|| Color::from_rgba_tuple((211, 218, 227, 255)));
pub static placeholderTextColor: Lazy<Color> =
Lazy::new(|| Color::from_rgba_tuple((102, 106, 115, 255)));
pub static selectedTextColor: Lazy<Color> =
Lazy::new(|| Color::from_rgba_tuple((254, 254, 254, 255)));
pub static textBackgroundColor: Lazy<Color> =
Lazy::new(|| Color::from_rgba_tuple((30, 34, 51, 255)));
pub static selectedTextBackgroundColor: Lazy<Color> =
Lazy::new(|| Color::from_rgba_tuple((197, 14, 210, 255)));
pub static keyboardFocusIndicatorColor: Lazy<Color> =
Lazy::new(|| Color::from_rgba_tuple((197, 14, 210, 191)));
pub static unemphasizedSelectedTextColor: Lazy<Color> =
Lazy::new(|| Color::from_rgba_tuple((254, 254, 254, 255)));
pub static unemphasizedSelectedTextBackgroundColor: Lazy<Color> =
Lazy::new(|| Color::from_rgba_tuple((47, 52, 63, 255)));
pub static linkColor: Lazy<Color> = Lazy::new(|| Color::from_rgba_tuple((82, 148, 226, 255)));
pub static separatorColor: Lazy<Color> = Lazy::new(|| Color::from_rgba_tuple((102, 106, 115, 63)));
pub static selectedContentBackgroundColor: Lazy<Color> =
Lazy::new(|| Color::from_rgba_tuple((197, 14, 210, 255)));
pub static unemphasizedSelectedContentBackgroundColor: Lazy<Color> =
Lazy::new(|| Color::from_rgba_tuple((47, 52, 63, 255)));
pub static selectedMenuItemTextColor: Lazy<Color> =
Lazy::new(|| Color::from_rgba_tuple((254, 254, 254, 255)));
pub static gridColor: Lazy<Color> = Lazy::new(|| Color::from_rgba_tuple((22, 25, 37, 255)));
pub static headerTextColor: Lazy<Color> =
Lazy::new(|| Color::from_rgba_tuple((211, 218, 227, 255)));
pub static origControlAccentColor: Lazy<Color> =
Lazy::new(|| Color::from_rgba_tuple((0, 232, 198, 255))); // Sweet's original green color for checkboxes
pub static controlAccentColor: Lazy<Color> =
Lazy::new(|| Color::from_rgba_tuple((197, 14, 210, 255)));
pub static controlColor: Lazy<Color> = Lazy::new(|| Color::from_rgba_tuple((102, 106, 115, 191)));
pub static controlTextColor: Lazy<Color> =
Lazy::new(|| Color::from_rgba_tuple((195, 199, 209, 255)));
pub static disabledControlTextColor: Lazy<Color> =
Lazy::new(|| Color::from_rgba_tuple((102, 106, 115, 127)));
pub static selectedControlColor: Lazy<Color> =
Lazy::new(|| Color::from_rgba_tuple((197, 14, 210, 255)));
pub static selectedControlTextColor: Lazy<Color> =
Lazy::new(|| Color::from_rgba_tuple((195, 199, 209, 255)));
pub static alternateSelectedControlTextColor: Lazy<Color> =
Lazy::new(|| Color::from_rgba_tuple((254, 254, 254, 255)));
pub static scrubberTexturedBackgroundColor: Lazy<Color> =
Lazy::new(|| Color::from_rgba_tuple((211, 218, 227, 255)));
pub static windowFrameTextColor: Lazy<Color> =
Lazy::new(|| Color::from_rgba_tuple((195, 199, 209, 255)));
pub static underPageBackgroundColor: Lazy<Color> =
Lazy::new(|| Color::from_rgba_tuple((22, 25, 37, 255)));
pub static findHighlightColor: Lazy<Color> =
Lazy::new(|| Color::from_rgba_tuple((255, 106, 0, 255)));
pub static highlightColor: Lazy<Color> = Lazy::new(|| Color::from_rgba_tuple((197, 14, 210, 255)));
pub static shadowColor: Lazy<Color> = Lazy::new(|| Color::from_rgba_tuple((0, 0, 0, 255)));
pub static systemBrownColor: Lazy<Color> =
Lazy::new(|| Color::from_rgba_tuple((155, 123, 85, 255)));
pub static systemFuchsiaColor: Lazy<Color> =
Lazy::new(|| Color::from_rgba_tuple((197, 14, 210, 255)));
pub static systemGrayColor: Lazy<Color> =
Lazy::new(|| Color::from_rgba_tuple((133, 133, 139, 255)));
pub static systemGreenColor: Lazy<Color> = Lazy::new(|| Color::from_rgba_tuple((48, 211, 58, 255)));
pub static systemIndigoColor: Lazy<Color> =
Lazy::new(|| Color::from_rgba_tuple((74, 64, 223, 255)));
pub static systemOrangeColor: Lazy<Color> =
Lazy::new(|| Color::from_rgba_tuple((252, 141, 13, 255)));
pub static systemPinkColor: Lazy<Color> = Lazy::new(|| Color::from_rgba_tuple((251, 25, 76, 255)));
pub static systemPurpleColor: Lazy<Color> =
Lazy::new(|| Color::from_rgba_tuple((157, 51, 213, 255)));
pub static systemRedColor: Lazy<Color> = Lazy::new(|| Color::from_rgba_tuple((251, 43, 44, 255)));
pub static systemTealColor: Lazy<Color> = Lazy::new(|| Color::from_rgba_tuple((76, 187, 242, 255)));
pub static systemYellowColor: Lazy<Color> =
Lazy::new(|| Color::from_rgba_tuple((254, 207, 14, 255)));
pub static systemBlueColor: Lazy<Color> = Lazy::new(|| Color::from_rgba_tuple((16, 106, 254, 255)));
pub static systemCyanColor: Lazy<Color> = Lazy::new(|| Color::from_rgba_tuple((90, 200, 245, 255)));
59 changes: 59 additions & 0 deletions src/colors/sweet/light.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#![allow(non_upper_case_globals)]

use fltk::enums::Color;
use fltk::utils::oncelock::Lazy;

pub static backgroundColor2: Lazy<Color> = Lazy::new(|| Color::from_rgb(230, 230, 230));
pub static windowBackgroundColor: Lazy<Color> = Lazy::new(|| Color::from_rgb(232, 234, 235));
pub static labelColor: Lazy<Color> = Lazy::new(|| Color::from_rgb(49, 54, 61));
pub static controlBackgroundColor: Lazy<Color> = Lazy::new(|| Color::from_rgb(230, 230, 230));
pub static secondaryLabelColor: Lazy<Color> = Lazy::new(|| Color::from_rgb(140, 142, 146));
pub static tertiaryLabelColor: Lazy<Color> = Lazy::new(|| Color::from_rgba_tuple((140, 142, 146, 191)));
pub static quaternaryLabelColor: Lazy<Color> = Lazy::new(|| Color::from_rgba_tuple((140, 142, 146, 127)));
pub static textColor: Lazy<Color> = Lazy::new(|| Color::from_rgb(49, 54, 61));
pub static placeholderTextColor: Lazy<Color> = Lazy::new(|| Color::from_rgb(140, 142, 146));
pub static selectedTextColor: Lazy<Color> = Lazy::new(|| Color::from_rgb(254, 254, 254));
pub static textBackgroundColor: Lazy<Color> = Lazy::new(|| Color::from_rgb(235, 240, 245));
pub static selectedTextBackgroundColor: Lazy<Color> =
Lazy::new(|| Color::from_rgba_tuple((197, 14, 210, 255)));
pub static keyboardFocusIndicatorColor: Lazy<Color> =
Lazy::new(|| Color::from_rgba_tuple((197, 14, 210, 191)));
pub static unemphasizedSelectedTextColor: Lazy<Color> = Lazy::new(|| Color::from_rgb(254, 254, 254));
pub static unemphasizedSelectedTextBackgroundColor: Lazy<Color> = Lazy::new(|| Color::from_rgb(232, 234, 236));
pub static linkColor: Lazy<Color> = Lazy::new(|| Color::from_rgb(82, 148, 226));
pub static separatorColor: Lazy<Color> = Lazy::new(|| Color::from_rgba_tuple((0, 0, 0, 63)));
pub static selectedContentBackgroundColor: Lazy<Color> =
Lazy::new(|| Color::from_rgba_tuple((197, 14, 210, 255)));
pub static unemphasizedSelectedContentBackgroundColor: Lazy<Color> = Lazy::new(|| Color::from_rgb(232, 234, 236));
pub static selectedMenuItemTextColor: Lazy<Color> = Lazy::new(|| Color::from_rgb(254, 254, 254));
pub static gridColor: Lazy<Color> = Lazy::new(|| Color::from_rgb(22, 25, 37));
pub static headerTextColor: Lazy<Color> = Lazy::new(|| Color::from_rgb(49, 54, 61));
pub static origControlAccentColor: Lazy<Color> =
Lazy::new(|| Color::from_rgba_tuple((0, 232, 198, 255))); // Sweet's original green color for checkboxes
pub static controlAccentColor: Lazy<Color> =
Lazy::new(|| Color::from_rgba_tuple((197, 14, 210, 255)));
pub static controlColor: Lazy<Color> = Lazy::new(|| Color::from_rgba_tuple((255, 255, 255, 255)));
pub static controlTextColor: Lazy<Color> = Lazy::new(|| Color::from_rgb(49, 54, 61));
pub static disabledControlTextColor: Lazy<Color> = Lazy::new(|| Color::from_rgba_tuple((140, 142, 146, 127)));
pub static selectedControlColor: Lazy<Color> = Lazy::new(|| Color::from_rgb(197, 14, 210));
pub static selectedControlTextColor: Lazy<Color> = Lazy::new(|| Color::from_rgb(49, 54, 61));
pub static alternateSelectedControlTextColor: Lazy<Color> = Lazy::new(|| Color::from_rgb(254, 254, 254));
pub static scrubberTexturedBackgroundColor: Lazy<Color> = Lazy::new(|| Color::from_rgb(211, 218, 227));
pub static windowFrameTextColor: Lazy<Color> = Lazy::new(|| Color::from_rgb(49, 54, 61));
pub static underPageBackgroundColor: Lazy<Color> = Lazy::new(|| Color::from_rgb(230, 230, 230));
pub static findHighlightColor: Lazy<Color> = Lazy::new(|| Color::from_rgb(255, 106, 0));
pub static highlightColor: Lazy<Color> = Lazy::new(|| Color::from_rgb(197, 14, 210));
pub static shadowColor: Lazy<Color> = Lazy::new(|| Color::from_rgba_tuple((0, 0, 0, 255)));
pub static systemBrownColor: Lazy<Color> = Lazy::new(|| Color::from_rgb(155, 123, 85));
pub static systemFuchsiaColor: Lazy<Color> = Lazy::new(|| Color::from_rgb(197, 14, 210));
pub static systemGrayColor: Lazy<Color> = Lazy::new(|| Color::from_rgb(133, 133, 139));
pub static systemGreenColor: Lazy<Color> = Lazy::new(|| Color::from_rgb(48, 211, 58));
pub static systemIndigoColor: Lazy<Color> = Lazy::new(|| Color::from_rgb(74, 64, 223));
pub static systemOrangeColor: Lazy<Color> = Lazy::new(|| Color::from_rgb(252, 141, 13));
pub static systemPinkColor: Lazy<Color> = Lazy::new(|| Color::from_rgb(251, 25, 76));
pub static systemPurpleColor: Lazy<Color> = Lazy::new(|| Color::from_rgb(157, 51, 213));
pub static systemRedColor: Lazy<Color> = Lazy::new(|| Color::from_rgb(251, 43, 44));
pub static systemTealColor: Lazy<Color> = Lazy::new(|| Color::from_rgba_tuple((76, 187, 242, 255)));
pub static systemYellowColor: Lazy<Color> = Lazy::new(|| Color::from_rgba_tuple((254, 207, 14, 255)));
pub static systemBlueColor: Lazy<Color> = Lazy::new(|| Color::from_rgba_tuple((16, 106, 254, 255)));
pub static systemCyanColor: Lazy<Color> = Lazy::new(|| Color::from_rgba_tuple((90, 200, 245, 255)));
2 changes: 2 additions & 0 deletions src/colors/sweet/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pub mod dark;
pub mod light;
3 changes: 3 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ pub enum SchemeType {
- OFlatFrame
*/
SvgBased,
/// A scheme mimicking the Sweet theme for GNOME/KDE
Sweet,
}

/// A widget scheme sets the style of drawing a widget without interfering with coloring
Expand All @@ -174,6 +176,7 @@ impl WidgetScheme {
SchemeType::Fluent => widget_schemes::fluent::use_fluent_scheme(),
SchemeType::Gleam => widget_schemes::gleam::use_gleam_scheme(),
SchemeType::SvgBased => widget_schemes::svg_based::use_svg_based_scheme(),
SchemeType::Sweet => widget_schemes::sweet::use_sweet_scheme(),
}
}
}
1 change: 1 addition & 0 deletions src/widget_schemes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ pub(crate) mod crystal;
pub mod fluent;
pub(crate) mod gleam;
pub(crate) mod svg_based;
pub mod sweet;
62 changes: 62 additions & 0 deletions src/widget_schemes/sweet.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
use fltk::{
app, draw,
enums::{Color, FrameType},
};

fn up_box(x: i32, y: i32, w: i32, h: i32, c: Color) {
let col1 = c.to_rgb();
let col = Color::color_average(c, Color::Background, 0.8).to_rgb();
draw::draw_rbox(x, y, w, h, 5, true, Color::from_rgb(col.0, col.1, col.2));
}

fn default_button_up_box(x: i32, y: i32, w: i32, h: i32, c: Color) {
let col1 = c.to_rgb();
let col = Color::color_average(c, Color::Background, 0.8).to_rgb();
draw::draw_rbox(x, y, w, h, 5, true, Color::from_rgb(col.0, col.1, col.2));
}

fn down_box(x: i32, y: i32, w: i32, h: i32, c: Color) {
let col1 = c.to_rgb();
let col = Color::color_average(c, Color::Background, 0.8).to_rgb();
draw::draw_rbox(x, y, w, h, 5, true, Color::from_rgb(col.0, col.1, col.2));
}

fn radio_round_down_box(x: i32, y: i32, w: i32, h: i32, c: Color) {
let col = c.to_rgb();
draw::draw_box(FrameType::OFlatBox, x, y, w, h, c);
}

fn border_box(x: i32, y: i32, w: i32, h: i32, c: Color) {
draw::draw_rbox(
x,
y,
w,
h,
5,
true,
*crate::colors::sweet::dark::systemFuchsiaColor,
);
}

fn use_scheme() {
app::set_scheme(app::Scheme::Gtk);
// app::set_menu_linespacing(5);
app::set_frame_type_cb(FrameType::UpBox, up_box, 2, 2, 4, 4);
app::set_frame_type_cb(FrameType::DiamondUpBox, default_button_up_box, 2, 2, 4, 4);
app::set_frame_type_cb(FrameType::DownBox, down_box, 2, 2, 4, 4);
app::set_frame_type_cb(FrameType::DiamondDownBox, down_box, 2, 2, 4, 4);
app::set_frame_type_cb(FrameType::RoundDownBox, radio_round_down_box, 2, 2, 4, 4);
app::set_frame_type_cb(FrameType::BorderBox, border_box, 2, 2, 4, 4);
}

pub(crate) fn use_sweet_scheme() {
use_scheme();
app::set_visible_focus(false);
app::set_scrollbar_size(13);
}

pub mod frames {
use fltk::enums::FrameType::{self, *};
pub const OS_DEFAULT_BUTTON_UP_BOX: FrameType = DiamondUpBox;
pub const OS_DEFAULT_DEPRESSED_DOWN_BOX: FrameType = FrameType::DiamondDownBox;
}

0 comments on commit 4393a1c

Please sign in to comment.