Skip to content

Commit e795e79

Browse files
authored
Merge pull request #418 from emmertex/fix/develop-panel-stays-put
Develop panel rows no longer jump during edits, crop and AI Denoise
2 parents ddd2b62 + aa04923 commit e795e79

7 files changed

Lines changed: 73 additions & 28 deletions

File tree

‎crates/engine/src/media.rs‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,19 @@ pub struct MediaCache {
509509
pub rendered: Arc<PreviewCache>,
510510
/// Which photos have a cached denoised picture, and how to read it.
511511
pub denoise: DenoiseIndex,
512+
/// What decodes have shown about each photo's file that the Edit panel offers options for (see
513+
/// [`ProfileFacts`]): kept when the decoded sources go, so those rows do not vanish while a source is decoded
514+
/// again or evicted, which would move every control under them.
515+
profile_facts: HashMap<PhotoId, ProfileFacts>,
516+
}
517+
518+
/// File facts that decide whether the Edit panel's Profile section shows an option: a camera model with measured
519+
/// colour (Calibrated camera colour) and a raw carrying its own local tone mapping. They belong to the file, not to
520+
/// a decode, so once any decode has seen one it stays until the photo's sources are forgotten.
521+
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
522+
pub struct ProfileFacts {
523+
pub colorimetric: bool,
524+
pub local_tone: bool,
512525
}
513526

514527
/// The photos that have a cached denoised picture for the denoise model in use. Only memory: nothing here touches the
@@ -580,6 +593,7 @@ impl Default for MediaCache {
580593
scenes: Vec::new(),
581594
rendered: Arc::new(PreviewCache::memory(rendered_budget(budget))),
582595
denoise: DenoiseIndex::default(),
596+
profile_facts: HashMap::new(),
583597
}
584598
}
585599
}
@@ -614,6 +628,7 @@ impl MediaCache {
614628
self.thumbs = Lru::new(THUMB_SOURCE_BYTES.min(self.budget));
615629
self.previews.clear();
616630
self.full.clear();
631+
self.profile_facts.clear();
617632
}
618633

619634
/// How many full-resolution originals to keep at once (at least one). Compare and Reference
@@ -732,6 +747,11 @@ impl MediaCache {
732747
}
733748

