Skip to content

Commit f266b8a

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

File tree

10 files changed

+352
-88
lines changed

10 files changed

+352
-88
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 = "4e0447d" }
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 = "4e0447d" }
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-demo/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ use android_view::{
1212
};
1313
use masonry::{
1414
core::{ErasedAction, NewWidget, Properties, Widget, WidgetId},
15-
properties::Padding,
15+
properties::{Padding, types::Length},
1616
theme::default_property_set,
1717
widgets::{Button, ButtonPress, Flex, Label, Portal, TextAction, TextArea, TextInput},
1818
};
1919
use masonry_android::{AppDriver, DriverCtx};
2020
use std::{ffi::c_void, sync::Arc};
2121
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
2222

23-
const WIDGET_SPACING: f64 = 5.0;
23+
const WIDGET_SPACING: Length = Length::const_px(5.0);
2424

2525
struct Driver {
2626
next_task: String,
@@ -59,8 +59,8 @@ fn make_widget_tree() -> impl Widget {
5959
.with_child(NewWidget::new_with_props(
6060
Flex::row()
6161
.with_flex_child(TextInput::new("").with_auto_id(), 1.0)
62-
.with_child(Button::new("Add task").with_auto_id()),
63-
Properties::new().with(Padding::all(WIDGET_SPACING)),
62+
.with_child(Button::new(NewWidget::new(Label::new("Add task"))).with_auto_id()),
63+
Properties::new().with(Padding::all(WIDGET_SPACING.get())),
6464
))
6565
.with_spacer(WIDGET_SPACING)
6666
.with_auto_id(),

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"

masonry/src/lib.rs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,9 @@ impl<Driver: AppDriver> MasonryViewPeer<Driver> {
170170
self.app_driver
171171
.on_action(&mut driver_ctx, widget_id, action);
172172
}
173+
RenderRootSignal::ClipboardStore(..) => {
174+
// TODO
175+
}
173176
RenderRootSignal::StartIme => {
174177
ctx.push_static_deferred_callback(show_soft_input);
175178
}
@@ -243,10 +246,11 @@ impl<Driver: AppDriver> MasonryViewPeer<Driver> {
243246

244247
let (scene, tree_update) = self.state.render_root.redraw();
245248

246-
if let Some(events) = self
247-
.state
248-
.accesskit_adapter
249-
.update_if_active(|| tree_update)
249+
if let Some(tree_update) = tree_update
250+
&& let Some(events) = self
251+
.state
252+
.accesskit_adapter
253+
.update_if_active(|| tree_update)
250254
{
251255
ctx.push_dynamic_deferred_callback(move |env, view| {
252256
events.raise(env, &view.0);
@@ -317,7 +321,8 @@ impl<Driver: AppDriver> MasonryViewPeer<Driver> {
317321
// Queue the texture to be presented on the surface.
318322
surface_texture.present();
319323

320-
device_handle.device.poll(wgpu::Maintain::Poll);
324+
// `poll` has a return type for a reason, but not sure what to do with it here.
325+
let _ = device_handle.device.poll(wgpu::PollType::Poll);
321326
}
322327

323328
fn on_key_event<'local>(
@@ -347,7 +352,7 @@ impl<Driver: AppDriver> MasonryViewPeer<Driver> {
347352
if handler.requested_initial_tree {
348353
self.state
349354
.render_root
350-
.handle_window_event(WindowEvent::RebuildAccessTree);
355+
.handle_window_event(WindowEvent::EnableAccessTree);
351356
self.handle_signals(ctx);
352357
}
353358
result

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)