implement modal view wrapper
this wrapper swallows all events that were not processed by the child view. it can be used for modal dialogs.
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
pub mod layout;
|
pub mod layout;
|
||||||
pub mod listview;
|
pub mod listview;
|
||||||
|
pub mod modal;
|
||||||
pub mod playlists;
|
pub mod playlists;
|
||||||
pub mod queue;
|
pub mod queue;
|
||||||
pub mod search;
|
pub mod search;
|
||||||
|
|||||||
22
src/ui/modal.rs
Normal file
22
src/ui/modal.rs
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
use cursive::event::{Event, EventResult};
|
||||||
|
use cursive::view::{View, ViewWrapper};
|
||||||
|
|
||||||
|
pub struct Modal<T: View> {
|
||||||
|
inner: T,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<T: View> Modal<T> {
|
||||||
|
pub fn new(inner: T) -> Self {
|
||||||
|
Modal { inner: inner }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<T: View> ViewWrapper for Modal<T> {
|
||||||
|
wrap_impl!(self.inner: T);
|
||||||
|
fn wrap_on_event(&mut self, ch: Event) -> EventResult {
|
||||||
|
match self.inner.on_event(ch) {
|
||||||
|
EventResult::Consumed(cb) => EventResult::Consumed(cb),
|
||||||
|
_ => EventResult::Consumed(None),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user