From 283205081cf42b48f1ca28f005cbe7b5eee2f173 Mon Sep 17 00:00:00 2001 From: Savanni D'Gerinel Date: Tue, 27 Feb 2024 23:28:48 -0500 Subject: [PATCH] Add the placeholders for game review and settings --- .../src/view_models/game_review_view_model.rs | 38 +++++++++++++++++++ ...abase_view_model.rs => home_view_model.rs} | 4 +- kifu/gtk/src/view_models/mod.rs | 12 ++++-- .../src/view_models/settings_view_model.rs | 38 +++++++++++++++++++ 4 files changed, 87 insertions(+), 5 deletions(-) create mode 100644 kifu/gtk/src/view_models/game_review_view_model.rs rename kifu/gtk/src/view_models/{database_view_model.rs => home_view_model.rs} (97%) create mode 100644 kifu/gtk/src/view_models/settings_view_model.rs diff --git a/kifu/gtk/src/view_models/game_review_view_model.rs b/kifu/gtk/src/view_models/game_review_view_model.rs new file mode 100644 index 0000000..c117347 --- /dev/null +++ b/kifu/gtk/src/view_models/game_review_view_model.rs @@ -0,0 +1,38 @@ +/* +Copyright 2024, Savanni D'Gerinel + +This file is part of Kifu. + +Kifu 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. + +Kifu 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 Kifu. If not, see . +*/ + +use crate::LocalObserver; +use kifu_core::{Core, CoreNotification}; + +pub struct GameReviewViewModel { + core: Core, + notification_observer: LocalObserver, + widget: gtk::Box, +} + +impl GameReviewViewModel { + fn new(core: Core) -> Self { + let notification_observer = LocalObserver::new(&core, |msg| { + println!("GameReviewViewModel called with message: {:?}", msg) + }); + + Self { + core, + notification_observer, + widget: gtk::Box::new(gtk::Orientation::Horizontal, 0), + } + } +} diff --git a/kifu/gtk/src/view_models/database_view_model.rs b/kifu/gtk/src/view_models/home_view_model.rs similarity index 97% rename from kifu/gtk/src/view_models/database_view_model.rs rename to kifu/gtk/src/view_models/home_view_model.rs index 1afe39d..78db7bc 100644 --- a/kifu/gtk/src/view_models/database_view_model.rs +++ b/kifu/gtk/src/view_models/home_view_model.rs @@ -18,13 +18,13 @@ use crate::LocalObserver; use kifu_core::{Core, CoreNotification}; /// DatabaseViewModel controls the view that the user sees when starting the application if the application has been configured and if there are no games in progress. It provides a window into the database, showing a list of recently recorded games (whether from this app or from a main database). It also provides the UI for starting a new game. This will render an empty database view if the user hasn't configured a database yet. -pub struct DatabaseViewModel { +pub struct HomeViewModel { core: Core, notification_observer: LocalObserver, widget: gtk::Box, } -impl DatabaseViewModel { +impl HomeViewModel { fn new(core: Core) -> Self { let notification_observer = LocalObserver::new(&core, |msg| { println!("DatabaseViewModelHandler called with message: {:?}", msg) diff --git a/kifu/gtk/src/view_models/mod.rs b/kifu/gtk/src/view_models/mod.rs index e41396c..c69dcf9 100644 --- a/kifu/gtk/src/view_models/mod.rs +++ b/kifu/gtk/src/view_models/mod.rs @@ -20,8 +20,14 @@ Every view model requires a reference to the app so that it can call functions o The view model is primary over the view. It will construct the view, it can make major changes to the view or even swap for another related view. It must listen for all messages from the core, discarding those that aren't relevant to it. It will also convert requests from sync to async. */ -mod database_view_model; -pub use database_view_model::DatabaseViewModel; - mod game_view_model; pub use game_view_model::GameViewModel; + +mod game_review_view_model; +pub use game_review_view_model::GameReviewViewModel; + +mod home_view_model; +pub use home_view_model::HomeViewModel; + +mod settings_view_model; +pub use settings_view_model::SettingsViewModel; diff --git a/kifu/gtk/src/view_models/settings_view_model.rs b/kifu/gtk/src/view_models/settings_view_model.rs new file mode 100644 index 0000000..2f13cd8 --- /dev/null +++ b/kifu/gtk/src/view_models/settings_view_model.rs @@ -0,0 +1,38 @@ +/* +Copyright 2024, Savanni D'Gerinel + +This file is part of Kifu. + +Kifu 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. + +Kifu 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 Kifu. If not, see . +*/ + +use crate::LocalObserver; +use kifu_core::{Core, CoreNotification}; + +pub struct SettingsViewModel { + core: Core, + notification_observer: LocalObserver, + widget: gtk::Box, +} + +impl SettingsViewModel { + fn new(core: Core) -> Self { + let notification_observer = LocalObserver::new(&core, |msg| { + println!("SettingsViewModel called with message: {:?}", msg) + }); + + Self { + core, + notification_observer, + widget: gtk::Box::new(gtk::Orientation::Horizontal, 0), + } + } +}