Dialog::get_content now returns &AnyView

This commit is contained in:
Alexandre Bury 2018-01-22 13:45:00 -08:00
parent 8aa901afb4
commit 06086fdeb0
4 changed files with 7 additions and 4 deletions

View File

@ -1,4 +1,3 @@
#[macro_use]
extern crate cursive;
use cursive::{Cursive, Printer};

View File

@ -1,4 +1,3 @@
#[macro_use]
extern crate cursive;
use cursive::{Cursive, Printer};

View File

@ -154,7 +154,7 @@ impl ScrollBase {
self.start_line = min(
div_up(
(1 + self.content_height - self.view_height) * thumb_y,
(self.view_height - thumb_height + 1),
self.view_height - thumb_height + 1,
),
self.content_height - self.view_height,
);

View File

@ -111,10 +111,15 @@ impl Dialog {
/// let text_view: &TextView = dialog.get_content().as_any().downcast_ref::<TextView>().unwrap();
/// assert_eq!(text_view.get_content().source(), "Hello!");
/// ```
pub fn get_content(&self) -> &View {
pub fn get_content(&self) -> &AnyView {
&*self.content.view
}
/// Gets mutable access to the content.
pub fn get_content_mut(&mut self) -> &mut AnyView {
&mut *self.content.view
}
/// Sets the content for this dialog.
///
/// Previous content will be dropped.