diff --git a/src/ui/mod.rs b/src/ui/mod.rs index eab8703..bf4a8dc 100644 --- a/src/ui/mod.rs +++ b/src/ui/mod.rs @@ -1,5 +1,6 @@ pub mod layout; pub mod listview; +pub mod modal; pub mod playlists; pub mod queue; pub mod search; diff --git a/src/ui/modal.rs b/src/ui/modal.rs new file mode 100644 index 0000000..515915d --- /dev/null +++ b/src/ui/modal.rs @@ -0,0 +1,22 @@ +use cursive::event::{Event, EventResult}; +use cursive::view::{View, ViewWrapper}; + +pub struct Modal { + inner: T, +} + +impl Modal { + pub fn new(inner: T) -> Self { + Modal { inner: inner } + } +} + +impl ViewWrapper for Modal { + 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), + } + } +}