From d282761b877610630c1787a268a2846c7c0cee71 Mon Sep 17 00:00:00 2001 From: pjht Date: Wed, 14 Jun 2023 14:46:04 -0500 Subject: [PATCH] Rename shot_at to iso in code --- src/main.rs | 10 +++++----- src/new_roll.rs | 22 +++++++++++----------- src/roll.rs | 6 +++--- src/roll_view.rs | 18 +++++++++--------- 4 files changed, 28 insertions(+), 28 deletions(-) diff --git a/src/main.rs b/src/main.rs index 242e8f2..ebdb940 100644 --- a/src/main.rs +++ b/src/main.rs @@ -187,11 +187,11 @@ impl eframe::App for MyApp { .name .cmp(&self.state.films[roll_2.film].name), RollField::ISO => roll_1 - .shot_at + .iso .unwrap_or(self.state.films[roll_1.film].iso) .cmp( &roll_2 - .shot_at + .iso .unwrap_or(self.state.films[roll_2.film].iso), ), }; @@ -214,12 +214,12 @@ impl eframe::App for MyApp { .push(add_clickable_label(ui, &roll.exposures.len().to_string())); widget_resps .push(add_clickable_label(ui, &self.state.films[roll.film].name)); - let shot_at_text = if let Some(shot_at) = roll.shot_at { - format!("{} ISO", shot_at) + let iso_text = if let Some(iso) = roll.iso { + format!("{} ISO", iso) } else { format!("{} ISO (box speed)", &self.state.films[roll.film].iso) }; - widget_resps.push(add_clickable_label(ui, shot_at_text)); + widget_resps.push(add_clickable_label(ui, iso_text)); if widget_resps.iter().any(|resp| resp.clicked()) { self.roll_view = Some(RollView::new(i)); diff --git a/src/new_roll.rs b/src/new_roll.rs index cf3d165..17f8c1a 100644 --- a/src/new_roll.rs +++ b/src/new_roll.rs @@ -14,7 +14,7 @@ pub struct NewRollWindow { desc: String, date: NaiveDate, film: FilmKey, - shot_at: Option, + iso: Option, exps: u8, show_id_req_err: bool, show_pp_iso_err: bool, @@ -33,7 +33,7 @@ impl NewRollWindow { desc: String::new(), date: Local::now().date_naive(), film, - shot_at: None, + iso: None, exps: 24, show_id_req_err: false, show_pp_iso_err: false, @@ -98,19 +98,19 @@ impl NewRollWindow { ui.selectable_value(&mut self.film, i, film.to_string()); } }); - if self.film != old_film && self.shot_at.is_some() { - self.shot_at = Some(app_state.films[self.film].iso); + if self.film != old_film && self.iso.is_some() { + self.iso = Some(app_state.films[self.film].iso); } }); ui.horizontal(|ui| { ui.label("Pushed/Pulled: "); - let mut check_state = self.shot_at.is_some(); + let mut check_state = self.iso.is_some(); ui.checkbox(&mut check_state, ""); - if check_state != self.shot_at.is_some() { + if check_state != self.iso.is_some() { if check_state { - self.shot_at = Some(app_state.films[self.film].iso); + self.iso = Some(app_state.films[self.film].iso); } else { - self.shot_at = None; + self.iso = None; self.show_pp_iso_err = false; } } @@ -122,7 +122,7 @@ impl NewRollWindow { ); } ui.horizontal(|ui| { - if let Some(ref mut iso) = self.shot_at { + if let Some(ref mut iso) = self.iso { let label = ui.label("ISO: "); ui.add(DragValue::new(iso).clamp_range(1..=u32::MAX)) .labelled_by(label.id); @@ -131,7 +131,7 @@ impl NewRollWindow { if ui.button("Submit").clicked() { self.show_id_req_err = self.id.is_empty(); self.show_pp_iso_err = self - .shot_at + .iso .map_or(false, |iso| iso == app_state.films[self.film].iso); if !self.show_id_req_err && !self.show_pp_iso_err { app_state.rolls.push(Roll::new( @@ -140,7 +140,7 @@ impl NewRollWindow { self.desc.clone(), self.date, self.film, - self.shot_at, + self.iso, self.exps, )); app_state.resort_roll_list = true; diff --git a/src/roll.rs b/src/roll.rs index 0ea84b2..67b90e7 100644 --- a/src/roll.rs +++ b/src/roll.rs @@ -52,7 +52,7 @@ pub struct Roll { pub desc: String, pub date: NaiveDate, pub film: FilmKey, - pub shot_at: Option, + pub iso: Option, pub exposures: Vec, } @@ -63,7 +63,7 @@ impl Roll { desc: String, date: NaiveDate, film: FilmKey, - shot_at: Option, + iso: Option, num_exposures: u8, ) -> Self { let mut exposures = Vec::new(); @@ -79,7 +79,7 @@ impl Roll { desc, date, film, - shot_at, + iso, exposures, } } diff --git a/src/roll_view.rs b/src/roll_view.rs index a1cafc2..c4c8ce3 100644 --- a/src/roll_view.rs +++ b/src/roll_view.rs @@ -15,7 +15,7 @@ pub struct RollView { exp: u8, editing: bool, edit_roll: Roll, - edit_shot_at: Option, + edit_iso: Option, show_id_req_err: bool, show_pp_iso_err: bool, } @@ -28,7 +28,7 @@ impl RollView { exp: 0, editing: false, edit_roll: Roll::default(), - edit_shot_at: None, + edit_iso: None, show_id_req_err: false, show_pp_iso_err: false, } @@ -119,13 +119,13 @@ impl RollView { if self.editing { ui.horizontal(|ui| { ui.label("Pushed/Pulled: "); - let mut check_state = self.edit_roll.shot_at.is_some(); + let mut check_state = self.edit_roll.iso.is_some(); ui.checkbox(&mut check_state, ""); - if check_state != self.edit_roll.shot_at.is_some() { + if check_state != self.edit_roll.iso.is_some() { if check_state { - self.edit_roll.shot_at = Some(app_state.films[self.edit_roll.film].iso); + self.edit_roll.iso = Some(app_state.films[self.edit_roll.film].iso); } else { - self.edit_roll.shot_at = None; + self.edit_roll.iso = None; self.show_pp_iso_err = false; } } @@ -136,7 +136,7 @@ impl RollView { "Error: Push/pull ISO must be different from the roll's box ISO", ); } - if let Some(ref mut iso) = self.edit_roll.shot_at { + if let Some(ref mut iso) = self.edit_roll.iso { ui.horizontal(|ui| { let label = ui.label("ISO: "); ui.add(DragValue::new(iso).clamp_range(1..=u32::MAX)) @@ -145,7 +145,7 @@ impl RollView { } } else { ui.horizontal(|ui| { - if let Some(iso) = roll.shot_at { + if let Some(iso) = roll.iso { if iso > app_state.films[roll.film].iso { ui.label(format!( "Pushed {:.2} stops (ISO {})", @@ -174,7 +174,7 @@ impl RollView { if ui.button("Done").clicked() { self.show_id_req_err = self.edit_roll.id.is_empty(); self.show_pp_iso_err = self - .edit_shot_at + .edit_iso .map_or(false, |iso| iso == app_state.films[self.edit_roll.film].iso); if !self.show_id_req_err && !self.show_pp_iso_err { let roll_exps = mem::take(&mut roll.exposures);