Skip to content

Commit

Permalink
don't reload app scheme on color theme change
Browse files Browse the repository at this point in the history
  • Loading branch information
MoAlyousef committed Oct 5, 2021
1 parent f63ea99 commit 98ca88b
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "fltk-theme"
version = "0.2.2"
version = "0.2.3"
authors = ["MoAlyousef <[email protected]>"]
edition = "2018"
description = "A theming crate for fltk-rs"
Expand Down
30 changes: 26 additions & 4 deletions examples/predef_color.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,34 @@ use fltk_theme::{color_themes, ColorTheme};

fn main() {
let a = app::App::default().with_scheme(app::Scheme::Gtk);
let theme = ColorTheme::from_colormap(color_themes::DARK_THEME);
theme.apply();
app::set_visible_focus(false);

let color_theme = ColorTheme::from_colormap(color_themes::BLACK_THEME);
color_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());
let mut choice = menu::Choice::new(100, 100, 200, 30, None);
choice.add_choice("Black|Dark|Gray|Shake|Tan");
choice.set_value(0);
let mut check = button::CheckButton::new(160, 150, 80, 30, " Check");
check.set_value(true);
check.set_frame(enums::FrameType::FlatBox);
let mut round = button::RoundButton::new(160, 180, 80, 30, " Round");
round.set_value(true);
round.set_frame(enums::FrameType::FlatBox);
button::Button::new(160, 220, 80, 30, "Hello");
win.end();
win.show();
choice.set_callback(|c| {
let theme = match c.value() {
0 => ColorTheme::from_colormap(color_themes::BLACK_THEME),
1 => ColorTheme::from_colormap(color_themes::DARK_THEME),
2 => ColorTheme::from_colormap(color_themes::GRAY_THEME),
3 => ColorTheme::from_colormap(color_themes::SHAKE_THEME),
4 => ColorTheme::from_colormap(color_themes::TAN_THEME),
_ => ColorTheme::from_colormap(color_themes::BLACK_THEME),
};
theme.apply();
});

a.run().unwrap();
}
Binary file modified screenshots/black.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified screenshots/dark_color.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified screenshots/plain-gray.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified screenshots/shake.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified screenshots/tan.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ impl ColorTheme {
for elem in &self.0 {
app::set_color(Color::by_index(elem.index), elem.r, elem.g, elem.b);
}
app::reload_scheme().ok();
app::redraw();
}
}

Expand Down

0 comments on commit 98ca88b

Please sign in to comment.