[][src]Struct fui::cursive::views::Dialog

pub struct Dialog { /* fields omitted */ }

Popup-like view with a main content, and optional buttons under it.

Examples

let dialog = Dialog::around(TextView::new("Hello!"))
                    .button("Ok", |s| s.quit());

Methods

impl Dialog[src]

pub fn new() -> Dialog[src]

Creates a new Dialog with empty content.

You should probably call content() next.

pub fn around<V>(view: V) -> Dialog where
    V: 'static + View
[src]

Creates a new Dialog with the given content.

pub fn content<V>(self, view: V) -> Dialog where
    V: 'static + View
[src]

Sets the content for this dialog.

Chainable variant.

pub fn get_content(&self) -> &(dyn View + 'static)[src]

Gets the content of this dialog.

use cursive::views::{Dialog, TextView};
let dialog = Dialog::around(TextView::new("Hello!"));
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_mut(&mut self) -> &mut (dyn View + 'static)[src]

Gets mutable access to the content.

pub fn set_content<V>(&mut self, view: V) where
    V: 'static + View
[src]

Sets the content for this dialog.

Previous content will be dropped.

pub fn text<S>(text: S) -> Dialog where
    S: Into<String>, 
[src]

Convenient method to create a dialog with a simple text content.

pub fn info<S>(text: S) -> Dialog where
    S: Into<String>, 
[src]

Convenient method to create an infobox.

It will contain the given text and a Ok dismiss button.

pub fn button<F, S>(self, label: S, cb: F) -> Dialog where
    F: 'static + Fn(&mut Cursive),
    S: Into<String>, 
[src]

Adds a button to the dialog with the given label and callback.

Consumes and returns self for easy chaining.

pub fn add_button<F, S>(&mut self, label: S, cb: F) where
    F: 'static + Fn(&mut Cursive),
    S: Into<String>, 
[src]

Adds a button to the dialog with the given label and callback.

pub fn buttons_len(&self) -> usize[src]

Returns the number of buttons on this dialog.

pub fn clear_buttons(&mut self)[src]

Removes any button from self.

pub fn remove_button(&mut self, i: usize)[src]

Removes a button from this dialog.

Panics

Panics if i >= self.buttons_len().

pub fn h_align(self, h: HAlign) -> Dialog[src]

Sets the horizontal alignment for the buttons, if any.

Only works if the buttons are as a row at the bottom of the dialog.

pub fn dismiss_button<S>(self, label: S) -> Dialog where
    S: Into<String>, 
[src]

Shortcut method to add a button that will dismiss the dialog.

pub fn title<S>(self, label: S) -> Dialog where
    S: Into<String>, 
[src]

Sets the title of the dialog.

If not empty, it will be visible at the top.

pub fn set_title<S>(&mut self, label: S) where
    S: Into<String>, 
[src]

Sets the title of the dialog.

pub fn title_position(self, align: HAlign) -> Dialog[src]

Sets the horizontal position of the title in the dialog. The default position is HAlign::Center

pub fn set_title_position(&mut self, align: HAlign)[src]

Sets the horizontal position of the title in the dialog. The default position is HAlign::Center

pub fn padding<T>(self, padding: T) -> Dialog where
    T: Into<Margins>, 
[src]

Sets the padding in the dialog (around content and buttons).

pub fn padding_top(self, padding: usize) -> Dialog[src]

Sets the top padding in the dialog (under the title).

pub fn padding_bottom(self, padding: usize) -> Dialog[src]

Sets the bottom padding in the dialog (under buttons).

pub fn padding_left(self, padding: usize) -> Dialog[src]

Sets the left padding in the dialog.

pub fn padding_right(self, padding: usize) -> Dialog[src]

Sets the right padding in the dialog.

pub fn buttons_mut(&mut self) -> impl Iterator<Item = &mut Button>[src]

Returns an iterator on this buttons for this dialog.

pub fn focus(&self) -> DialogFocus[src]

Returns currently focused element

Trait Implementations

impl View for Dialog[src]

impl Default for Dialog[src]

Auto Trait Implementations

impl !Send for Dialog

impl !Sync for Dialog

Blanket Implementations

impl<T> From for T[src]

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T> View for T where
    T: ViewWrapper
[src]

impl<T> With for T[src]

fn with<F>(self, f: F) -> Self where
    F: FnOnce(&mut Self), 
[src]

Calls the given closure on self.

fn try_with<E, F>(self, f: F) -> Result<Self, E> where
    F: FnOnce(&mut Self) -> Result<(), E>, 
[src]

Calls the given closure on self.

fn with_if<F>(self, condition: bool, f: F) -> Self where
    F: FnOnce(&mut Self), 
[src]

Calls the given closure if condition == true.

impl<T> Identifiable for T where
    T: View
[src]

fn with_id<S>(self, id: S) -> IdView<Self> where
    S: Into<String>, 
[src]

Wraps this view into an IdView with the given id. Read more

impl<T> Finder for T where
    T: View
[src]

fn call_on_id<V, F, R>(&mut self, id: &str, callback: F) -> Option<R> where
    F: FnOnce(&mut V) -> R,
    V: View + Any
[src]

Convenient method to use call_on with a view::Selector::Id.

fn find_id<V>(
    &mut self,
    id: &str
) -> Option<OwningHandle<OwningRef<Rc<RefCell<V>>, RefCell<V>>, RefMut<'static, V>>> where
    V: View + Any
[src]

Convenient method to find a view wrapped in an [IdView]. Read more

impl<T> Boxable for T where
    T: View
[src]

fn boxed(self, width: SizeConstraint, height: SizeConstraint) -> BoxView<Self>[src]

Wraps self in a BoxView with the given size constraints.

fn fixed_size<S>(self, size: S) -> BoxView<Self> where
    S: Into<XY<usize>>, 
[src]

Wraps self into a fixed-size BoxView.

fn fixed_width(self, width: usize) -> BoxView<Self>[src]

Wraps self into a fixed-width BoxView.

fn fixed_height(self, height: usize) -> BoxView<Self>[src]

Wraps self into a fixed-width BoxView.

fn full_screen(self) -> BoxView<Self>[src]

Wraps self into a full-screen BoxView.

fn full_width(self) -> BoxView<Self>[src]

Wraps self into a full-width BoxView.

fn full_height(self) -> BoxView<Self>[src]

Wraps self into a full-height BoxView.

fn max_size<S>(self, size: S) -> BoxView<Self> where
    S: Into<XY<usize>>, 
[src]

Wraps self into a limited-size BoxView.

fn max_width(self, max_width: usize) -> BoxView<Self>[src]

Wraps self into a limited-width BoxView.

fn max_height(self, max_height: usize) -> BoxView<Self>[src]

Wraps self into a limited-height BoxView.

fn min_size<S>(self, size: S) -> BoxView<Self> where
    S: Into<XY<usize>>, 
[src]

Wraps self into a BoxView at least sized size.

fn min_width(self, min_width: usize) -> BoxView<Self>[src]

Wraps self in a BoxView at least min_width wide.

fn min_height(self, min_height: usize) -> BoxView<Self>[src]

Wraps self in a BoxView at least min_height tall.

impl<T> Scrollable for T where
    T: View
[src]

fn scrollable(self) -> ScrollView<Self>[src]

Wraps self in a ScrollView.

impl<T> AnyView for T where
    T: View
[src]

fn as_any(&self) -> &(dyn Any + 'static)[src]

Downcast self to a Any.

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)[src]

Downcast self to a mutable Any.

impl<T> IntoBoxedView for T where
    T: View
[src]

impl<T> Erased for T