aboutsummaryrefslogtreecommitdiff
path: root/src/handlers/zoom.rs
diff options
context:
space:
mode:
authorRubén Beltrán del Río <jj@r.bdr.sh>2026-01-16 00:08:41 +0100
committerRubén Beltrán del Río <jj@r.bdr.sh>2026-01-16 00:12:53 +0100
commit04b1e6080d99601b8d6343be3140f545cd8f9eae (patch)
tree2180b7d50f2442e5d18a99a87e56def29b02f68e /src/handlers/zoom.rs
parentab6492a9f9b8a65121fcf10ff5a44660bd063af1 (diff)
Separate concerns
Diffstat (limited to 'src/handlers/zoom.rs')
-rw-r--r--src/handlers/zoom.rs25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/handlers/zoom.rs b/src/handlers/zoom.rs
new file mode 100644
index 0000000..3acbb2c
--- /dev/null
+++ b/src/handlers/zoom.rs
@@ -0,0 +1,25 @@
+use crate::AppModel;
+use crate::constants;
+
+/// Sets the zoom level and updates the rendered image.
+pub fn zoom(model: &mut AppModel, level: f64) {
+ model.zoom = level;
+ model.update_image();
+}
+
+/// Decreases zoom by one step if above minimum.
+pub fn zoom_out(model: &mut AppModel) {
+ let new_zoom = model.zoom - constants::ZOOM_STEP;
+ if new_zoom >= constants::MIN_ZOOM {
+ model.zoom = new_zoom;
+ model.update_image();
+ }
+}
+
+/// Increases zoom by one step if below maximum.
+pub fn zoom_in(model: &mut AppModel) {
+ if model.zoom < constants::MAX_ZOOM {
+ model.zoom += constants::ZOOM_STEP;
+ model.update_image();
+ }
+}