mirror of
https://github.com/storytold/lightcraft.git
synced 2026-10-28 03:57:57 -06:00
fix: EXIF values under histogram run together (#913)
- Filter empty EXIF values instead of rendering empty strings at fixed positions - Distribute remaining items evenly across available width using (i + 0.5) / count - Apply left/center/right alignment dynamically based on item position - Fixes 'ISO 1000200mm' visual collision when focal length or aperture missing
This commit is contained in:
@@ -561,21 +561,28 @@ fn histogram(app: &mut LightcraftApp, ui: &mut egui::Ui, id: PhotoId) {
|
||||
// EXIF strip
|
||||
if let Some(ph) = app.session.catalog.photo(id) {
|
||||
let m = &ph.meta;
|
||||
let items = [
|
||||
m.iso.map(|i| format!("ISO {i}")).unwrap_or_default(),
|
||||
m.focal_mm.map(|f| format!("{f:.0}mm")).unwrap_or_default(),
|
||||
m.aperture.map(|a| format!("f/{a:.1}")).unwrap_or_default(),
|
||||
m.shutter.clone(),
|
||||
];
|
||||
let y = r.bottom() - 13.0;
|
||||
for (i, s) in items.iter().enumerate() {
|
||||
let x = r.left() + 18.0 + (r.width() - 36.0) * i as f32 / 3.0;
|
||||
let align = match i {
|
||||
0 => Align2::LEFT_CENTER,
|
||||
3 => Align2::RIGHT_CENTER,
|
||||
_ => Align2::CENTER_CENTER,
|
||||
};
|
||||
p.text(pos2(x, y), align, s, t.font(12.5), t.text_label);
|
||||
let items: Vec<String> = [
|
||||
m.iso.map(|i| format!("ISO {i}")),
|
||||
m.focal_mm.map(|f| format!("{f:.0}mm")),
|
||||
m.aperture.map(|a| format!("f/{a:.1}")),
|
||||
if m.shutter.is_empty() { None } else { Some(m.shutter.clone()) },
|
||||
]
|
||||
.into_iter()
|
||||
.flatten()
|
||||
.collect();
|
||||
|
||||
if !items.is_empty() {
|
||||
let y = r.bottom() - 13.0;
|
||||
let count = items.len() as f32;
|
||||
for (i, s) in items.iter().enumerate() {
|
||||
let x = r.left() + 18.0 + (r.width() - 36.0) * (i as f32 + 0.5) / count;
|
||||
let align = match i {
|
||||
0 => Align2::LEFT_CENTER,
|
||||
_ if i == items.len() - 1 => Align2::RIGHT_CENTER,
|
||||
_ => Align2::CENTER_CENTER,
|
||||
};
|
||||
p.text(pos2(x, y), align, s, t.font(12.5), t.text_label);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user