8 releases

0.1.8 Aug 4, 2021
0.1.7 Aug 2, 2021
0.1.5 Jul 26, 2021

#133 in GUI

Download history 31/week @ 2021-07-16 73/week @ 2021-07-23 83/week @ 2021-07-30 40/week @ 2021-08-06 34/week @ 2021-08-13 14/week @ 2021-08-20 8/week @ 2021-08-27 7/week @ 2021-09-03 26/week @ 2021-09-10

55 downloads per month
Used in flemish

MIT license

165KB
4K SLoC

fltk-theme

A theming crate for fltk-rs, based on work by Remy Oukaour and Greg Ercolano, and schemes developed by the NTK GUI library.

Usage

[dependencies]
fltk = "1.1.6"
fltk-theme = "0.1"

Example

Setting the color theme:

use fltk::{prelude::*, *};
use fltk_theme::{ColorTheme, color_themes};

fn main() {
    let a = app::App::default().with_scheme(app::Scheme::Gtk);
    let theme = ColorTheme::from_colormap(color_themes::BLACK_THEME);
    theme.apply();
    let mut win = window::Window::default().with_size(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:

use fltk::{prelude::*, *};
use fltk_theme::{widget_themes, WidgetTheme, ThemeType};

fn main() {
    let a = app::App::default();
    let widget_theme = WidgetTheme::new(ThemeType::Aqua);
    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();
}

Setting the widget scheme:

use fltk::{prelude::*, *};
use fltk_theme::{WidgetScheme, SchemeType};

fn main() {
    let a = app::App::default();
    let widget_scheme = WidgetScheme::new(SchemeType::Clean);
    widget_scheme.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();
}

Widget themes

  • Classic (old Windows theme) alt_test

  • Aero (Windows 7 theme) alt_test

  • Aqua (MacOS theme) alt_test

  • Dark alt_test

  • High Contrast alt_test

  • Blue alt_test

  • Metro (Windows 8 theme) alt_test

  • Greybird (Gnome xfce) alt_test

Theme FrameTypes

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. alt_test

Color themes

  • Black theme alt_test

  • Dark theme alt_test

  • Plain gray theme alt_test

  • Tan theme alt_test

  • Shake theme alt_test

Widget Schemes

These provide schemes for widgets without color theming. Currently there are 4 schemes:

  • Clean: Taken from NTK's clear scheme. alt_test

  • Crystal: Taken from NTK's crystal scheme. alt_test

  • Gleam: Taken from NTK's gleam scheme. alt_test

  • SvgBased: This overrides FLTK's Base scheme round/rounded/oval FrameTypes which are drawn using scalable vector graphics. alt_test

Dependencies

~11MB
~244K SLoC