2016-08-05 00:27:04 +00:00
|
|
|
extern crate cursive;
|
|
|
|
|
2017-10-12 23:38:55 +00:00
|
|
|
use cursive::theme::{BaseColor, BorderStyle, Color, ColorStyle};
|
|
|
|
use cursive::views::{Dialog, EditView, LinearLayout, TextView};
|
2018-06-11 06:29:10 +00:00
|
|
|
use cursive::Cursive;
|
2016-08-05 00:27:04 +00:00
|
|
|
|
|
|
|
fn main() {
|
2018-04-01 23:39:03 +00:00
|
|
|
let mut siv = Cursive::default();
|
2016-08-05 00:27:04 +00:00
|
|
|
|
2017-06-11 22:01:35 +00:00
|
|
|
let layout = LinearLayout::vertical()
|
2018-03-22 18:04:10 +00:00
|
|
|
.child(TextView::new(
|
|
|
|
"This is a dynamic theme example!",
|
|
|
|
))
|
2017-10-12 23:38:55 +00:00
|
|
|
.child(EditView::new().content("Woo! colors!").style(
|
2018-01-17 17:35:57 +00:00
|
|
|
ColorStyle::new(
|
|
|
|
Color::Rgb(200, 150, 150),
|
|
|
|
Color::Dark(BaseColor::Blue),
|
|
|
|
),
|
2017-10-12 23:38:55 +00:00
|
|
|
));
|
2016-08-05 00:27:04 +00:00
|
|
|
|
2017-10-12 23:38:55 +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-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-06-11 22:01:35 +00:00
|
|
|
|
2017-10-12 23:38:55 +00:00
|
|
|
s.set_theme(theme);
|
|
|
|
})
|
|
|
|
.button("Quit", Cursive::quit),
|
|
|
|
);
|
2016-08-05 00:27:04 +00:00
|
|
|
|
|
|
|
siv.run();
|
|
|
|
}
|