A theming crate for fltk-rs. - The widget themes are based on work by Remy Oukaour and Rangi42. - The color themes are based on work by Greg Ercolano. - Some of the widget schemes are based on work by the NTK GUI library, others are nouveau.
toml
[dependencies]
fltk = "1.2"
fltk-theme = "0.4"
Setting the color theme:
```rust use fltk::{prelude::*, *}; use fltktheme::{ColorTheme, colorthemes};
fn main() { let a = app::App::default().withscheme(app::Scheme::Gtk); let theme = ColorTheme::new(colorthemes::BLACKTHEME); theme.apply(); let mut win = window::Window::default().withsize(400, 300); let mut btn = button::Button::new(160, 200, 80, 40, "Hello"); btn.set_color(btn.color().lighter()); win.end(); win.show(); a.run().unwrap(); } ```
Setting the widget theme:
```rust use fltk::{prelude::*, *}; use fltktheme::{widgetthemes, WidgetTheme, ThemeType};
fn main() { let a = app::App::default(); let widgettheme = WidgetTheme::new(ThemeType::AquaClassic); widgettheme.apply(); let mut win = window::Window::default().withsize(400, 300); let mut btn = button::Button::new(160, 200, 80, 30, "Hello"); btn.setframe(widgetthemes::OSDEFAULTBUTTONUP_BOX); win.end(); win.show(); a.run().unwrap(); } ```
Setting the widget scheme: ```rust use fltk::{prelude::*, *}; use fltk_theme::{WidgetScheme, SchemeType};
fn main() { let a = app::App::default(); let widgetscheme = WidgetScheme::new(SchemeType::Clean); widgetscheme.apply(); let mut win = window::Window::default().with_size(400, 300); let mut btn = button::Button::new(160, 200, 80, 30, "Hello"); win.end(); win.show(); a.run().unwrap(); } ```
Aero (Windows 7 theme)
AquaClassic (classic MacOS theme),
Dark
High Contrast
Blue
Metro (Windows 8 theme)
Greybird (Gnome xfce)
Choosing a WidgetTheme will also define a set of FrameTypes which can be used for your widgets.
OS_BUTTON_UP_BOX
OS_CHECK_DOWN_BOX
OS_BUTTON_UP_FRAME
OS_CHECK_DOWN_FRAME
OS_PANEL_THIN_UP_BOX
OS_SPACER_THIN_DOWN_BOX
OS_PANEL_THIN_UP_FRAME
OS_SPACER_THIN_DOWN_FRAME
OS_RADIO_ROUND_DOWN_BOX
OS_HOVERED_UP_BOX
OS_DEPRESSED_DOWN_BOX
OS_HOVERED_UP_FRAME
OS_DEPRESSED_DOWN_FRAME
OS_INPUT_THIN_DOWN_BOX
OS_INPUT_THIN_DOWN_FRAME
OS_MINI_BUTTON_UP_BOX
OS_MINI_DEPRESSED_DOWN_BOX
OS_MINI_BUTTON_UP_FRAME
OS_MINI_DEPRESSED_DOWN_FRAME
OS_DEFAULT_BUTTON_UP_BOX
OS_DEFAULT_HOVERED_UP_BOX
OS_DEFAULT_DEPRESSED_DOWN_BOX
OS_TOOLBAR_BUTTON_HOVER_BOX
OS_TABS_BOX
OS_SWATCH_BOX
OS_SWATCH_FRAME
OS_BG_BOX
You can check the frames example to see all FrameType
's you can apply to you widgets.
-
Dark theme
Plain gray theme
Tan theme
Shake theme
These provide schemes for widgets without color theming. Currently there are 6 schemes:
- Clean: Taken from NTK's clear scheme.
-
Gleam: Taken from NTK's gleam scheme.
Aqua: Tries to mimic the modern MacOS's styles.
Fluent: Tries to mimic Window's 10 styles.
SvgBased: This overrides FLTK's Base scheme round/rounded/oval FrameTypes which are drawn using scalable vector graphics.
The crate also provides colors, namely html colors and aqua colors. The aqua colors are provided as lazystatic values and are named after the cocoa NSColor properties (such as windowBackgroundColor, systemBlueColor, controlAccentColor...etc). The html colors are provided in a lazystatic HashMap and can be accessed by their html names.
Colors and Color themes can also be used with widget schemes or even in a regular fltk-rs application.