cursive/examples/theme_manual.rs

34 lines
1.0 KiB
Rust
Raw Normal View History

2017-10-12 23:38:55 +00:00
use cursive::theme::{BaseColor, BorderStyle, Color, ColorStyle};
2019-11-15 19:41:05 +00:00
use cursive::views::{Dialog, Edit, LinearLayout, Text};
2018-06-11 06:29:10 +00:00
use cursive::Cursive;
fn main() {
let mut siv = Cursive::default();
let layout = LinearLayout::vertical()
2019-11-15 19:41:05 +00:00
.child(Text::new("This is a dynamic theme example!"))
.child(Edit::new().content("Woo! colors!").style(ColorStyle::new(
Color::Rgb(200, 150, 150),
Color::Dark(BaseColor::Blue),
)));
2017-10-12 23:38:55 +00:00
siv.add_layer(
Dialog::around(layout)
.button("Change", |s| {
let mut theme = s.current_theme().clone();
2017-10-12 23:38:55 +00:00
theme.shadow = !theme.shadow;
theme.borders = match theme.borders {
BorderStyle::Simple => BorderStyle::Outset,
BorderStyle::Outset => BorderStyle::None,
BorderStyle::None => BorderStyle::Simple,
};
2017-10-12 23:38:55 +00:00
s.set_theme(theme);
2019-03-01 00:04:14 +00:00
})
.button("Quit", Cursive::quit),
2017-10-12 23:38:55 +00:00
);
siv.run();
}