diff options
author | Manos Pitsidianakis <el13635@mail.ntua.gr> | 2019-02-15 09:16:21 +0200 |
---|---|---|
committer | Manos Pitsidianakis <el13635@mail.ntua.gr> | 2019-06-10 19:40:37 +0300 |
commit | 04411f10034439df9352d8c4481ae1aaca7ddc54 (patch) | |
tree | f63662dc29f01fcc91d7c9ea97952c9eef013e6b /ui/src/components/mail/listing/mod.rs | |
parent | 92bb3bf8d3beceac99d09b6edc73b0177488c12f (diff) |
rename 'mod.rs' files
closes #53
Diffstat (limited to 'ui/src/components/mail/listing/mod.rs')
-rw-r--r-- | ui/src/components/mail/listing/mod.rs | 118 |
1 files changed, 0 insertions, 118 deletions
diff --git a/ui/src/components/mail/listing/mod.rs b/ui/src/components/mail/listing/mod.rs deleted file mode 100644 index 4bd6898d..00000000 --- a/ui/src/components/mail/listing/mod.rs +++ /dev/null @@ -1,118 +0,0 @@ -/* - * meli - ui crate. - * - * Copyright 2017-2018 Manos Pitsidianakis - * - * This file is part of meli. - * - * meli is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * meli is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with meli. If not, see <http://www.gnu.org/licenses/>. - */ - -use super::*; - -mod compact; -pub use self::compact::*; - -mod thread; -pub use self::thread::*; - -mod plain; -pub use self::plain::*; - -#[derive(Debug)] -pub enum Listing { - Plain(PlainListing), - Threaded(ThreadListing), - Compact(CompactListing), -} - -impl fmt::Display for Listing { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - match self { - Listing::Compact(l) => write!(f, "{}", l), - Listing::Plain(l) => write!(f, "{}", l), - Listing::Threaded(l) => write!(f, "{}", l), - } - } -} - -impl Default for Listing { - fn default() -> Self { - Listing::Threaded(Default::default()) - } -} - -impl Component for Listing { - fn draw(&mut self, grid: &mut CellBuffer, area: Area, context: &mut Context) { - match self { - Listing::Compact(l) => l.draw(grid, area, context), - Listing::Plain(l) => l.draw(grid, area, context), - Listing::Threaded(l) => l.draw(grid, area, context), - } - } - fn process_event(&mut self, event: &UIEvent, context: &mut Context) -> bool { - if match self { - Listing::Plain(l) => l.process_event(event, context), - Listing::Compact(l) => l.process_event(event, context), - Listing::Threaded(l) => l.process_event(event, context), - } { - return true; - } - - match event.event_type { - UIEventType::Resize => self.set_dirty(), - UIEventType::Action(ref action) => match action { - Action::Listing(ListingAction::SetPlain) => { - if let Listing::Plain(_) = self { - return true; - } - *self = Listing::Plain(PlainListing::default()); - return true; - } - Action::Listing(ListingAction::SetThreaded) => { - if let Listing::Threaded(_) = self { - return true; - } - self.set_dirty(); - *self = Listing::Threaded(ThreadListing::default()); - return true; - } - Action::Listing(ListingAction::SetCompact) => { - if let Listing::Compact(_) = self { - return true; - } - *self = Listing::Compact(CompactListing::default()); - return true; - } - _ => {} - }, - _ => {} - } - false - } - fn is_dirty(&self) -> bool { - match self { - Listing::Compact(l) => l.is_dirty(), - Listing::Plain(l) => l.is_dirty(), - Listing::Threaded(l) => l.is_dirty(), - } - } - fn set_dirty(&mut self) { - match self { - Listing::Compact(l) => l.set_dirty(), - Listing::Plain(l) => l.set_dirty(), - Listing::Threaded(l) => l.set_dirty(), - } - } -} |