Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion crates/ui-egui/src/libtools.rs
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,18 @@ fn value_editor(app: &mut LccApp, ui: &mut egui::Ui, painter: &Painter, next: &m
choose(ui, items);
}
}
PaintKind::Settings => choose(ui, app.session.presets.iter().map(|m| (m.id.clone(), m.name.clone())).collect()),
PaintKind::Settings => {
// only the rows in view are built (thousands of presets made every frame slow)
let presets = &app.session.presets;
let current = presets.iter().find(|m| m.id == painter.value).map(|m| m.name.clone()).unwrap_or_else(|| painter.value.clone());
let r = egui::ComboBox::from_id_salt("painter-value")
.selected_text(current)
.show_ui(ui, |ui| crate::panels::presets::picker_rows(ui, "painter-value", presets, Some(&painter.value)));
crate::widgets::register(ui.ctx(), "painter:value", r.response.rect);
if let Some(Some(id)) = r.inner {
*next = Some((kind, id));
}
}
PaintKind::Rotation => choose(
ui,
[("left", "Rotate Left"), ("right", "Rotate Right"), ("flipHorizontal", "Flip Horizontal"), ("flipVertical", "Flip Vertical")]
Expand Down
3 changes: 2 additions & 1 deletion crates/ui-egui/src/panels/presets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ impl AppliedPreset {
&& session
.undo
.last()
.is_some_and(|entry| session.presets.iter().any(|preset| preset.id == self.id && entry.label == format!("Preset: {}", preset.name)))
.and_then(|entry| entry.label.strip_prefix("Preset: "))
.is_some_and(|name| session.presets.iter().any(|preset| preset.id == self.id && preset.name == name))
}
}

Expand Down
13 changes: 3 additions & 10 deletions crates/ui-egui/src/panels/quick_develop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,10 @@ pub fn show(app: &mut LccApp, ui: &mut egui::Ui) {
}
ui.label(egui::RichText::new(crate::i18n::tr_format!("{n} selected", n = n)).size(11.5).color(t.text_dim));
// Saved Preset
let presets: Vec<(String, String)> = app.session.presets.iter().map(|p| (p.id.clone(), p.name.clone())).collect();
// Only the rows in view are built: a collection imported whole is thousands of presets.
let presets = &app.session.presets;
if let Some(p) = choice_row(ui, "qd-preset", "Saved Preset", "Choose…", |ui| {
let mut pick = None;
egui::ScrollArea::vertical().max_height(320.0).show(ui, |ui| {
for (id, name) in &presets {
if ui.button(name).clicked() {
pick = Some(id.clone());
}
}
});
pick.map(|id| json!({"preset": id}))
crate::panels::presets::picker_rows(ui, "qd-preset", presets, None).map(|id| json!({"preset": id}))
}) {
quick_set(app, ui, p);
}
Expand Down
13 changes: 7 additions & 6 deletions crates/ui-egui/src/panels/tether_bar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -361,16 +361,17 @@ fn settings_window(app: &mut LccApp, ctx: &egui::Context) {
crate::access::label(&r, "Keywords");
ui.end_row();
ui.label(crate::i18n::tr("Develop preset"));
let presets: Vec<(String, String)> = app.session.presets.iter().map(|p| (p.id.clone(), p.name.clone())).collect();
let shown = presets
let shown = app
.session
.presets
.iter()
.find(|(id, _)| *id == form.preset)
.map(|(_, n)| n.clone())
.find(|p| p.id == form.preset)
.map(|p| p.name.clone())
.unwrap_or_else(|| crate::i18n::tr("None").to_string());
egui::ComboBox::from_id_salt("tether-preset").selected_text(shown).width(260.0).show_ui(ui, |ui| {
ui.selectable_value(&mut form.preset, String::new(), crate::i18n::tr("None"));
for (id, name) in &presets {
ui.selectable_value(&mut form.preset, id.clone(), name);
if let Some(id) = crate::panels::presets::picker_rows(ui, "tether-preset", &app.session.presets, Some(&form.preset)) {
form.preset = id;
}
});
ui.end_row();
Expand Down
28 changes: 28 additions & 0 deletions crates/ui-egui/src/tests_classic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -356,3 +356,31 @@ fn the_tool_strip_is_develops_alone() {
click(&mut h, "module:develop");
assert!(has(&h, "icon:edit") && has(&h, "icon:crop") && has(&h, "icon:presets"), "the strip is Develop's");
}

/// Issue #36: with a preset collection imported whole (thousands of presets), Quick Develop's
/// Saved Preset menu builds only the rows in view; building one button per preset every frame
/// made Library sluggish while it was open. Picking a preset still applies it.
#[test]
fn quick_develop_preset_menu_builds_only_visible_rows() {
let mut h = demo();
let many = (0..5000)
.map(|i| lcc_develop::Preset {
id: format!("user.big.{i}"),
name: format!("Look {i}"),
group: format!("Big {:02}", i / 500),
settings: json!({"light": {"exposure": 1.0}}),
favorite: false,
builtin: false,
})
.collect();
assert_eq!(h.app.session.add_presets(many).len(), 5000);
let id = h.app.session.visible_cloned()[0];
run(&mut h, "library.select", json!({"ids": [id.0]}));
let widgets = |h: &Headless| h.view.ctx.viewport(|v| v.prev_pass.widgets.layers().map(|(_, w)| w.len()).sum::<usize>());
h.step();
let closed = widgets(&h);
click(&mut h, "button:qd-preset");
h.step();
let open = widgets(&h);
assert!(open > closed + 5 && open < closed + 200, "the open menu built {} widgets", open.saturating_sub(closed));
}
2 changes: 2 additions & 0 deletions docs/changelog/0.8.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@
- The preset Amount slider fades the preset gradually down to 0 %: curves blend point by point, and the profile, treatment and switches take the preset's at any amount above 0 instead of snapping back at 50 %. (#37) (no PR)
- `cargo test -p lcc-ui-egui` runs the model-setup tests on its own: the crate's tests enable the engine's denoise
feature instead of relying on the app or CLI to turn it on. (no PR)
- Large preset collections (#36): Quick Develop's Saved Preset menu, the tether bar's preset list and the painter's
Settings list build only the rows in view (10 000 presets: 16 ms → 0.8 ms a frame with the menu open). (no PR)
Loading