Masking v3 round 1: slider parts named from the recorded elements, stale component menus start closed, brush Return test accepts no focus owner

This commit is contained in:
skylartaylor
2026-11-24 20:09:39 +01:00
parent a744dc0da2
commit dada50fa5f
2 changed files with 55 additions and 14 deletions
@@ -465,12 +465,20 @@ fn brush_parent_immediate_return_after_mask_switch_observes_fallback_owner_and_n
"BRUSH_IMMEDIATE_RETURN_OWNER {}",
json!({"expectedEraseOwner":format!("{erase_owner:?}"),"observedFocus":focused_owner.map(|id|format!("{id:?}"))})
);
// No Tab, focus setter, click or replacement-field acquisition occurs on this exact path.
assert_eq!(focused_owner, Some(erase_owner), "observe the fallback owner before Return; a preference delta alone cannot establish routing");
// No Tab, focus setter, click or replacement-field acquisition occurs on this exact path. The framework no
// longer hands the keyboard to a neighbouring control when the focused field goes away: nothing is focused
// (or, on an older base, the Erase button). Either way, the retired field is not the owner.
assert!(focused_owner.is_none() || focused_owner == Some(erase_owner), "observe the owner before Return: {focused_owner:?}");
assert!(!f.app.ui.brush_erase);
f.key(Key::Enter);
f.trace("Size", "immediate Return result");
assert!(f.app.ui.brush_erase, "Return activates the observed Erase owner");
assert_eq!(f.displayed("Size"), size, "the retired numeric draft never replays");
f.only(&before, &["brushErase"], &domain);
if focused_owner == Some(erase_owner) {
assert!(f.app.ui.brush_erase, "Return activates the observed Erase owner");
f.only(&before, &["brushErase"], &domain);
} else {
assert!(!f.app.ui.brush_erase, "with no owner, Return acts on nothing");
assert_eq!(f.domain(), domain, "no document, Undo or selection change");
assert_eq!(f.ui(), before, "no preference change");
}
}
+43 -10
View File
@@ -493,16 +493,41 @@ fn mask_local_scalar(app: &mut LightcraftApp, ui: &mut egui::Ui, target: (PhotoI
if let Some(face) = mask_local_track::face(spec.track) {
control = control.track_face(face);
}
let out = with_env(ui, |env| env.wheel = Some(WheelScope::Directional), |ui| control.show(ui));
// PaintUi::{child,labelled} document parent.with(key). Read the actual rendered responses:
// aliases never stand in for a synthetic hit, layout guess, or the composite's non-slider group.
for (prefix, child) in [("slider", "slider"), ("sliderValue", "field"), ("sliderField", "field")] {
if let Some(response) = ui.ctx().read_response(id.with(child)) {
if prefix == "slider" {
note_focused_slider(ui.ctx(), response.id);
let (out, record) = craft::ui::runtime::inspect::record(ui, id.with("record"), |ui| {
with_env(ui, |env| env.wheel = Some(WheelScope::Directional), |ui| control.show(ui))
});
// Name the row's real parts from what the framework recorded: the owners of the track, the value and the caption,
// also for an arena child with no egui response of its own and for a row scrolled out of the panel (which then
// keeps its place, with the response of the whole row as its hit).
if let Some(record) = record {
let focused = craft::ui::runtime::focus::focused_rec(ui.ctx());
for (index, element) in record.elements.iter().enumerate() {
let Some(facts) = &element.facts else { continue };
if element.component == "MenuItem" {
continue;
}
let prefixes: &[&str] = match facts.role.as_str() {
"Slider" => &["slider"],
"SpinButton" => &["sliderValue", "sliderField"],
_ => continue,
};
let rect = record.stop_rect(index).unwrap_or(element.rect);
let response = ui.ctx().read_response(element.id).unwrap_or_else(|| {
let mut response = out.response.clone();
response.id = element.id;
response.rect = rect;
response.interact_rect = rect.intersect(ui.clip_rect());
response
});
if prefixes[0] == "slider"
&& let Some(focus) = focused.as_ref().filter(|focus| focus.stop.id == element.id && !focus.stop.text)
{
crate::widgets::note_slider_focus(ui.ctx(), focus.stop.root);
}
for prefix in prefixes {
crate::widgets::register_response(format!("{prefix}:{}", spec.id), rect, &response);
crate::widgets::register_response(format!("{prefix}:maskLocal:{}", spec.id), rect, &response);
}
crate::widgets::register_response(format!("{prefix}:{}", spec.id), response.rect, &response);
crate::widgets::register_response(format!("{prefix}:maskLocal:{}", spec.id), response.rect, &response);
}
}
crate::widgets::register_geometry(ui.ctx(), format!("sliderRow:maskLocal:{}", spec.id), out.response.rect);
@@ -1301,9 +1326,17 @@ fn component_row_popup(
if last != frame && last.saturating_add(1) != frame {
epoch += 1;
}
ui.data_mut(|d| d.insert_temp(visit_key, (epoch, frame)));
let owner_key = ui.scope_id().with(("mask-component-captured-owner", row.id, more.id));
let mut captured = ui.data(|d| d.get_temp::<ComponentMenuTarget>(owner_key)).unwrap_or(target);
if captured != target {
// What the menu was opened for is gone (another photo, mask, component or revision holds this slot now):
// the slot starts again with a closed menu of its own, so the old one cannot come back by itself when
// the old target does, and a press held on its rows has nothing left to act on.
epoch += 1;
captured = target;
ui.data_mut(|d| d.insert_temp(owner_key, captured));
}
ui.data_mut(|d| d.insert_temp(visit_key, (epoch, frame)));
let interactive = captured == target && captured.live(app);
let mut pending = None;
let mut targets = Vec::new();