Activity Trait

This commit is contained in:
ChristianVisintin
2020-11-21 17:39:36 +01:00
parent 056f8c7c7f
commit 43ab9a9df0
2 changed files with 52 additions and 0 deletions

51
src/ui/activities/mod.rs Normal file
View File

@@ -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 <http://www.gnu.org/licenses/>.
*
*/
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);
}

View File

@@ -24,5 +24,6 @@
*/ */
// Modules // Modules
pub mod activities;
pub mod context; pub mod context;
pub(crate) mod input; pub(crate) mod input;