diff options
Diffstat (limited to 'src/handlers/zoom.rs')
| -rw-r--r-- | src/handlers/zoom.rs | 25 |
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(); + } +} |