Skip to content

Commit 4393a1c

Browse files
authored
Merge pull request #11 from StarterX4/sweet-theme
"Sweet" Widget Scheme
2 parents f923b7f + 6107551 commit 4393a1c

File tree

11 files changed

+274
-1
lines changed

11 files changed

+274
-1
lines changed

README.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ You can check the frames example to see all `FrameType`'s you can apply to you w
165165

166166
## Widget Schemes
167167

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

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

189+
- Sweet: Tries to mimic the Sweet theme for GNOME/KDE.
190+
- ![alt_test](screenshots/sweet_dark.png)
191+
- ![alt_test](screenshots/sweet_light.png)
192+
189193
## Colors
190194

191195
The crate also provides colors, namely html colors and aqua colors.

examples/sweet_dark.rs

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
use fltk::{enums::*, prelude::*, *};
2+
use fltk_theme::widget_schemes::sweet::frames::*;
3+
use fltk_theme::{SchemeType, WidgetScheme};
4+
5+
use fltk_theme::colors::sweet::dark::*; // get all the dark sweet colors
6+
7+
// use fltk_theme::colors::sweet::light::*; // get all the light sweet colors
8+
9+
fn main() {
10+
let a = app::App::default();
11+
app::set_font_size(12);
12+
let bg = windowBackgroundColor.to_rgb();
13+
app::background(bg.0, bg.1, bg.2);
14+
let ctrl = controlAccentColor.to_rgb();
15+
app::background2(ctrl.0, ctrl.1, ctrl.2);
16+
let lbl = labelColor.to_rgb();
17+
app::foreground(lbl.0, lbl.1, lbl.2);
18+
let txt_sel_bg = selectedTextBackgroundColor.to_rgb();
19+
app::set_selection_color(txt_sel_bg.0, txt_sel_bg.1, txt_sel_bg.2);
20+
//app::set_color(Color::Selection, 255, 255, 255);
21+
let widget_scheme = WidgetScheme::new(SchemeType::Sweet);
22+
widget_scheme.apply();
23+
let mut win = window::Window::default()
24+
.with_size(400, 300)
25+
.with_label("Sweet Dark");
26+
let mut col = group::Flex::default()
27+
.with_size(340, 240)
28+
.center_of_parent()
29+
.column();
30+
col.set_frame(FrameType::NoBox);
31+
col.set_margins(100, 40, 100, 40);
32+
let mut choice = menu::Choice::default();
33+
choice.set_color(*controlColor);
34+
choice.add_choice("Opt1|Opt2|Opt3");
35+
choice.set_value(2);
36+
let mut inp = input::Input::default();
37+
inp.set_color(*controlColor);
38+
let mut check = button::CheckButton::default().with_label(" Check");
39+
check.set_value(true);
40+
check.set_frame(enums::FrameType::FlatBox);
41+
let mut round = button::RoundButton::default().with_label(" Round");
42+
round.set_value(true);
43+
round.set_frame(enums::FrameType::FlatBox);
44+
let mut btn = button::Button::default().with_label("Hello");
45+
btn.set_color(*controlColor);
46+
btn.set_selection_color(*controlAccentColor);
47+
btn.set_frame(OS_DEFAULT_BUTTON_UP_BOX);
48+
col.end();
49+
win.end();
50+
win.make_resizable(true);
51+
win.show();
52+
a.run().unwrap();
53+
}

screenshots/sweet_dark.png

11.2 KB
Loading

screenshots/sweet_light.png

11.2 KB
Loading

src/colors/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
pub mod aqua;
22
pub mod html;
3+
pub mod sweet;

src/colors/sweet/dark.rs

