From c5d45b748d90c79f881c4e054b425d68801dad14 Mon Sep 17 00:00:00 2001 From: Rubén Beltrán del Río Date: Thu, 26 Mar 2026 18:13:49 +0100 Subject: Spin header into its own component --- src/handlers/view.rs | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'src/handlers/view.rs') diff --git a/src/handlers/view.rs b/src/handlers/view.rs index 660f7b9..87c4172 100644 --- a/src/handlers/view.rs +++ b/src/handlers/view.rs @@ -13,9 +13,11 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -use relm4::gtk; +use relm4::prelude::*; +use crate::components::header::HeaderAction; use crate::AppModel; +use wmap_renderer::StageType; /// Toggles between horizontal and vertical layout orientation. pub fn change_orientation(model: &mut AppModel) { @@ -23,14 +25,17 @@ pub fn change_orientation(model: &mut AppModel) { gtk::Orientation::Horizontal => gtk::Orientation::Vertical, _ => gtk::Orientation::Horizontal, }; + model.header.emit(HeaderAction::SetLayoutOrientation(model.orientation)); } /// Updates the selected stage type from dropdown selection. -pub fn stage_type_selected(model: &mut AppModel, index: usize) { - if index < model.available_stage_types.len() - && let Some(stage_type) = model.available_stage_types.get(index) - { - model.stage_type = stage_type.clone(); - model.update_image(); - } +pub fn stage_type_selected(model: &mut AppModel, stage_type: StageType) { + model.stage_type = stage_type; + model.update_image(); +} + +/// Updates the selected stage type from dropdown selection. +pub fn change_horizontal_layout(model: &mut AppModel, is_enabled: bool) { + model.horizontal_layout_enabled = is_enabled; + model.header.emit(HeaderAction::SetHorizontalLayoutEnabled(is_enabled)); } -- cgit