mirror of
https://github.com/FliegendeWurst/cursive.git
synced 2024-11-23 17:35:00 +00:00
Add a center()
convenient method to TextView
Avoids having to import HAlign
This commit is contained in:
parent
261d2aac48
commit
2597c9a566
@ -60,7 +60,7 @@ fn coffee_break(s: &mut Cursive) {
|
|||||||
s.pop_layer();
|
s.pop_layer();
|
||||||
s.add_layer(Dialog::empty()
|
s.add_layer(Dialog::empty()
|
||||||
.title("Preparation complete")
|
.title("Preparation complete")
|
||||||
.content(TextView::new("Now, the real deal!"))
|
.content(TextView::new("Now, the real deal!").center())
|
||||||
.button("Again??", phase_2));
|
.button("Again??", phase_2));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,6 +117,7 @@ fn final_step(s: &mut Cursive) {
|
|||||||
s.add_layer(Dialog::empty()
|
s.add_layer(Dialog::empty()
|
||||||
.title("Report")
|
.title("Report")
|
||||||
.content(TextView::new("Time travel was a success!\n\
|
.content(TextView::new("Time travel was a success!\n\
|
||||||
We went forward a few seconds!!"))
|
We went forward a few seconds!!")
|
||||||
|
.center())
|
||||||
.button("That's it?", |s| s.quit()));
|
.button("That's it?", |s| s.quit()));
|
||||||
}
|
}
|
||||||
|
@ -101,6 +101,12 @@ impl TextView {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Center the text horizontally and vertically inside the view.
|
||||||
|
pub fn center(mut self) -> Self {
|
||||||
|
self.align = Align::center();
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
/// Replace the text in this view.
|
/// Replace the text in this view.
|
||||||
pub fn set_content(&mut self, content: &str) {
|
pub fn set_content(&mut self, content: &str) {
|
||||||
let content = strip_last_newline(content);
|
let content = strip_last_newline(content);
|
||||||
|
Loading…
Reference in New Issue
Block a user