Fix batch 10 fixture modifiers and rail icons

This commit is contained in:
Dylan M. Taylor
2026-11-20 07:59:08 -05:00
parent a1742ab01e
commit d7e4db7804
5 changed files with 25 additions and 11 deletions
+1 -1
View File
@@ -205,7 +205,7 @@ impl Rig {
fn click(&mut self, at: Pos2) {
self.fixture.frame(vec![pointer::moved(at)]);
self.fixture.frame(vec![pointer::press(at)]);
self.fixture.frame_held(vec![pointer::press(at)]);
self.fixture.frame(vec![pointer::release(at)]);
self.fixture.frame(Vec::new());
}
+11 -7
View File
@@ -723,7 +723,7 @@ fn a_held_command_or_alt_runs_its_stand_in_for_one_gesture() {
let at = rig.centre();
// Command at the press, up mid-drag: the stand-in keeps the gesture to the release.
rig.fixture.hold(Modifiers::COMMAND).frame(vec![pointer::press(at)]).frame(vec![pointer::moved(at + BY)]);
rig.fixture.hold(Modifiers::COMMAND).frame_held(vec![pointer::press(at)]).frame(vec![pointer::moved(at + BY)]);
rig.fixture.hold(Modifiers::NONE).frame(vec![pointer::moved(at + BY * 2.0)]).frame(vec![pointer::release(at + BY * 2.0)]);
let calls = rig.calls();
assert_eq!(calls.first().map(String::as_str), Some("command press"), "{calls:?}");
@@ -758,7 +758,11 @@ fn a_held_command_or_alt_runs_its_stand_in_for_one_gesture() {
main.ignores = Some(StandInKey::Command);
let mut rig = Rig::new(main, &log, None);
let at = rig.centre();
rig.fixture.hold(Modifiers::COMMAND).frame(vec![pointer::press(at)]).frame(vec![pointer::moved(at + BY)]).frame(vec![pointer::release(at + BY)]);
rig.fixture
.hold(Modifiers::COMMAND)
.frame_held(vec![pointer::press(at)])
.frame(vec![pointer::moved(at + BY)])
.frame(vec![pointer::release(at + BY)]);
let calls = rig.calls();
assert_eq!(&calls[..2], ["main press", "command press"], "{calls:?}");
assert_eq!(calls.last().map(String::as_str), Some("command release"), "{calls:?}");
@@ -769,7 +773,7 @@ fn a_held_command_or_alt_runs_its_stand_in_for_one_gesture() {
main.refuses = Some(StandInKey::Alt);
let mut rig = Rig::new(main, &log, None);
let at = rig.centre();
rig.fixture.hold(Modifiers::ALT).frame(vec![pointer::press(at)]).frame(vec![pointer::release(at)]);
rig.fixture.hold(Modifiers::ALT).frame_held(vec![pointer::press(at)]).frame(vec![pointer::release(at)]);
assert_eq!(rig.calls().first().map(String::as_str), Some("alt press"), "{:?}", rig.calls());
// The hover cursor is the stand-in's while its key is held, no gesture runs and the selected tool does not take
@@ -791,7 +795,7 @@ fn a_held_command_or_alt_runs_its_stand_in_for_one_gesture() {
let mut rig = Rig::with(main, &log, None, Setup { momentary: Some(Momentary::new(NavigationOptions::default())), ..Setup::default() });
let at = rig.centre();
rig.fixture.hold(Modifiers::COMMAND).frame(vec![pointer::moved(at), key_press(Key::Space, Modifiers::COMMAND)]);
rig.fixture.frame(vec![pointer::press(at)]).frame(vec![pointer::moved(at + BY)]).frame(vec![pointer::release(at + BY)]);
rig.fixture.frame_held(vec![pointer::press(at)]).frame(vec![pointer::moved(at + BY)]).frame(vec![pointer::release(at + BY)]);
assert!(rig.calls().is_empty(), "neither the selected tool nor a stand-in sees a press under a momentary tool: {:?}", rig.calls());
// With the Hand selected, Cmd at a press is Zoom In, not the Command stand-in.
@@ -802,7 +806,7 @@ fn a_held_command_or_alt_runs_its_stand_in_for_one_gesture() {
momentary.hand_selected(true);
let mut rig = Rig::with(main, &log, None, Setup { momentary: Some(momentary), ..Setup::default() });
let at = rig.centre();
rig.fixture.hold(Modifiers::COMMAND).frame(vec![pointer::moved(at)]).frame(vec![pointer::press(at)]).frame(vec![pointer::release(at)]);
rig.fixture.hold(Modifiers::COMMAND).frame(vec![pointer::moved(at)]).frame_held(vec![pointer::press(at)]).frame(vec![pointer::release(at)]);
assert!(!rig.calls().iter().any(|call| call == "command press"), "Cmd over the selected Hand is Zoom In: {:?}", rig.calls());
}
@@ -815,7 +819,7 @@ fn a_gesture_a_stand_in_holds_is_cancelled_on_the_stand_in() {
main.refuses = Some(StandInKey::Command);
let mut rig = Rig::new(main, &log, None);
let at = rig.centre();
rig.fixture.hold(Modifiers::COMMAND).frame(vec![pointer::press(at)]).frame(vec![pointer::moved(at + BY)]);
rig.fixture.hold(Modifiers::COMMAND).frame_held(vec![pointer::press(at)]).frame(vec![pointer::moved(at + BY)]);
rig.log.borrow_mut().clear();
let (ctx, canvas) = (rig.fixture.ctx().clone(), rig.canvas.get());
let cancelled = {
@@ -1359,7 +1363,7 @@ fn a_secondary_click_the_tool_did_not_take_asks_for_the_menu() {
let log = Log::default();
let mut rig = Rig::new(Probe::new("main", &log), &log, None);
let at = rig.centre();
rig.fixture.hold(Modifiers::SHIFT).frame(vec![pointer::secondary(at, true)]);
rig.fixture.hold(Modifiers::SHIFT).frame_held(vec![pointer::secondary(at, true)]);
rig.fixture.hold(Modifiers::NONE).frame(vec![pointer::secondary(at, false)]);
let asked = rig.contexts.borrow().clone();
assert_eq!(asked.len(), 1, "{asked:?}");
+1 -1
View File
@@ -86,7 +86,7 @@ impl Rig {
/// Hovers and presses at `at` in separate frames.
fn press(&mut self, at: Pos2) {
self.tick(FRAME, vec![pointer::moved(at)]);
self.tick(FRAME, vec![pointer::press(at)]);
self.fixture.frame_held(vec![pointer::press(at)]);
}
/// Moves from `from` to `to` in `steps` frames of `dt` seconds.
+10
View File
@@ -432,6 +432,16 @@ impl Fixture {
self
}
/// One frame whose pointer button events carry the modifiers held by the fixture.
pub fn frame_held(&mut self, mut events: Vec<Event>) -> &mut Self {
for event in &mut events {
if let Event::PointerButton { modifiers, .. } = event {
*modifiers = self.frames.held();
}
}
self.frame(events)
}
/// One frame with no events; returns the shapes it painted, nested shapes flattened.
pub fn frame_shapes(&mut self) -> Vec<egui::Shape> {
self.frames.record_paint();
@@ -71,8 +71,8 @@ impl DockPanels<usize> for Demo {
}
fn rail_footer(&mut self, _: &usize, ui: &mut Ui, _: &mut BodyCx<'_>) {
IconButton::new(IconId::new("chevron-up")).label("Previous").show(ui);
IconButton::new(IconId::new("chevron-down")).label("Next").show(ui);
IconButton::new(IconId::new("chevron_up")).label("Previous").show(ui);
IconButton::new(IconId::new("chevron_down")).label("Next").show(ui);
}
fn panel_rows(&mut self, panel: &usize) -> Vec<PanelRow> {