734749
fn insert_source(&mut self, id: PhotoId, level: SourceLevel, img: DecodedSource) {
750+
if let Some(info) = &img.info {
751+
let f = self.profile_facts.entry(id).or_default();
752+
f.colorimetric |= info.colorimetric;
753+
f.local_tone |= info.local_tone.is_some();
754+
}
735755
let tick = lcc_preview::next_tick();
736756
match level {
737757
SourceLevel::Thumb => {
@@ -761,6 +781,14 @@ impl MediaCache {
761781
self.thumbs.remove(&id);
762782
self.previews.retain(|e| e.0 != id);
763783
self.full.retain(|e| e.0 != id);
784+
self.profile_facts.remove(&id);
785+
}
786+
787+
/// What decodes of `id` have shown so far, with what the cached sources say now (see [`ProfileFacts`]).
788+
pub fn profile_facts(&self, id: PhotoId) -> ProfileFacts {
789+
let now = self.source_facts(id, SourceInfo::default());
790+
let seen = self.profile_facts.get(&id).copied().unwrap_or_default();
791+
ProfileFacts { colorimetric: seen.colorimetric || now.colorimetric, local_tone: seen.local_tone || now.local_tone.is_some() }
764792
}
765793

766794
/// (decoded thumbnail sources, bytes).

‎crates/ui-egui/src/panels/denoise.rs‎

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -180,13 +180,15 @@ pub fn detail_status(app: &mut LccApp, ui: &mut egui::Ui, id: PhotoId, amount: f
180180
}
181181
});
182182
}
183+
// Waiting, in line and being made are passing states of background work: they add no line here (it would
184+
// push every control under it down and back up while the user drags a slider); the activity stack shows the
185+
// progress, with the photo's file name.
183186
PhotoState::Idle => {
184187
if amount > 0.0 && app.session.denoise_auto() {
185188
// the pump has not met this photo yet: let it come round soon instead of waiting out its pause
186189
let now = ui.ctx().input(|i| i.time);
187190
app.caches.denoise.next_pump = app.caches.denoise.next_pump.min(now + 0.05);
188191
ui.ctx().request_repaint_after(std::time::Duration::from_millis(60));
189-
egui::Frame::NONE.inner_margin(pad).show(ui, |ui| note(ui, "Waiting to start…", t.text_dim));
190192
} else if amount > 0.0 {
191193
egui::Frame::NONE.inner_margin(pad).show(ui, |ui| {
192194
note(ui, "Its denoised picture is not made yet, and pictures are not made on their own (Settings, AI Denoise).", t.text_dim);
@@ -199,28 +201,7 @@ pub fn detail_status(app: &mut LccApp, ui: &mut egui::Ui, id: PhotoId, amount: f
199201
});
200202
}
201203
}
202-
PhotoState::Queued { ahead } => {
203-
egui::Frame::NONE.inner_margin(pad).show(ui, |ui| {
204-
let text = if ahead == 0 {
205-
tr("Next up for AI Denoise…").to_string()
206-
} else {
207-
tr_format!("In line for AI Denoise ({ahead} ahead)…", ahead = ahead)
208-
};
209-
note(ui, &text, t.text_dim);
210-
});
211-
}
212-
PhotoState::Running { done, total } => {
213-
egui::Frame::NONE.inner_margin(pad).show(ui, |ui| {
214-
let frac = if total > 0 { (done as f32 / total as f32).clamp(0.0, 1.0) } else { 0.0 };
215-
let text = if total > 0 {
216-
tr_format!("Making the denoised picture… {}%", (frac * 100.0).round() as u32)
217-
} else {
218-
tr("Starting…").to_string()
219-
};
220-
let bar = ui.add(egui::ProgressBar::new(frac).desired_width(ui.available_width().min(240.0)).text(RichText::new(text).size(11.0)));
221-
register(ui.ctx(), "denoise:progress", bar.rect);
222-
});
223-
}
204+
PhotoState::Queued { .. } | PhotoState::Running { .. } => {}
224205
PhotoState::Failed { why, unsupported } => {
225206
egui::Frame::NONE.inner_margin(pad).show(ui, |ui| {
226207
let color = if unsupported { t.text_dim } else { t.caution };

‎crates/ui-egui/src/panels/edit.rs‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,9 +202,12 @@ pub fn show_controls(app: &mut LccApp, ui: &mut egui::Ui, id: PhotoId) {
202202
control(app, ui, &d, "profile.amount", true);
203203
ui.add_space(6.0);
204204
}
205+
// whether to offer the two file options below: facts of the file that stay put while sources are decoded again
206+
// (an edit, crop mode), so the rows under them never move
207+
let facts = app.session.media.profile_facts(id);
205208
// a raw carrying its own local tone mapping (Apple ProRAW's gain table map): off renders it as
206209
// Lightroom Classic does, on as the camera does
207-
if app.session.source_info(id).local_tone.is_some() {
210+
if facts.local_tone {
208211
egui::Frame::NONE.inner_margin(egui::Margin { left: 12, right: 16, top: 0, bottom: 10 }).show(ui, |ui| {
209212
let mut on = d.profile.camera_local_tone;
210213
let r = ui.checkbox(&mut on, crate::i18n::tr("Camera local tone mapping"));
@@ -216,7 +219,7 @@ pub fn show_controls(app: &mut LccApp, ui: &mut egui::Ui, id: PhotoId) {
216219
}
217220
// a raw without colour matrices whose camera model has measured ones: off starts from the look fitted to the
218221
// camera's JPEG (Auto), on from the measured colour with the app's own tone curve (Colorimetric)
219-
if app.session.source_info(id).colorimetric {
222+
if facts.colorimetric {
220223
egui::Frame::NONE.inner_margin(egui::Margin { left: 12, right: 16, top: 0, bottom: 10 }).show(ui, |ui| {
221224
let mut on = d.profile.camera_colour == lcc_develop::CameraColour::Colorimetric;
222225
let r = ui.checkbox(&mut on, crate::i18n::tr("Calibrated camera colour"));

‎crates/ui-egui/src/panels/masking.rs‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,14 @@ pub fn show(app: &mut LccApp, ui: &mut egui::Ui, id: PhotoId) {
189189
} else {
190190
None
191191
};
192+
// one line kept for the status whether or not there is one: the AI masks' background work must not move the
193+
// controls under it (one line, cut short when narrow, so it never grows either)
194+
ui.add_space(4.0);
195+
let line = ui.text_style_height(&egui::TextStyle::Body);
196+
let (rect, _) = ui.allocate_exact_size(egui::vec2(ui.available_width(), line), egui::Sense::hover());
192197
if let Some(status) = status {
193-
ui.add_space(4.0);
194-
ui.add(egui::Label::new(egui::RichText::new(crate::i18n::tr(status)).color(t.text_dim)).wrap());
198+
let label = egui::Label::new(egui::RichText::new(crate::i18n::tr(status)).color(t.text_dim)).truncate();
199+
ui.put(rect, label);
195200
ui.ctx().request_repaint_after(std::time::Duration::from_millis(250));
196201
}
197202
// the model download, while its dialog is closed

‎crates/ui-egui/src/tests_camera_colour.rs‎

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use std::time::Duration;
77

88
use lcc_catalog::{Op, Photo, PhotoId, Source};
99
use lcc_develop::CameraColour;
10-
use lcc_engine::media::{FileLoader, LoadOptions};
10+
use lcc_engine::media::{FileLoader, LoadOptions, SourceLevel};
1111
use lcc_pipeline::SourceInfo;
1212
use serde_json::json;
1313

@@ -74,3 +74,24 @@ fn calibrated_camera_colour_is_not_offered_without_measured_colour() {
7474
let (h, _) = edit_panel(false);
7575
assert!(!shown(&h));
7676
}
77+
78+
fn rect_of(h: &Headless, id: &str) -> Option<egui::Rect> {
79+
h.app.widgets.iter().find(|(w, _)| w == id).map(|(_, r)| *r)
80+
}
81+
82+
#[test]
83+
fn calibrated_camera_colour_stays_while_the_photo_is_decoded_again() {
84+
// the row used to follow the cached decodes: a source decoded again (an edit, crop mode) or one without the
85+
// decoder's facts hid it for a frame or more, and every control under it, the slider being dragged among them,
86+
// jumped up and back
87+
let (mut h, _) = edit_panel(true);
88+
assert!(shown(&h));
89+
let below = rect_of(&h, "slider:light.exposure").expect("the Exposure slider");
90+
let plain = Arc::new(lcc_raster::Rgb32f::new(48, 32));
91+
for level in [SourceLevel::Thumb, SourceLevel::Preview, SourceLevel::Full] {
92+
h.app.session.media.insert(PhotoId(1), level, plain.clone());
93+
}
94+
h.step();
95+
assert!(shown(&h), "still offered while the decodes carry no facts");
96+
assert_eq!(rect_of(&h, "slider:light.exposure"), Some(below), "the controls under it stay put");
97+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## Fixes
2+
3+
- **Develop panel no longer jumps:** the Calibrated camera colour and Camera local tone mapping options stay shown while a photo is decoded again (an edit, crop mode), AI Denoise progress moved to the activity stack, and the masking status line keeps its space, so controls under them never move under the pointer. (no PR)
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
### Develop panel stays put
2+
3+
- Editing a photo or entering crop mode no longer hides the Calibrated camera colour option for a moment, so the sliders under it stay under the pointer while you drag.
4+
- AI Denoise progress shows in the activity stack only; the Edit panel no longer adds a line while a denoised picture is made, and the masking status keeps one line, so the controls never move.

0 commit comments

Comments
 (0)