diff options
| author | Rubén Beltrán del Río <jj@r.bdr.sh> | 2025-12-26 21:26:57 +0100 |
|---|---|---|
| committer | Rubén Beltrán del Río <jj@r.bdr.sh> | 2025-12-26 21:28:08 +0100 |
| commit | 9129c8bc3376cc6014dd97113ceb9ff189d5e411 (patch) | |
| tree | 0362f3a57823de8d00904bdfb52681794f937640 /src | |
| parent | 5cb79e3f86b5328301eabbbc409f254b58ee9bf4 (diff) | |
Update rust version
Diffstat (limited to 'src')
| -rw-r--r-- | src/main.rs | 32 | ||||
| -rw-r--r-- | src/stages.rs | 2 |
2 files changed, 20 insertions, 14 deletions
diff --git a/src/main.rs b/src/main.rs index e99316c..562530d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -5,15 +5,18 @@ mod icon_names { include!(concat!(env!("OUT_DIR"), "/icon_names.rs")); } -use wmap_parser::{parse, Map}; -use wmap_renderer::{render_to_surface, StageType, Configuration}; +use crate::icon_names::shipped::{ + IMAGE_REGULAR, PLUS, SPLIT_HORIZONTAL_REGULAR, SPLIT_VERTICAL_REGULAR, ZOOM_IN_REGULAR, + ZOOM_OUT_REGULAR, +}; +use cairo::ImageSurface; use gtk::prelude::*; -use relm4::{gtk, ComponentParts, ComponentSender, RelmApp, RelmWidgetExt, SimpleComponent}; -use sourceview5::prelude::{BufferExt, TextBufferExt, TextViewExt}; +use relm4::{ComponentParts, ComponentSender, RelmApp, RelmWidgetExt, SimpleComponent, gtk}; use sourceview5::LanguageManager; +use sourceview5::prelude::{BufferExt, TextBufferExt, TextViewExt}; use stages::all_stages; -use crate::icon_names::shipped::{ZOOM_IN_REGULAR, ZOOM_OUT_REGULAR, IMAGE_REGULAR, PLUS, SPLIT_HORIZONTAL_REGULAR, SPLIT_VERTICAL_REGULAR}; -use cairo::ImageSurface; +use wmap_parser::{Map, parse}; +use wmap_renderer::{Configuration, StageType, render_to_surface}; struct AppModel { orientation: gtk::Orientation, @@ -41,7 +44,9 @@ enum AppAction { impl AppModel { fn update_image(&mut self) { - if let Ok(surface) = render_to_surface(&self.map, self.stage_type, &self.render_configuration) { + if let Ok(surface) = + render_to_surface(&self.map, self.stage_type, &self.render_configuration) + { self.surface_width = (surface.width() as f64 * self.zoom).round() as i32; self.surface_height = (surface.height() as f64 * self.zoom).round() as i32; self.surface = surface; @@ -49,11 +54,12 @@ impl AppModel { let zoom = self.zoom; let surface_clone = self.surface.clone(); - self.drawing_area.set_draw_func(move |_, cr, _width, _height| { - cr.scale(zoom, zoom); - cr.set_source_surface(&surface_clone, 0.0, 0.0).ok(); - cr.paint().ok(); - }); + self.drawing_area + .set_draw_func(move |_, cr, _width, _height| { + cr.scale(zoom, zoom); + cr.set_source_surface(&surface_clone, 0.0, 0.0).ok(); + cr.paint().ok(); + }); self.drawing_area.set_content_width(self.surface_width); self.drawing_area.set_content_height(self.surface_height); @@ -267,7 +273,7 @@ impl SimpleComponent for AppModel { AppAction::Zoom(new_zoom) => { self.zoom = new_zoom; self.update_image(); - }, + } AppAction::ZoomOut => { if self.zoom - constants::ZOOM_STEP >= constants::MIN_ZOOM { self.zoom -= constants::ZOOM_STEP; diff --git a/src/stages.rs b/src/stages.rs index 28079bd..9584c68 100644 --- a/src/stages.rs +++ b/src/stages.rs @@ -1,4 +1,4 @@ -use wmap_renderer::{StageType}; +use wmap_renderer::StageType; pub fn all_stages() -> &'static [StageType] { &[ |