+88
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
#![allow(non_upper_case_globals)]
2+
3+
use fltk::enums::Color;
4+
use fltk::utils::oncelock::Lazy;
5+
6+
pub static backgroundColor2: Lazy<Color> = Lazy::new(|| Color::from_rgba_tuple((22, 25, 37, 255)));
7+
pub static windowBackgroundColor: Lazy<Color> =
8+
Lazy::new(|| Color::from_rgba_tuple((24, 27, 40, 255)));
9+
pub static labelColor: Lazy<Color> = Lazy::new(|| Color::from_rgba_tuple((195, 199, 209, 255)));
10+
pub static controlBackgroundColor: Lazy<Color> =
11+
Lazy::new(|| Color::from_rgba_tuple((30, 34, 51, 255)));
12+
pub static secondaryLabelColor: Lazy<Color> =
13+
Lazy::new(|| Color::from_rgba_tuple((102, 106, 115, 255)));
14+
pub static tertiaryLabelColor: Lazy<Color> =
15+
Lazy::new(|| Color::from_rgba_tuple((102, 106, 115, 191)));
16+
pub static quaternaryLabelColor: Lazy<Color> =
17+
Lazy::new(|| Color::from_rgba_tuple((102, 106, 115, 127)));
18+
pub static textColor: Lazy<Color> = Lazy::new(|| Color::from_rgba_tuple((211, 218, 227, 255)));
19+
pub static placeholderTextColor: Lazy<Color> =
20+
Lazy::new(|| Color::from_rgba_tuple((102, 106, 115, 255)));
21+
pub static selectedTextColor: Lazy<Color> =
22+
Lazy::new(|| Color::from_rgba_tuple((254, 254, 254, 255)));
23+
pub static textBackgroundColor: Lazy<Color> =
24+
Lazy::new(|| Color::from_rgba_tuple((30, 34, 51, 255)));
25+
pub static selectedTextBackgroundColor: Lazy<Color> =
26+
Lazy::new(|| Color::from_rgba_tuple((197, 14, 210, 255)));
27+
pub static keyboardFocusIndicatorColor: Lazy<Color> =
28+
Lazy::new(|| Color::from_rgba_tuple((197, 14, 210, 191)));
29+
pub static unemphasizedSelectedTextColor: Lazy<Color> =
30+
Lazy::new(|| Color::from_rgba_tuple((254, 254, 254, 255)));
31+
pub static unemphasizedSelectedTextBackgroundColor: Lazy<Color> =
32+
Lazy::new(|| Color::from_rgba_tuple((47, 52, 63, 255)));
33+
pub static linkColor: Lazy<Color> = Lazy::new(|| Color::from_rgba_tuple((82, 148, 226, 255)));
34+
pub static separatorColor: Lazy<Color> = Lazy::new(|| Color::from_rgba_tuple((102, 106, 115, 63)));
35+
pub static selectedContentBackgroundColor: Lazy<Color> =
36+
Lazy::new(|| Color::from_rgba_tuple((197, 14, 210, 255)));
37+
pub static unemphasizedSelectedContentBackgroundColor: Lazy<Color> =
38+
Lazy::new(|| Color::from_rgba_tuple((47, 52, 63, 255)));
39+
pub static selectedMenuItemTextColor: Lazy<Color> =
40+
Lazy::new(|| Color::from_rgba_tuple((254, 254, 254, 255)));
41+
pub static gridColor: Lazy<Color> = Lazy::new(|| Color::from_rgba_tuple((22, 25, 37, 255)));
42+
pub static headerTextColor: Lazy<Color> =
43+
Lazy::new(|| Color::from_rgba_tuple((211, 218, 227, 255)));
44+
pub static origControlAccentColor: Lazy<Color> =
45+
Lazy::new(|| Color::from_rgba_tuple((0, 232, 198, 255))); // Sweet's original green color for checkboxes
46+
pub static controlAccentColor: Lazy<Color> =
47+
Lazy::new(|| Color::from_rgba_tuple((197, 14, 210, 255)));
48+
pub static controlColor: Lazy<Color> = Lazy::new(|| Color::from_rgba_tuple((102, 106, 115, 191)));
49+
pub static controlTextColor: Lazy<Color> =
50+
Lazy::new(|| Color::from_rgba_tuple((195, 199, 209, 255)));
51+
pub static disabledControlTextColor: Lazy<Color> =
52+
Lazy::new(|| Color::from_rgba_tuple((102, 106, 115, 127)));
53+
pub static selectedControlColor: Lazy<Color> =
54+
Lazy::new(|| Color::from_rgba_tuple((197, 14, 210, 255)));
55+
pub static selectedControlTextColor: Lazy<Color> =
56+
Lazy::new(|| Color::from_rgba_tuple((195, 199, 209, 255)));
57+
pub static alternateSelectedControlTextColor: Lazy<Color> =
58+
Lazy::new(|| Color::from_rgba_tuple((254, 254, 254, 255)));
59+
pub static scrubberTexturedBackgroundColor: Lazy<Color> =
60+
Lazy::new(|| Color::from_rgba_tuple((211, 218, 227, 255)));
61+
pub static windowFrameTextColor: Lazy<Color> =
62+
Lazy::new(|| Color::from_rgba_tuple((195, 199, 209, 255)));
63+
pub static underPageBackgroundColor: Lazy<Color> =
64+
Lazy::new(|| Color::from_rgba_tuple((22, 25, 37, 255)));
65+
pub static findHighlightColor: Lazy<Color> =
66+
Lazy::new(|| Color::from_rgba_tuple((255, 106, 0, 255)));
67+
pub static highlightColor: Lazy<Color> = Lazy::new(|| Color::from_rgba_tuple((197, 14, 210, 255)));
68+
pub static shadowColor: Lazy<Color> = Lazy::new(|| Color::from_rgba_tuple((0, 0, 0, 255)));
69+
pub static systemBrownColor: Lazy<Color> =
70+
Lazy::new(|| Color::from_rgba_tuple((155, 123, 85, 255)));
71+
pub static systemFuchsiaColor: Lazy<Color> =
72+
Lazy::new(|| Color::from_rgba_tuple((197, 14, 210, 255)));
73+
pub static systemGrayColor: Lazy<Color> =
74+
Lazy::new(|| Color::from_rgba_tuple((133, 133, 139, 255)));
75+
pub static systemGreenColor: Lazy<Color> = Lazy::new(|| Color::from_rgba_tuple((48, 211, 58, 255)));
76+
pub static systemIndigoColor: Lazy<Color> =
77+
Lazy::new(|| Color::from_rgba_tuple((74, 64, 223, 255)));
78+
pub static systemOrangeColor: Lazy<Color> =
79+
Lazy::new(|| Color::from_rgba_tuple((252, 141, 13, 255)));
80+
pub static systemPinkColor: Lazy<Color> = Lazy::new(|| Color::from_rgba_tuple((251, 25, 76, 255)));
81+
pub static systemPurpleColor: Lazy<Color> =
82+
Lazy::new(|| Color::from_rgba_tuple((157, 51, 213, 255)));
83+
pub static systemRedColor: Lazy<Color> = Lazy::new(|| Color::from_rgba_tuple((251, 43, 44, 255)));
84+
pub static systemTealColor: Lazy<Color> = Lazy::new(|| Color::from_rgba_tuple((76, 187, 242, 255)));
85+
pub static systemYellowColor: Lazy<Color> =
86+
Lazy::new(|| Color::from_rgba_tuple((254, 207, 14, 255)));
87+
pub static systemBlueColor: Lazy<Color> = Lazy::new(|| Color::from_rgba_tuple((16, 106, 254, 255)));
88+
pub static systemCyanColor: Lazy<Color> = Lazy::new(|| Color::from_rgba_tuple((90, 200, 245, 255)));

