Skip to content

Commit a66c675

Browse files
committed
Update ui-events to 0.2.0.
1 parent bec6c62 commit a66c675

File tree

8 files changed

+337
-78
lines changed

8 files changed

+337
-78
lines changed

Cargo.lock

Lines changed: 303 additions & 49 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ ndk = "0.9.0"
1818
num_enum = "0.7.3"
1919
send_wrapper = "0.6.0"
2020
smallvec = "1.15.0"
21-
ui-events = "0.1.0"
21+
ui-events = { git = "https://github.com/endoli/ui-events", rev = "6382e63" }
2222

2323
[profile.dev]
2424
panic = "abort"

demo/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ log = "0.4.26"
1717
parley = { git = "https://github.com/linebender/parley", rev = "587b7634ae8601c10de7f0361bfd56085a5b7b4e", features = ["accesskit"] }
1818
peniko = { version = "0.4.0", default-features = false }
1919
pollster = "0.4.0"
20-
ui-events = "0.1.0"
20+
ui-events = { git = "https://github.com/endoli/ui-events", rev = "6382e63" }
2121
vello = "0.5.0"
2222

2323
# Send tracing events to Android GPU inspector, for profiling

demo/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ impl ViewPeer for DemoViewPeer {
371371
return false;
372372
};
373373

