aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authorRubén Beltrán del Río <jj@r.bdr.sh>2026-03-26 23:18:11 +0100
committerRubén Beltrán del Río <jj@r.bdr.sh>2026-03-26 23:26:01 +0100
commit1f28cbdf1dbe26e4c7da27323a0202a3276cb3a7 (patch)
treef5a707ed5671d0345b21c935f5a46099b12b8f19 /src/main.rs
parent9a472115e594e28f4e3bd95b10800bf2b690febf (diff)
Move footer to its own component
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs59
1 files changed, 13 insertions, 46 deletions
diff --git a/src/main.rs b/src/main.rs
index c9393f4..f661df9 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -38,11 +38,10 @@ use std::convert::identity;
use std::path::PathBuf;
use crate::actions::Action;
-use crate::icon_names::shipped::{ ZOOM_IN_REGULAR, ZOOM_OUT_REGULAR };
use cairo::ImageSurface;
use gtk::glib;
use relm4::prelude::*;
-use relm4::actions::{AccelsPlus, ActionablePlus, RelmAction, RelmActionGroup};
+use relm4::actions::{AccelsPlus, RelmAction, RelmActionGroup};
use adw::prelude::*;
use sourceview5::LanguageManager;
@@ -53,6 +52,7 @@ use wmap_parser::{Map, parse};
use wmap_renderer::{Configuration, StageType, render_to_surface};
use components::header::{Header, HeaderInit};
+use components::footer::{Footer, FooterInit};
/// Macro to reduce boilerplate when registering actions with accelerators.
macro_rules! register_action {
@@ -136,7 +136,8 @@ struct AppModel {
editor_css_provider: gtk::CssProvider,
horizontal_layout_enabled: bool,
// Child Components
- header: Controller<Header>
+ header: Controller<Header>,
+ footer: Controller<Footer>,
}
impl AppModel {
@@ -355,48 +356,7 @@ impl SimpleComponent for AppModel {
}
},
- add_bottom_bar = &gtk::ActionBar {
- pack_end = &gtk::Box {
- set_orientation: gtk::Orientation::Horizontal,
-
- gtk::Label {
- #[watch]
- set_label: &format!("{:.1}x", model.zoom),
- set_margin_end: 5
- },
-
- gtk::Button::with_label(&tr!("command.view.zoom_out")) {
- set_icon_name: ZOOM_OUT_REGULAR,
- set_margin_end: 5,
- add_css_class: "flat",
- add_css_class: "zoom",
- add_css_class: "zoom-out",
- ActionablePlus::set_stateless_action::<ZoomOutAction>: &(),
- },
-
- gtk::Scale {
- set_orientation: gtk::Orientation::Horizontal,
- #[watch]
- set_value: model.zoom,
- set_draw_value: false,
- set_range: (constants::MIN_ZOOM, constants::MAX_ZOOM),
- set_increments: (constants::ZOOM_STEP, constants::ZOOM_STEP),
- set_value_pos: gtk::PositionType::Left,
- set_width_request: 100,
- connect_value_changed[sender] => move |scale| {
- sender.input(Action::Zoom(scale.value()));
- }
- },
-
- gtk::Button::with_label(&tr!("command.view.zoom_in")) {
- set_icon_name: ZOOM_IN_REGULAR,
- add_css_class: "flat",
- add_css_class: "zoom",
- add_css_class: "zoom-in",
- ActionablePlus::set_stateless_action::<ZoomInAction>: &(),
- },
- }
- }
+ add_bottom_bar = model.footer.widget(),
}
}
}
@@ -478,6 +438,12 @@ impl SimpleComponent for AppModel {
})
.forward(sender.input_sender(), identity);
+ let footer = Footer::builder()
+ .launch(FooterInit {
+ zoom: init.zoom
+ })
+ .forward(sender.input_sender(), identity);
+
let mut model = AppModel {
orientation,
stage_type,
@@ -499,7 +465,8 @@ impl SimpleComponent for AppModel {
preferences_window: None,
editor_css_provider,
horizontal_layout_enabled: true,
- header
+ header,
+ footer
};
model.apply_preferences();