src/colors/sweet/light.rs

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#![allow(non_upper_case_globals)]
2+
3+
use fltk::enums::Color;
4+
use fltk::utils::oncelock::Lazy;
5+
6+
pub static backgroundColor2: Lazy<Color> = Lazy::new(|| Color::from_rgb(230, 230, 230));
7+
pub static windowBackgroundColor: Lazy<Color> = Lazy::new(|| Color::from_rgb(232, 234, 235));
8+
pub static labelColor: Lazy<Color> = Lazy::new(|| Color::from_rgb(49, 54, 61));
9+
pub static controlBackgroundColor: Lazy<Color> = Lazy::new(|| Color::from_rgb(230, 230, 230));
10+
pub static secondaryLabelColor: Lazy<Color> = Lazy::new(|| Color::from_rgb(140, 142, 146));
11+
pub static tertiaryLabelColor: Lazy<Color> = Lazy::new(|| Color::from_rgba_tuple((140, 142, 146, 191)));
12+
pub static quaternaryLabelColor: Lazy<Color> = Lazy::new(|| Color::from_rgba_tuple((140, 142, 146, 127)));
13+
pub static textColor: Lazy<Color> = Lazy::new(|| Color::from_rgb(49, 54, 61));
14+
pub static placeholderTextColor: Lazy<Color> = Lazy::new(|| Color::from_rgb(140, 142, 146));
15+
pub static selectedTextColor: Lazy<Color> = Lazy::new(|| Color::from_rgb(254, 254, 254));
16+
pub static textBackgroundColor: Lazy<Color> = Lazy::new(|| Color::from_rgb(235, 240, 245));
17+
pub static selectedTextBackgroundColor: Lazy<Color> =
18+
Lazy::new(|| Color::from_rgba_tuple((197, 14, 210, 255)));
19+
pub static keyboardFocusIndicatorColor: Lazy<Color> =
20+
Lazy::new(|| Color::from_rgba_tuple((197, 14, 210, 191)));
21+
pub static unemphasizedSelectedTextColor: Lazy<Color> = Lazy::new(|| Color::from_rgb(254, 254, 254));
22+
pub static unemphasizedSelectedTextBackgroundColor: Lazy<Color> = Lazy::new(|| Color::from_rgb(232, 234, 236));
23+
pub static linkColor: Lazy<Color> = Lazy::new(|| Color::from_rgb(82, 148, 226));
24+
pub static separatorColor: Lazy<Color> = Lazy::new(|| Color::from_rgba_tuple((0, 0, 0, 63)));
25+
pub static selectedContentBackgroundColor: Lazy<Color> =
26+
Lazy::new(|| Color::from_rgba_tuple((197, 14, 210, 255)));
27+
pub static unemphasizedSelectedContentBackgroundColor: Lazy<Color> = Lazy::new(|| Color::from_rgb(232, 234, 236));
28+
pub static selectedMenuItemTextColor: Lazy<Color> = Lazy::new(|| Color::from_rgb(254, 254, 254));
29+
pub static gridColor: Lazy<Color> = Lazy::new(|| Color::from_rgb(22, 25, 37));
30+
pub static headerTextColor: Lazy<Color> = Lazy::new(|| Color::from_rgb(49, 54, 61));
31+
pub static origControlAccentColor: Lazy<Color> =
32+
Lazy::new(|| Color::from_rgba_tuple((0, 232, 198, 255))); // Sweet's original green color for checkboxes
33+
pub static controlAccentColor: Lazy<Color> =
34+
Lazy::new(|| Color::from_rgba_tuple((197, 14, 210, 255)));
35+
pub static controlColor: Lazy<Color> = Lazy::new(|| Color::from_rgba_tuple((255, 255, 255, 255)));
36+
pub static controlTextColor: Lazy<Color> = Lazy::new(|| Color::from_rgb(49, 54, 61));
37+
pub static disabledControlTextColor: Lazy<Color> = Lazy::new(|| Color::from_rgba_tuple((140, 142, 146, 127)));
38+
pub static selectedControlColor: Lazy<Color> = Lazy::new(|| Color::from_rgb(197, 14, 210));
39+
pub static selectedControlTextColor: Lazy<Color> = Lazy::new(|| Color::from_rgb(49, 54, 61));
40+
pub static alternateSelectedControlTextColor: Lazy<Color> = Lazy::new(|| Color::from_rgb(254, 254, 254));
41+
pub static scrubberTexturedBackgroundColor: Lazy<Color> = Lazy::new(|| Color::from_rgb(211, 218, 227));
42+
pub static windowFrameTextColor: Lazy<Color> = Lazy::new(|| Color::from_rgb(49, 54, 61));
43+
pub static underPageBackgroundColor: Lazy<Color> = Lazy::new(|| Color::from_rgb(230, 230, 230));
44+
pub static findHighlightColor: Lazy<Color> = Lazy::new(|| Color::from_rgb(255, 106, 0));
45+
pub static highlightColor: Lazy<Color> = Lazy::new(|| Color::from_rgb(197, 14, 210));
46+
pub static shadowColor: Lazy<Color> = Lazy::new(|| Color::from_rgba_tuple((0, 0, 0, 255)));
47+
pub static systemBrownColor: Lazy<Color> = Lazy::new(|| Color::from_rgb(155, 123, 85));
48+
pub static systemFuchsiaColor: Lazy<Color> = Lazy::new(|| Color::from_rgb(197, 14, 210));
49+
pub static systemGrayColor: Lazy<Color> = Lazy::new(|| Color::from_rgb(133, 133, 139));
50+
pub static systemGreenColor: Lazy<Color> = Lazy::new(|| Color::from_rgb(48, 211, 58));
51+
pub static systemIndigoColor: Lazy<Color> = Lazy::new(|| Color::from_rgb(74, 64, 223));
52+
pub static systemOrangeColor: Lazy<Color> = Lazy::new(|| Color::from_rgb(252, 141, 13));
53+
pub static systemPinkColor: Lazy<Color> = Lazy::new(|| Color::from_rgb(251, 25, 76));
54+
pub static systemPurpleColor: Lazy<Color> = Lazy::new(|| Color::from_rgb(157, 51, 213));
55+
pub static systemRedColor: Lazy<Color> = Lazy::new(|| Color::from_rgb(251, 43, 44));
56+
pub static systemTealColor: Lazy<Color> = Lazy::new(|| Color::from_rgba_tuple((76, 187, 242, 255)));
57+
pub static systemYellowColor: Lazy<Color> = Lazy::new(|| Color::from_rgba_tuple((254, 207, 14, 255)));
58+
pub static systemBlueColor: Lazy<Color> = Lazy::new(|| Color::from_rgba_tuple((16, 106, 254, 255)));
59+
pub static systemCyanColor: Lazy<Color> = Lazy::new(|| Color::from_rgba_tuple((90, 200, 245, 255)));

