Rename scale_pct to scale_step in image::Viewer

This commit is contained in:
Héctor Ramón Jiménez 2020-12-18 10:53:38 +01:00
parent ca3e4e9f1b
commit e6f23e3771

View File

@ -21,7 +21,7 @@ pub struct Viewer<'a> {
max_height: u32, max_height: u32,
min_scale: f32, min_scale: f32,
max_scale: f32, max_scale: f32,
scale_pct: f32, scale_step: f32,
handle: image::Handle, handle: image::Handle,
} }
@ -41,7 +41,7 @@ impl<'a> Viewer<'a> {
max_height: u32::MAX, max_height: u32::MAX,
min_scale: 0.25, min_scale: 0.25,
max_scale: 10.0, max_scale: 10.0,
scale_pct: 0.10, scale_step: 0.10,
handle, handle,
} }
} }
@ -112,8 +112,8 @@ impl<'a> Viewer<'a> {
/// Default is `0.10` /// Default is `0.10`
/// ///
/// [`Viewer`]: struct.Viewer.html /// [`Viewer`]: struct.Viewer.html
pub fn scale_pct(mut self, scale_pct: f32) -> Self { pub fn scale_step(mut self, scale_step: f32) -> Self {
self.scale_pct = scale_pct; self.scale_step = scale_step;
self self
} }
@ -230,10 +230,10 @@ where
self.state.scale = Some( self.state.scale = Some(
(if y > 0.0 { (if y > 0.0 {
self.state.scale.unwrap_or(1.0) self.state.scale.unwrap_or(1.0)
* (1.0 + self.scale_pct) * (1.0 + self.scale_step)
} else { } else {
self.state.scale.unwrap_or(1.0) self.state.scale.unwrap_or(1.0)
/ (1.0 + self.scale_pct) / (1.0 + self.scale_step)
}) })
.max(self.min_scale) .max(self.min_scale)
.min(self.max_scale), .min(self.max_scale),