cursive/examples/theme_manual.rs
Alexandre Bury 5c42a59954 Refactor colors management
Do not register pairs with backend. Let backend cache color pairs if
needed.
2017-06-12 11:59:33 -07:00

34 lines
1.1 KiB
Rust

extern crate cursive;
use cursive::Cursive;
use cursive::theme::{ColorStyle, BaseColor, Color, BorderStyle};
use cursive::views::{EditView, LinearLayout, Dialog, TextView};
fn main() {
let mut siv = Cursive::new();
let layout = LinearLayout::vertical()
.child(TextView::new("This is a dynamic theme example!"))
.child(EditView::new().content("Woo! colors!").style(ColorStyle::Custom {
front: Color::Rgb(200, 150, 150),
back: Color::Dark(BaseColor::Blue),
}));
siv.add_layer(Dialog::around(layout)
.button("Change", |s| {
let mut theme = s.current_theme().clone();
theme.shadow = !theme.shadow;
theme.borders = match theme.borders {
BorderStyle::Simple => BorderStyle::Outset,
BorderStyle::Outset => BorderStyle::None,
BorderStyle::None => BorderStyle::Simple,
};
s.set_theme(theme);
})
.button("Quit", Cursive::quit));
siv.run();
}