src/colors/sweet/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
pub mod dark;
2+
pub mod light;

src/lib.rs

+3
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,8 @@ pub enum SchemeType {
151151
- OFlatFrame
152152
*/
153153
SvgBased,
154+
/// A scheme mimicking the Sweet theme for GNOME/KDE
155+
Sweet,
154156
}
155157

156158
/// A widget scheme sets the style of drawing a widget without interfering with coloring
@@ -174,6 +176,7 @@ impl WidgetScheme {
174176
SchemeType::Fluent => widget_schemes::fluent::use_fluent_scheme(),
175177
SchemeType::Gleam => widget_schemes::gleam::use_gleam_scheme(),
176178
SchemeType::SvgBased => widget_schemes::svg_based::use_svg_based_scheme(),
179+
SchemeType::Sweet => widget_schemes::sweet::use_sweet_scheme(),
177180
}
178181
}
179182
}

src/widget_schemes/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ pub(crate) mod crystal;
1010
pub mod fluent;
1111
pub(crate) mod gleam;
1212
pub(crate) mod svg_based;
13+
pub mod sweet;

src/widget_schemes/sweet.rs

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
use fltk::{
2+
app, draw,
3+
enums::{Color, FrameType},
4+
};
5+
6+
fn up_box(x: i32, y: i32, w: i32, h: i32, c: Color) {
7+
let col1 = c.to_rgb();
8+
let col = Color::color_average(c, Color::Background, 0.8).to_rgb();
9+
draw::draw_rbox(x, y, w, h, 5, true, Color::from_rgb(col.0, col.1, col.2));
10+
}
11+
12+
fn default_button_up_box(x: i32, y: i32, w: i32, h: i32, c: Color) {
13+
let col1 = c.to_rgb();
14+
let col = Color::color_average(c, Color::Background, 0.8).to_rgb();
15+
draw::draw_rbox(x, y, w, h, 5, true, Color::from_rgb(col.0, col.1, col.2));
16+
}
17+
18+
fn down_box(x: i32, y: i32, w: i32, h: i32, c: Color) {
19+
let col1 = c.to_rgb();
20+
let col = Color::color_average(c, Color::Background, 0.8).to_rgb();
21+
draw::draw_rbox(x, y, w, h, 5, true, Color::from_rgb(col.0, col.1, col.2));
22+
}
23+
24+
fn radio_round_down_box(x: i32, y: i32, w: i32, h: i32, c: Color) {
25+
let col = c.to_rgb();
26+
draw::draw_box(FrameType::OFlatBox, x, y, w, h, c);
27+
}
28+
29+
fn border_box(x: i32, y: i32, w: i32, h: i32, c: Color) {
30+
draw::draw_rbox(
31+
x,
32+
y,
33+
w,
34+
h,
35+
5,
36+
true,
37+
*crate::colors::sweet::dark::systemFuchsiaColor,
38+
);
39+
}
40+
41+
fn use_scheme() {
42+
app::set_scheme(app::Scheme::Gtk);
43+
// app::set_menu_linespacing(5);
44+
app::set_frame_type_cb(FrameType::UpBox, up_box, 2, 2, 4, 4);
45+
app::set_frame_type_cb(FrameType::DiamondUpBox, default_button_up_box, 2, 2, 4, 4);
46+
app::set_frame_type_cb(FrameType::DownBox, down_box, 2, 2, 4, 4);
47+
app::set_frame_type_cb(FrameType::DiamondDownBox, down_box, 2, 2, 4, 4);
48+
app::set_frame_type_cb(FrameType::RoundDownBox, radio_round_down_box, 2, 2, 4, 4);
49+
app::set_frame_type_cb(FrameType::BorderBox, border_box, 2, 2, 4, 4);
50+
}
51+
52+
pub(crate) fn use_sweet_scheme() {
53+
use_scheme();
54+
app::set_visible_focus(false);
55+
app::set_scrollbar_size(13);
56+
}
57+
58+
pub mod frames {
59+
use fltk::enums::FrameType::{self, *};
60+
pub const OS_DEFAULT_BUTTON_UP_BOX: FrameType = DiamondUpBox;
61+
pub const OS_DEFAULT_DEPRESSED_DOWN_BOX: FrameType = FrameType::DiamondDownBox;
62+
}

0 commit comments

Comments
 (0)