Skip to content

Commit

Permalink
Add rich example
Browse files Browse the repository at this point in the history
  • Loading branch information
fin-ger committed Aug 12, 2024
1 parent 99b17a5 commit 4d6e0e0
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions examples/rich.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
use cursive::view::{Resizable, SizeConstraint};
use cursive::views::{DummyView, Panel, LinearLayout, TextView, Button};
use cursive::{Cursive, CursiveExt};
use cursive_aligned_view::Alignable;

fn main() {
let mut siv = Cursive::default();

let left = Panel::new(DummyView).title("Left panel");
let bottom = Panel::new(DummyView).title("Bottom panel");
let right_top = Panel::new(DummyView).title("Right top panel");
let right_bottom = Panel::new(
LinearLayout::vertical()
.child(TextView::new("Press this button to quit"))
.child(Button::new("Quit", |s| s.quit()))
.align_center()
.resized(SizeConstraint::Free, SizeConstraint::Free)
).title("Right bottom panel");

let layout = LinearLayout::vertical().child(
LinearLayout::horizontal().child(left).child(
LinearLayout::vertical().child(right_top).child(right_bottom)
)
).child(bottom);

siv.add_fullscreen_layer(layout);
siv.run();
}

0 comments on commit 4d6e0e0

Please sign in to comment.