mirror of
https://github.com/FliegendeWurst/cursive.git
synced 2024-11-09 02:40:40 +00:00
8fa704bcfa
And `Dialog::empty` -> `Dialog::new`
30 lines
1.1 KiB
Rust
30 lines
1.1 KiB
Rust
extern crate cursive;
|
|
|
|
use cursive::Cursive;
|
|
use cursive::views::{Dialog, LinearLayout, TextView};
|
|
use cursive::align::HAlign;
|
|
use cursive::traits::*;
|
|
|
|
fn main() {
|
|
let mut siv = Cursive::new();
|
|
|
|
// Some description text
|
|
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.";
|
|
|
|
// We'll create a dialog with a TextView serving as a title
|
|
siv.add_layer(Dialog::around(LinearLayout::vertical()
|
|
.child(TextView::new("Title").h_align(HAlign::Center))
|
|
// Box the textview, so it doesn't get too wide.
|
|
// A 0 height value means it will be unconstrained.
|
|
.child(TextView::new(text).scrollable(false).fixed_width(30))
|
|
.child(TextView::new(text).fixed_width(30))
|
|
.child(TextView::new(text).fixed_width(30))
|
|
.child(TextView::new(text).fixed_width(30)))
|
|
.button("Quit", |s| s.quit())
|
|
.h_align(HAlign::Center));
|
|
|
|
siv.run();
|
|
}
|