Show film and ISO roll was shot for each roll in table

This commit is contained in:
pjht 2023-06-01 14:16:25 -05:00
parent 3ff8bc276b
commit 0232363e73
Signed by: pjht
GPG Key ID: 7B5F6AFBEC7EE78E

View File

@ -83,12 +83,14 @@ impl eframe::App for MyApp {
ui.heading("Film Manager");
egui::Grid::new("roll_table")
.striped(true)
.num_columns(4)
.num_columns(6)
.show(ui, |ui| {
ui.heading("ID");
ui.heading("Name");
ui.heading("Date");
ui.heading("Exposures");
ui.heading("Film");
ui.heading("Shot at");
ui.end_row();
for (i, roll) in self.state.rolls.iter().enumerate() {
let id_label = ui.add(Label::new(&roll.id).sense(Sense::click()));
@ -100,10 +102,21 @@ impl eframe::App for MyApp {
let exps_label = ui.add(
Label::new(&roll.exposures.len().to_string()).sense(Sense::click()),
);
let film_label = ui.add(
Label::new(&self.state.films[roll.film].name).sense(Sense::click()),
);
let shot_at_text = if let Some(shot_at) = roll.shot_at {
format!("{} ISO", shot_at)
} else {
format!("{} ISO (box speed)", &self.state.films[roll.film].iso)
};
let shot_at_label = ui.add(Label::new(shot_at_text).sense(Sense::click()));
let clicked = id_label.clicked()
|| name_label.clicked()
|| date_label.clicked()
|| exps_label.clicked();
|| exps_label.clicked()
|| film_label.clicked()
|| shot_at_label.clicked();
let old_film_rows_popup_location = self.film_rows_popup_location.clone();
let secondary_clicked = if id_label.secondary_clicked() {
self.film_rows_popup_location = Some(id_label.clone());
@ -117,26 +130,36 @@ impl eframe::App for MyApp {
} else if exps_label.secondary_clicked() {
self.film_rows_popup_location = Some(exps_label.clone());
true
} else if film_label.secondary_clicked() {
self.film_rows_popup_location = Some(film_label.clone());
true
} else if shot_at_label.secondary_clicked() {
self.film_rows_popup_location = Some(shot_at_label.clone());
true
} else {
false
};
let hovered = id_label.hovered()
|| name_label.hovered()
|| date_label.hovered()
|| exps_label.hovered();
|| exps_label.hovered()
|| film_label.hovered()
|| shot_at_label.hovered();
if hovered {
id_label.highlight();
name_label.highlight();
date_label.highlight();
exps_label.highlight();
film_label.highlight();
shot_at_label.highlight();
}
if clicked && !self.roll_views.iter().any(|view| view.roll() == i) {
self.roll_views.push(RollViewWindow::new(i));
}
let popup_id = ui.make_persistent_id("roll_context_menu");
if secondary_clicked {
if self.film_rows_popup_location.is_some()
&& self.film_rows_popup_location.as_ref().map(|resp| resp.id)
if self.film_rows_popup_location.as_ref().map(|resp| resp.id)
== old_film_rows_popup_location.as_ref().map(|resp| resp.id)
{
ui.memory_mut(|mem| mem.close_popup());