diff --git a/src/ui/activities/mod.rs b/src/ui/activities/mod.rs new file mode 100644 index 0000000..64717ef --- /dev/null +++ b/src/ui/activities/mod.rs @@ -0,0 +1,51 @@ +//! ## Activities +//! +//! `activities` is the module which provides all the different activities +//! each activity identifies a layout with its own logic in the UI + +/* +* +* Copyright (C) 2020 Christian Visintin - christian.visintin1997@gmail.com +* +* This file is part of "TermSCP" +* +* TermSCP 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. +* +* TermSCP 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 TermSCP. If not, see . +* +*/ + +use super::context::Context; + +// Activities + +// Activity trait + +pub trait Activity { + /// ### on_create + /// + /// `on_create` is the function which must be called to initialize the activity. + /// `on_create` must initialize all the data structures used by the activity + fn on_create(&mut self, context: &mut Context); + + /// ### on_draw + /// + /// `on_draw` is the function which draws the graphical interface. + /// This function must be called at each tick to refresh the interface + fn on_draw(&mut self, context: &mut Context); + + /// ### on_destroy + /// + /// `on_destroy` is the function which cleans up runtime variables and data before terminating the activity. + /// This function must be called once before terminating the activity. + fn on_destroy(&mut self, context: &mut Context); +} diff --git a/src/ui/mod.rs b/src/ui/mod.rs index 9744c6d..e4e4bd4 100644 --- a/src/ui/mod.rs +++ b/src/ui/mod.rs @@ -24,5 +24,6 @@ */ // Modules +pub mod activities; pub mod context; pub(crate) mod input;