pub struct DialogComponent<S, A>where
    S: Debug + Default + Clone + PartialEq + Sync + Send,
    A: Debug + Default + Clone + Sync + Send,{
    pub id: FlexBoxId,
    pub dialog_engine: DialogEngine,
    pub on_dialog_press_handler: Option<fn(_: DialogChoice, _: &Arc<RwLock<Store<S, A>>>)>,
    pub on_dialog_editor_change_handler: Option<fn(_: EditorBuffer, _: &Arc<RwLock<Store<S, A>>>)>,
}
Expand description

This is a shim which allows the reusable DialogEngine to be used in the context of Component and r3bl_redux::Store. The main methods here simply pass thru all their arguments to the DialogEngine.

Fields§

§id: FlexBoxId§dialog_engine: DialogEngine§on_dialog_press_handler: Option<fn(_: DialogChoice, _: &Arc<RwLock<Store<S, A>>>)>

Make sure to dispatch actions to handle the user’s dialog choice DialogChoice.

§on_dialog_editor_change_handler: Option<fn(_: EditorBuffer, _: &Arc<RwLock<Store<S, A>>>)>

Make sure to dispatch an action to update the dialog buffer’s editor buffer.

Implementations§

source§

impl<S, A> DialogComponent<S, A>where S: Debug + Default + Clone + PartialEq + Sync + Send, A: Debug + Default + Clone + Sync + Send,

source

pub fn new( id: FlexBoxId, dialog_options: DialogEngineConfigOptions, editor_options: EditorEngineConfig, on_dialog_press_handler: fn(_: DialogChoice, _: &Arc<RwLock<Store<S, A>>>), on_dialog_editor_change_handler: fn(_: EditorBuffer, _: &Arc<RwLock<Store<S, A>>>) ) -> DialogComponent<S, A>

The on_dialog_press_handler is a lambda that is called if the user presses enter or escape. Typically this results in a Redux action being created and then dispatched to the given store.

source

pub fn new_shared( id: FlexBoxId, dialog_options: DialogEngineConfigOptions, editor_options: EditorEngineConfig, on_dialog_press_handler: fn(_: DialogChoice, _: &Arc<RwLock<Store<S, A>>>), on_dialog_editor_change_handler: fn(_: EditorBuffer, _: &Arc<RwLock<Store<S, A>>>) ) -> Arc<RwLock<DialogComponent<S, A>>>

Trait Implementations§

source§

impl<S, A> Clone for DialogComponent<S, A>where S: Clone + Debug + Default + PartialEq + Sync + Send, A: Clone + Debug + Default + Sync + Send,

source§

fn clone(&self) -> DialogComponent<S, A>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<S, A> Component<S, A> for DialogComponent<S, A>where S: HasDialogBuffers + Default + Clone + PartialEq + Debug + Sync + Send, A: Debug + Default + Clone + Sync + Send,

source§

fn render<'life0, 'life1, 'life2, 'async_trait>( &'life0 mut self, args: ComponentScopeArgs<'life1, S, A>, _current_box: &'life2 FlexBox, surface_bounds: SurfaceBounds ) -> Pin<Box<dyn Future<Output = Result<RenderPipeline, Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, DialogComponent<S, A>: 'async_trait,

This shim simply calls DialogEngineApi::render_engine w/ all the necessary arguments:

Note:

  1. The 3rd argument _current_box FlexBox is ignored since the dialog component breaks out of whatever box the layout places it in, and ends up painting itself over the entire screen.
  2. However, SurfaceBounds is saved for later use. And it is used to restrict where the dialog can be placed on the screen.
source§

fn handle_event<'life0, 'life1, 'life2, 'async_trait>( &'life0 mut self, args: ComponentScopeArgs<'life1, S, A>, input_event: &'life2 InputEvent ) -> Pin<Box<dyn Future<Output = Result<EventPropagation, Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, DialogComponent<S, A>: 'async_trait,

This shim simply calls DialogEngineApi::apply_event w/ all the necessary arguments:

Usually a component must have focus in order for the App to route_event_to_focused_component in the first place.

source§

fn reset(&mut self)

This is an optional method that can be used to initialize the state of the component’s engines. This applies to modal dialog components that need their engine to be initialized before they are shown / activated.
source§

fn get_id(&self) -> FlexBoxId

source§

impl<S, A> Default for DialogComponent<S, A>where S: Default + Debug + Clone + PartialEq + Sync + Send, A: Default + Debug + Clone + Sync + Send,

source§

fn default() -> DialogComponent<S, A>

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<S, A> RefUnwindSafe for DialogComponent<S, A>

§

impl<S, A> Send for DialogComponent<S, A>

§

impl<S, A> Sync for DialogComponent<S, A>

§

impl<S, A> Unpin for DialogComponent<S, A>

§

impl<S, A> UnwindSafe for DialogComponent<S, A>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V