mirror of
https://github.com/storytold/lightcraft.git
synced 2026-10-29 20:48:33 -06:00
Merge batch 30 fixes
This commit is contained in:
@@ -64,7 +64,10 @@ struct Partial {
|
||||
target: PathBuf,
|
||||
}
|
||||
fn partial(style: SidecarNaming, upper_stem: bool, upper_full: bool, shared: bool) -> Partial {
|
||||
let dir = crate::tests_xmp::temp_dir("sidecar-provenance");
|
||||
// one folder per fixture: tests run in parallel, and each removes its folder at the end
|
||||
static NEXT: std::sync::atomic::AtomicUsize = std::sync::atomic::AtomicUsize::new(0);
|
||||
let n = NEXT.fetch_add(1, std::sync::atomic::Ordering::Relaxed);
|
||||
let dir = crate::tests_xmp::temp_dir(&format!("sidecar-provenance-{n}"));
|
||||
let a = dir.join("a.jpg");
|
||||
let b = dir.join("Trip.jpg");
|
||||
std::fs::write(&a, b"tiny physical photo; rename does not decode").unwrap();
|
||||
|
||||
@@ -308,6 +308,10 @@ fn keyboard_owned(app: &LightcraftApp, ctx: &egui::Context) -> bool {
|
||||
return ctx.input(|input| input.key_pressed(Key::Escape))
|
||||
&& app.widgets.iter().any(|(widget, _)| widget.starts_with("sliderField:") && crate::text_field::was_editing(ctx, widget));
|
||||
}
|
||||
// a selected slider keeps its arrow keys; everything else is a shortcut
|
||||
if crate::widgets::slider_has_focus(ctx) {
|
||||
return ctx.input(|input| [Key::ArrowLeft, Key::ArrowRight, Key::ArrowUp, Key::ArrowDown].iter().any(|key| input.key_pressed(*key)));
|
||||
}
|
||||
let chrome = app
|
||||
.ui
|
||||
.docking
|
||||
|
||||
@@ -93,9 +93,10 @@ fn export_dialog_is_unchanged_in_a_tall_window() {
|
||||
let h = export_dialog([1600.0, 1000.0]);
|
||||
assert_fits(&h, "Export at 1600×1000");
|
||||
let dialog = rect(&h, "dialog:window");
|
||||
// (846 × 500.6 before #781: the whole dialog, nothing scrolled away)
|
||||
// (846 tall as before #781: the whole dialog, nothing scrolled away; 546 wide since the
|
||||
// watermark's nine positions, #833)
|
||||
assert!((dialog.height() - 846.0).abs() <= 1.0, "{dialog:?}");
|
||||
assert!((dialog.width() - 500.6).abs() <= 1.0, "{dialog:?}");
|
||||
assert!((dialog.width() - 546.0).abs() <= 1.0, "{dialog:?}");
|
||||
}
|
||||
|
||||
// Scenario: other long dialogs fit a short window too, with their buttons on screen
|
||||
|
||||
@@ -1337,6 +1337,9 @@ fn color_range_pick_button_samples_the_photo() {
|
||||
#[test]
|
||||
fn a_selected_develop_slider_accepts_wheel_nudges() {
|
||||
let mut h = detail("panel.edit");
|
||||
// the demo may open on the Edit panel already, which `panel.edit` then toggles shut
|
||||
let r = h.request("ui.set", json!({"right": "edit"}), T);
|
||||
assert_eq!(r["ok"], true, "{r}");
|
||||
h.settle(SETTLE);
|
||||
let name = "slider:light.exposure";
|
||||
let panel = h.app.widgets.iter().find(|(id, _)| id == "panel:right_panel").unwrap().1;
|
||||
|
||||
@@ -187,6 +187,7 @@ pub fn slider(ui: &mut Ui, spec: &ControlSpec, value: f64, enabled: bool, label_
|
||||
// opt-in so hovering an unfocused slider still scrolls the containing panel.
|
||||
if enabled && (resp.clicked() || resp.drag_started()) {
|
||||
resp.request_focus();
|
||||
ui.data_mut(|d| d.insert_temp(focused_slider_key(), id));
|
||||
}
|
||||
// screen readers: a slider named after its control, with its value
|
||||
let label_text = crate::i18n::tr(label_override.unwrap_or(spec.label)).to_string();
|
||||
@@ -726,3 +727,14 @@ pub(crate) fn elide_head(text: &str, max: f32, width: impl Fn(&str) -> f32) -> S
|
||||
#[cfg(test)]
|
||||
#[path = "widgets/tests_numeric_entry.rs"]
|
||||
mod numeric_entry_tests;
|
||||
|
||||
fn focused_slider_key() -> egui::Id {
|
||||
egui::Id::new("lightcraft-focused-slider")
|
||||
}
|
||||
|
||||
/// Whether the widget with keyboard focus is a develop slider a click selected. It owns only the
|
||||
/// arrow keys (and the wheel): every other shortcut still works, as in Lightroom after a drag.
|
||||
pub fn slider_has_focus(ctx: &egui::Context) -> bool {
|
||||
let focused = ctx.memory(|m| m.focused());
|
||||
focused.is_some() && focused == ctx.data(|d| d.get_temp::<egui::Id>(focused_slider_key()))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user