2016-08-05 00:27:04 +00:00
|
|
|
extern crate cursive;
|
|
|
|
|
2016-09-29 05:45:27 +00:00
|
|
|
use cursive::Cursive;
|
2017-06-11 22:01:35 +00:00
|
|
|
use cursive::theme::{ColorStyle, BaseColor, Color, BorderStyle};
|
|
|
|
use cursive::views::{EditView, LinearLayout, Dialog, TextView};
|
2016-08-05 00:27:04 +00:00
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let mut siv = Cursive::new();
|
|
|
|
|
2017-06-11 22:01:35 +00:00
|
|
|
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),
|
|
|
|
}));
|
2016-08-05 00:27:04 +00:00
|
|
|
|
2017-06-11 22:01:35 +00:00
|
|
|
siv.add_layer(Dialog::around(layout)
|
|
|
|
.button("Change", |s| {
|
|
|
|
let mut theme = s.current_theme().clone();
|
2016-08-05 00:27:04 +00:00
|
|
|
|
2017-06-11 22:01:35 +00:00
|
|
|
theme.shadow = !theme.shadow;
|
|
|
|
theme.borders = match theme.borders {
|
|
|
|
Some(BorderStyle::Simple) => Some(BorderStyle::Outset),
|
|
|
|
Some(BorderStyle::Outset) => None,
|
|
|
|
None => Some(BorderStyle::Simple),
|
|
|
|
};
|
|
|
|
|
|
|
|
s.set_theme(theme);
|
|
|
|
})
|
|
|
|
.button("Quit", Cursive::quit));
|
2016-08-05 00:27:04 +00:00
|
|
|
|
|
|
|
siv.run();
|
|
|
|
}
|