374-
if matches!(ev, PointerEvent::Up { .. }) {
374+
if matches!(ev, PointerEvent::Up(..)) {
375375
ctx.push_static_deferred_callback(show_soft_input);
376376
}
377377

demo/src/text.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use parley::{
1212
use std::time::{Duration, Instant};
1313
use ui_events::{
1414
keyboard::{Code, Key, KeyState, KeyboardEvent, NamedKey},
15-
pointer::{PointerButton, PointerEvent, PointerState, PointerUpdate},
15+
pointer::{PointerButton, PointerButtonEvent, PointerEvent, PointerState, PointerUpdate},
1616
};
1717
use vello::{
1818
Scene,
@@ -310,7 +310,7 @@ impl Editor {
310310
pub fn handle_pointer_event(&mut self, ev: PointerEvent) -> bool {
311311
let mut drv = self.editor.driver(&mut self.font_cx, &mut self.layout_cx);
312312
match ev {
313-
PointerEvent::Down {
313+
PointerEvent::Down(PointerButtonEvent {
314314
button: None | Some(PointerButton::Primary),
315315
state:
316316
PointerState {
@@ -320,7 +320,7 @@ impl Editor {
320320
..
321321
},
322322
..
323-
} => match count {
323+
}) => match count {
324324
2 => drv.select_word_at_point(position.x as f32 - INSET, position.y as f32 - INSET),
325325
3 => drv.select_line_at_point(position.x as f32 - INSET, position.y as f32 - INSET),
326326
1 if modifiers.shift() => drv.extend_selection_to_point(

masonry-demo/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ crate-type = ["cdylib"]
99

1010
[dependencies]
1111
android-view = { path = ".." }
12-
masonry = { git = "https://github.com/linebender/xilem" }
12+
masonry = { git = "https://github.com/xorgy/xilem", branch = "ui-events-0.2.0" }
1313
masonry_android = { path = "../masonry" }
1414

1515
# Send tracing events to Android GPU inspector, for profiling

masonry/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ edition = "2024"
66
[dependencies]
77
accesskit_android = "0.4.0"
88
android-view = { path = ".." }
9-
masonry_core = { git = "https://github.com/linebender/xilem" }
9+
masonry_core = { git = "https://github.com/xorgy/xilem", branch = "ui-events-0.2.0" }
1010
pollster = "0.4.0"
1111
tracing = "0.1.40"

src/events.rs

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ use num_enum::FromPrimitive;
1212
use ui_events::{
1313
ScrollDelta,
1414
keyboard::{KeyboardEvent, Modifiers},
15-
pointer::{ContactGeometry, PointerEvent, PointerId, PointerState, PointerUpdate},
15+
pointer::{
16+
ContactGeometry, PointerButtonEvent, PointerEvent, PointerId, PointerScrollEvent,
17+
PointerState, PointerUpdate,
18+
},
1619
};
1720

1821
use crate::ViewConfiguration;
@@ -467,16 +470,18 @@ impl<'local> MotionEvent<'local> {
467470
};
468471

469472
Some(match action {
470-
MotionAction::Down | MotionAction::PointerDown => PointerEvent::Down {
471-
pointer,
472-
state,
473-
button,
474-
},
475-
MotionAction::Up | MotionAction::PointerUp => PointerEvent::Up {
473+
MotionAction::Down | MotionAction::PointerDown => {
474+
PointerEvent::Down(PointerButtonEvent {
475+
pointer,
476+
state,
477+
button,
478+
})
479+
}
480+
MotionAction::Up | MotionAction::PointerUp => PointerEvent::Up(PointerButtonEvent {
476481
pointer,
477482
state,
478483
button,
479-
},
484+
}),
480485
MotionAction::Move | MotionAction::HoverMove => {
481486
let hsz = self.history_size(env);
482487
let mut coalesced: Vec<PointerState> = vec![state.clone(); hsz as usize];
@@ -527,7 +532,7 @@ impl<'local> MotionEvent<'local> {
527532
MotionAction::Cancel => PointerEvent::Cancel(pointer),
528533
MotionAction::HoverEnter => PointerEvent::Enter(pointer),
529534
MotionAction::HoverExit => PointerEvent::Leave(pointer),
530-
MotionAction::Scroll => PointerEvent::Scroll {
535+
MotionAction::Scroll => PointerEvent::Scroll(PointerScrollEvent {
531536
pointer,
532537
delta: ScrollDelta::PixelDelta(PhysicalPosition::<f64> {
533538
x: (self.axis(env, Axis::Hscroll, action_index)
@@ -536,7 +541,7 @@ impl<'local> MotionEvent<'local> {
536541
* vc.scaled_vertical_scroll_factor) as f64,
537542
}),
538543
state,
539-
},
544+
}),
540545
_ => {
541546
// Other current `MotionAction` values relate to gamepad/joystick buttons;
542547
// ui-events doesn't currently have types for these, so consider them unhandled.
@@ -620,11 +625,11 @@ impl TapCounter {
620625
///
621626
pub fn attach_count(&mut self, e: PointerEvent) -> PointerEvent {
622627
match e {
623-
PointerEvent::Down {
628+
PointerEvent::Down(PointerButtonEvent {
624629
button,
625630
pointer,
626631
state,
627-
} => {
632+
}) => {
628633
let e = if let Some(i) =
629634
self.taps.iter().position(|TapState { x, y, up_time, .. }| {
630635
let dx = (x - state.position.x).abs();
@@ -641,11 +646,11 @@ impl TapCounter {
641646
self.taps[i].x = state.position.x;
642647
self.taps[i].y = state.position.y;
643648

644-
PointerEvent::Down {
649+
PointerEvent::Down(PointerButtonEvent {
645650
button,
646651
pointer,
647652
state: PointerState { count, ..state },
648-
}
653+
})
649654
} else {
650655
let s = TapState {
651656
pointer_id: pointer.pointer_id,
@@ -656,34 +661,34 @@ impl TapCounter {
656661
y: state.position.y,
657662
};
658663
self.taps.push(s);
659-
PointerEvent::Down {
664+
PointerEvent::Down(PointerButtonEvent {
660665
button,
661666
pointer,
662667
state: PointerState { count: 1, ..state },
663-
}
668+
})
664669
};
665670
self.clear_expired(state.time);
666671
e
667672
}
668-
PointerEvent::Up {
673+
PointerEvent::Up(PointerButtonEvent {
669674
button,
670675
pointer,
671676
ref state,
672-
} => {
677+
}) => {
673678
if let Some(i) = self
674679
.taps
675680
.iter()
676681
.position(|TapState { pointer_id, .. }| *pointer_id == pointer.pointer_id)
677682
{
678683
self.taps[i].up_time = state.time;
679-
PointerEvent::Up {
684+
PointerEvent::Up(PointerButtonEvent {
680685
button,
681686
pointer,
682687
state: PointerState {
683688
count: self.taps[i].count,
684689
..state.clone()
685690
},
686-
}
691+
})
687692
} else {
688693
e.clone()
689694
}
@@ -735,7 +740,7 @@ impl TapCounter {
735740
.retain(|TapState { pointer_id, .. }| *pointer_id != p.pointer_id);
736741
e.clone()
737742
}
738-
PointerEvent::Enter(..) | PointerEvent::Scroll { .. } => e.clone(),
743+
PointerEvent::Enter(..) | PointerEvent::Scroll(..) => e.clone(),
739744
}
740745
}
741746

0 commit comments

Comments
 (0)