2015-06-08 19:23:36 +00:00
|
|
|
extern crate cursive;
|
|
|
|
|
2016-09-29 05:45:27 +00:00
|
|
|
use cursive::Cursive;
|
2015-06-08 19:23:36 +00:00
|
|
|
use cursive::align::HAlign;
|
2016-09-29 05:45:27 +00:00
|
|
|
use cursive::traits::*;
|
2017-10-12 23:38:55 +00:00
|
|
|
use cursive::views::{Dialog, LinearLayout, TextView};
|
2015-06-08 19:23:36 +00:00
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let mut siv = Cursive::new();
|
|
|
|
|
2015-06-08 22:38:10 +00:00
|
|
|
// Some description text
|
2016-07-13 08:19:05 +00:00
|
|
|
let text = "This is a very simple example of linear layout. Two views \
|
|
|
|
are present, a short title above, and this text. The text \
|
|
|
|
has a fixed width, and the title is centered horizontally.";
|
2015-06-08 19:23:36 +00:00
|
|
|
|
2015-06-08 22:38:10 +00:00
|
|
|
// We'll create a dialog with a TextView serving as a title
|
2017-10-12 23:38:55 +00:00
|
|
|
siv.add_layer(
|
|
|
|
Dialog::around(
|
|
|
|
LinearLayout::vertical()
|
2015-06-08 19:23:36 +00:00
|
|
|
.child(TextView::new("Title").h_align(HAlign::Center))
|
2015-06-08 22:38:10 +00:00
|
|
|
// Box the textview, so it doesn't get too wide.
|
|
|
|
// A 0 height value means it will be unconstrained.
|
2016-08-04 04:55:41 +00:00
|
|
|
.child(TextView::new(text).scrollable(false).fixed_width(30))
|
|
|
|
.child(TextView::new(text).fixed_width(30))
|
|
|
|
.child(TextView::new(text).fixed_width(30))
|
2017-10-12 23:38:55 +00:00
|
|
|
.child(TextView::new(text).fixed_width(30)),
|
|
|
|
).button("Quit", |s| s.quit())
|
|
|
|
.h_align(HAlign::Center),
|
|
|
|
);
|
2015-06-08 19:23:36 +00:00
|
|
|
|
|
|
|
siv.run();
|
|
|
|
}
|