2015-06-08 19:23:36 +00:00
|
|
|
use cursive::align::HAlign;
|
2016-09-29 05:45:27 +00:00
|
|
|
use cursive::traits::*;
|
2018-06-27 00:40:15 +00:00
|
|
|
use cursive::views::{Dialog, DummyView, LinearLayout, TextView};
|
2018-01-16 02:55:27 +00:00
|
|
|
|
|
|
|
// This example uses a LinearLayout to stick multiple views next to each other.
|
2015-06-08 19:23:36 +00:00
|
|
|
|
|
|
|
fn main() {
|
2020-04-15 19:20:50 +00:00
|
|
|
let mut siv = cursive::default();
|
2015-06-08 19:23:36 +00:00
|
|
|
|
2018-06-20 17:28:44 +00:00
|
|
|
// Some description text. We want it to be long, but not _too_ long.
|
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()
|
2018-06-20 17:28:44 +00:00
|
|
|
.child(TextView::new("Title").h_align(HAlign::Center))
|
|
|
|
// Use a DummyView as spacer
|
|
|
|
.child(DummyView.fixed_height(1))
|
|
|
|
// Disabling scrollable means the view cannot shrink.
|
|
|
|
.child(TextView::new(text))
|
2018-06-24 02:00:08 +00:00
|
|
|
// The other views will share the remaining space.
|
2018-06-27 00:40:15 +00:00
|
|
|
.child(TextView::new(text).scrollable())
|
|
|
|
.child(TextView::new(text).scrollable())
|
|
|
|
.child(TextView::new(text).scrollable())
|
2018-06-20 17:28:44 +00:00
|
|
|
.fixed_width(30),
|
2019-03-01 00:04:14 +00:00
|
|
|
)
|
|
|
|
.button("Quit", |s| s.quit())
|
2018-08-22 20:33:29 +00:00
|
|
|
.h_align(HAlign::Center),
|
2017-10-12 23:38:55 +00:00
|
|
|
);
|
2015-06-08 19:23:36 +00:00
|
|
|
|
|
|
|
siv.run();
|
|
|
|
}
|