-
Notifications
You must be signed in to change notification settings - Fork 5
Bump masonry, vello, and parley deps. #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,15 +12,15 @@ use android_view::{ | |
| }; | ||
| use masonry::{ | ||
| core::{ErasedAction, NewWidget, Properties, Widget, WidgetId}, | ||
| properties::Padding, | ||
| properties::{Padding, types::Length}, | ||
| theme::default_property_set, | ||
| widgets::{Button, ButtonPress, Flex, Label, Portal, TextAction, TextArea, TextInput}, | ||
| }; | ||
| use masonry_android::{AppDriver, DriverCtx}; | ||
| use std::{ffi::c_void, sync::Arc}; | ||
| use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt}; | ||
|
|
||
| const WIDGET_SPACING: f64 = 5.0; | ||
| const WIDGET_SPACING: Length = Length::const_px(5.0); | ||
|
|
||
| struct Driver { | ||
| next_task: String, | ||
|
|
@@ -29,7 +29,7 @@ struct Driver { | |
| impl AppDriver for Driver { | ||
| fn on_action(&mut self, ctx: &mut DriverCtx<'_>, _widget_id: WidgetId, action: ErasedAction) { | ||
| if action.is::<ButtonPress>() { | ||
| ctx.render_root().edit_root_widget(|mut root| { | ||
| ctx.render_root().edit_base_layer(|mut root| { | ||
| let mut portal = root.downcast::<Portal<Flex>>(); | ||
| let mut flex = Portal::child_mut(&mut portal); | ||
| Flex::add_child(&mut flex, Label::new(self.next_task.clone()).with_auto_id()); | ||
|
|
@@ -59,8 +59,8 @@ fn make_widget_tree() -> impl Widget { | |
| .with_child(NewWidget::new_with_props( | ||
| Flex::row() | ||
| .with_flex_child(TextInput::new("").with_auto_id(), 1.0) | ||
| .with_child(Button::new("Add task").with_auto_id()), | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can make this code slightly more readable with |
||
| Properties::new().with(Padding::all(WIDGET_SPACING)), | ||
| .with_child(Button::new(NewWidget::new(Label::new("Add task"))).with_auto_id()), | ||
| Properties::new().with(Padding::all(WIDGET_SPACING.get())), | ||
| )) | ||
| .with_spacer(WIDGET_SPACING) | ||
| .with_auto_id(), | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -116,6 +116,7 @@ impl MasonryState { | |
| default_properties, | ||
| use_system_fonts: true, | ||
| size_policy: WindowSizePolicy::User, | ||
| size: Default::default(), | ||
| scale_factor, | ||
| test_font: None, | ||
| }, | ||
|
|
@@ -170,6 +171,9 @@ impl<Driver: AppDriver> MasonryViewPeer<Driver> { | |
| self.app_driver | ||
| .on_action(&mut driver_ctx, widget_id, action); | ||
| } | ||
| RenderRootSignal::ClipboardStore(..) => { | ||
| // TODO | ||
| } | ||
| RenderRootSignal::StartIme => { | ||
| ctx.push_static_deferred_callback(show_soft_input); | ||
| } | ||
|
|
@@ -228,6 +232,15 @@ impl<Driver: AppDriver> MasonryViewPeer<Driver> { | |
| }; | ||
| info!("Widget selected in inspector: {widget_id} - {display_name}"); | ||
| } | ||
| RenderRootSignal::NewLayer(..) => { | ||
| // TODO | ||
| } | ||
| RenderRootSignal::RepositionLayer(..) => { | ||
| // TODO | ||
| } | ||
| RenderRootSignal::RemoveLayer(..) => { | ||
| // TODO | ||
| } | ||
|
Comment on lines
+235
to
+243
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you don't know how to handle those, you should replicate the version in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will do, thanks. |
||
| } | ||
| } | ||
|
|
||
|
|
@@ -243,10 +256,11 @@ impl<Driver: AppDriver> MasonryViewPeer<Driver> { | |
|
|
||
| let (scene, tree_update) = self.state.render_root.redraw(); | ||
|
|
||
| if let Some(events) = self | ||
| .state | ||
| .accesskit_adapter | ||
| .update_if_active(|| tree_update) | ||
| if let Some(tree_update) = tree_update | ||
| && let Some(events) = self | ||
| .state | ||
| .accesskit_adapter | ||
| .update_if_active(|| tree_update) | ||
| { | ||
| ctx.push_dynamic_deferred_callback(move |env, view| { | ||
| events.raise(env, &view.0); | ||
|
|
@@ -317,7 +331,8 @@ impl<Driver: AppDriver> MasonryViewPeer<Driver> { | |
| // Queue the texture to be presented on the surface. | ||
| surface_texture.present(); | ||
|
|
||
| device_handle.device.poll(wgpu::Maintain::Poll); | ||
| // `poll` has a return type for a reason, but not sure what to do with it here. | ||
| let _ = device_handle.device.poll(wgpu::PollType::Poll); | ||
| } | ||
|
|
||
| fn on_key_event<'local>( | ||
|
|
@@ -347,7 +362,7 @@ impl<Driver: AppDriver> MasonryViewPeer<Driver> { | |
| if handler.requested_initial_tree { | ||
| self.state | ||
| .render_root | ||
| .handle_window_event(WindowEvent::RebuildAccessTree); | ||
| .handle_window_event(WindowEvent::EnableAccessTree); | ||
| self.handle_signals(ctx); | ||
| } | ||
| result | ||
|
|
@@ -436,9 +451,9 @@ impl<Driver: AppDriver> ViewPeer for MasonryViewPeer<Driver> { | |
| width: jint, | ||
| height: jint, | ||
| ) { | ||
| self.state.tap_counter = TapCounter::new(ctx.view.view_configuration(&mut ctx.env)); | ||
| let android_ctx = ctx.view.context(&mut ctx.env); | ||
| let scale_factor = scale_factor(&mut ctx.env, &android_ctx); | ||
| self.state.tap_counter = TapCounter::new(ctx.view.view_configuration(&mut ctx.env)); | ||
| self.state | ||
| .render_root | ||
| .handle_window_event(WindowEvent::Rescale(scale_factor)); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you could use the crates.io release instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It didn't exist at that point 😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh and also that has to go in the ui-events 0.2.0 PR, because that's a separate set of changes.