Skip to content

Commit 92d8dd5

Browse files
committed
Bump masonry, vello, and parley deps.
1 parent bec6c62 commit 92d8dd5

File tree

9 files changed

+417
-266
lines changed

9 files changed

+417
-266
lines changed

Cargo.lock

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

demo/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ android-view = { path = ".." }
1414
android_logger = "0.15.0"
1515
anyhow = "1.0.96"
1616
log = "0.4.26"
17-
parley = { git = "https://github.com/linebender/parley", rev = "587b7634ae8601c10de7f0361bfd56085a5b7b4e", features = ["accesskit"] }
18-
peniko = { version = "0.4.0", default-features = false }
17+
parley = { version = "0.6.0", features = ["accesskit"] }
18+
peniko = { version = "0.5.0", default-features = false }
1919
pollster = "0.4.0"
2020
ui-events = "0.1.0"
21-
vello = "0.5.0"
21+
vello = "0.6.0"
2222

2323
# Send tracing events to Android GPU inspector, for profiling
2424
tracing_android_trace = "0.1.1"

demo/src/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,8 @@ impl DemoViewPeer {
290290
// Queue the texture to be presented on the surface.
291291
surface_texture.present();
292292

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

296297
fn set_composing_text_internal(&mut self, text: &str, new_cursor_position: jint) {
@@ -439,6 +440,7 @@ impl ViewPeer for DemoViewPeer {
439440
) {
440441
self.tap_counter = TapCounter::new(ctx.view.view_configuration(&mut ctx.env));
441442
let editor = self.editor.editor_mut();
443+
#[allow(clippy::cast_possible_truncation, reason = "Unavoidable")]
442444
editor.set_scale(1.0);
443445
editor.set_width(Some(width as f32 - 2_f32 * text::INSET));
444446
self.last_drawn_generation = Default::default();

demo/src/text.rs

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use ui_events::{
1616
};
1717
use vello::{
1818
Scene,
19-
kurbo::{Affine, Line, Stroke},
19+
kurbo::{Affine, Line, Rect, Stroke},
2020
peniko::color::palette,
2121
peniko::{Brush, Fill},
2222
};
@@ -148,7 +148,7 @@ impl Editor {
148148
pub fn cursor_blink(&mut self) {
149149
self.cursor_visible = self.start_time.is_some_and(|start_time| {
150150
let elapsed = Instant::now().duration_since(start_time);
151-
(elapsed.as_millis() / self.blink_period.as_millis()) % 2 == 0
151+
(elapsed.as_millis() / self.blink_period.as_millis()).is_multiple_of(2)
152152
});
153153
}
154154

@@ -346,10 +346,10 @@ impl Editor {
346346
}
347347

348348
pub fn handle_accesskit_action_request(&mut self, req: &accesskit::ActionRequest) {
349-
if req.action == accesskit::Action::SetTextSelection {
350-
if let Some(accesskit::ActionData::SetTextSelection(selection)) = &req.data {
351-
self.driver().select_from_accesskit(selection);
352-
}
349+
if req.action == accesskit::Action::SetTextSelection
350+
&& let Some(accesskit::ActionData::SetTextSelection(selection)) = &req.data
351+
{
352+
self.driver().select_from_accesskit(selection);
353353
}
354354
}
355355

@@ -363,25 +363,26 @@ impl Editor {
363363
/// Returns drawn `Generation`.
364364
pub fn draw(&mut self, scene: &mut Scene) -> Generation {
365365
let transform = Affine::translate((INSET as f64, INSET as f64));
366-
self.editor.selection_geometry_with(|rect, _| {
367-
scene.fill(
368-
Fill::NonZero,
369-
transform,
370-
palette::css::STEEL_BLUE,
371-
None,
372-
&rect,
373-
);
374-
});
375-
if self.cursor_visible {
376-
if let Some(cursor) = self.editor.cursor_geometry(5.0) {
366+
self.editor
367+
.selection_geometry_with(|parley::BoundingBox { x0, x1, y0, y1 }, _| {
377368
scene.fill(
378369
Fill::NonZero,
379370
transform,
380-
palette::css::CADET_BLUE,
371+
palette::css::STEEL_BLUE,
381372
None,
382-
&cursor,
373+
&Rect { x0, x1, y0, y1 },
383374
);
384-
}
375+
});
376+
if self.cursor_visible
377+
&& let Some(parley::BoundingBox { x0, x1, y0, y1 }) = self.editor.cursor_geometry(5.0)
378+
{
379+
scene.fill(
380+
Fill::NonZero,
381+
transform,
382+
palette::css::CADET_BLUE,
383+
None,
384+
&Rect { x0, x1, y0, y1 },
385+
);
385386
}
386387
let layout = self.editor.layout(&mut self.font_cx, &mut self.layout_cx);
387388
for line in layout.lines() {

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/linebender/xilem", rev = "2750659" }
1313
masonry_android = { path = "../masonry" }
1414

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

masonry-demo/src/lib.rs

Lines changed: 5 additions & 5 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,
@@ -29,7 +29,7 @@ struct Driver {
2929
impl AppDriver for Driver {
3030
fn on_action(&mut self, ctx: &mut DriverCtx<'_>, _widget_id: WidgetId, action: ErasedAction) {
3131
if action.is::<ButtonPress>() {
32-
ctx.render_root().edit_root_widget(|mut root| {
32+
ctx.render_root().edit_base_layer(|mut root| {
3333
let mut portal = root.downcast::<Portal<Flex>>();
3434
let mut flex = Portal::child_mut(&mut portal);
3535
Flex::add_child(&mut flex, Label::new(self.next_task.clone()).with_auto_id());
@@ -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/linebender/xilem", rev = "2750659" }
1010
pollster = "0.4.0"
1111
tracing = "0.1.40"

masonry/src/lib.rs

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ impl MasonryState {
116116
default_properties,
117117
use_system_fonts: true,
118118
size_policy: WindowSizePolicy::User,
119+
size: Default::default(),
119120
scale_factor,
120121
test_font: None,
121122
},
@@ -170,6 +171,9 @@ impl<Driver: AppDriver> MasonryViewPeer<Driver> {
170171
self.app_driver
171172
.on_action(&mut driver_ctx, widget_id, action);
172173
}
174+
RenderRootSignal::ClipboardStore(..) => {
175+
// TODO
176+
}
173177
RenderRootSignal::StartIme => {
174178
ctx.push_static_deferred_callback(show_soft_input);
175179
}
@@ -228,6 +232,15 @@ impl<Driver: AppDriver> MasonryViewPeer<Driver> {
228232
};
229233
info!("Widget selected in inspector: {widget_id} - {display_name}");
230234
}
235+
RenderRootSignal::NewLayer(..) => {
236+
// TODO
237+
}
238+
RenderRootSignal::RepositionLayer(..) => {
239+
// TODO
240+
}
241+
RenderRootSignal::RemoveLayer(..) => {
242+
// TODO
243+
}
231244
}
232245
}
233246

@@ -243,10 +256,11 @@ impl<Driver: AppDriver> MasonryViewPeer<Driver> {
243256

244257
let (scene, tree_update) = self.state.render_root.redraw();
245258

246-
if let Some(events) = self
247-
.state
248-
.accesskit_adapter
249-
.update_if_active(|| tree_update)
259+
if let Some(tree_update) = tree_update
260+
&& let Some(events) = self
261+
.state
262+
.accesskit_adapter
263+
.update_if_active(|| tree_update)
250264
{
251265
ctx.push_dynamic_deferred_callback(move |env, view| {
252266
events.raise(env, &view.0);
@@ -317,7 +331,8 @@ impl<Driver: AppDriver> MasonryViewPeer<Driver> {
317331
// Queue the texture to be presented on the surface.
318332
surface_texture.present();
319333

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

323338
fn on_key_event<'local>(
@@ -347,7 +362,7 @@ impl<Driver: AppDriver> MasonryViewPeer<Driver> {
347362
if handler.requested_initial_tree {
348363
self.state
349364
.render_root
350-
.handle_window_event(WindowEvent::RebuildAccessTree);
365+
.handle_window_event(WindowEvent::EnableAccessTree);
351366
self.handle_signals(ctx);
352367
}
353368
result
@@ -436,9 +451,9 @@ impl<Driver: AppDriver> ViewPeer for MasonryViewPeer<Driver> {
436451
width: jint,
437452
height: jint,
438453
) {
439-
self.state.tap_counter = TapCounter::new(ctx.view.view_configuration(&mut ctx.env));
440454
let android_ctx = ctx.view.context(&mut ctx.env);
441455
let scale_factor = scale_factor(&mut ctx.env, &android_ctx);
456+
self.state.tap_counter = TapCounter::new(ctx.view.view_configuration(&mut ctx.env));
442457
self.state
443458
.render_root
444459
.handle_window_event(WindowEvent::Rescale(scale_factor));

src/events.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -425,9 +425,11 @@ impl<'local> MotionEvent<'local> {
425425
let contact_geometry = if pointer.pointer_type == PointerType::Touch {
426426
let height = self.axis(env, Axis::TouchMajor, action_index) as f64;
427427
let width = self.axis(env, Axis::TouchMinor, action_index) as f64;
428-
(height > 0.0 && width > 0.0)
429-
.then_some(ContactGeometry { width, height })
430-
.unwrap_or_default()
428+
if height > 0.0 && width > 0.0 {
429+
ContactGeometry { width, height }
430+
} else {
431+
Default::default()
432+
}
431433
} else {
432434
Default::default()
433435
};
@@ -492,9 +494,11 @@ impl<'local> MotionEvent<'local> {
492494
self.historical_axis(env, Axis::TouchMajor, action_index, pos) as f64;
493495
let width =
494496
self.historical_axis(env, Axis::TouchMinor, action_index, pos) as f64;
495-
(height > 0.0 && width > 0.0)
496-
.then_some(ContactGeometry { width, height })
497-
.unwrap_or_default()
497+
if height > 0.0 && width > 0.0 {
498+
ContactGeometry { width, height }
499+
} else {
500+
Default::default()
501+
}
498502
} else {
499503
Default::default()
500504
};

0 commit comments

Comments
 (0)