Skip to content

Implement compose pass#512

Merged
PoignardAzur merged 6 commits intomainfrom
implement_pass_spec_compose
Aug 16, 2024
Merged

Implement compose pass#512
PoignardAzur merged 6 commits intomainfrom
implement_pass_spec_compose

Conversation

@PoignardAzur
Copy link
Contributor

Add Widget::compose method.
Add ComposeCtx type.
Add needs_compose, request_compose, translation_changed flags to WidgetState.
Add window_origin attribute to WidgetState.
Add convenience methods to TreeArena.
Remove needs_window_origin flag and parent_window_origin attribute.

Copy link
Contributor

@waywardmonkeys waywardmonkeys left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some initial comments...

use std::time::Duration;

use accesskit::{NodeBuilder, TreeUpdate};
use kurbo::Vec2;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use crate::kurbo::Vec2 ?

Copy link
Contributor Author

@PoignardAzur PoignardAzur Aug 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it doesn't make a difference, they resolve to the same symbol. (Otherwise I think rustc would complain.)

I don't know if we have a coding style for this, but either way, we're already using both versions throughout Masonry, so I'll keep the ones you pointed out as-is.

/// Request a compose pass.
///
/// The compose pass is often cheaper than the layout pass, because it can only transform individual widgets' position.
/// [`compose`]: crate::Widget::compose
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no thing above this that this would be providing a link target for.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm the Link seems still not to be working using cargo doc --no-deps

// Copyright 2024 the Xilem Authors
// SPDX-License-Identifier: Apache-2.0

use kurbo::{Point, Vec2};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use crate::kurbo... again

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't fix, see other comment.

panic!(
"Error in '{}' #{}: cannot find child #{} returned by children_ids()",
parent_name,
parent_id.to_raw(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should there be a Display or Debug impl for WidgetId?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, but that's a future PR.


use std::sync::atomic::{AtomicBool, Ordering};

use kurbo::Vec2;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use crate::kurbo::Vec2;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, can combine with the import below.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I mean it's just a nit, but I agree, it's slightly cleaner, same for the other use comments here)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't fix, see other comment.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably generally find a unique style in the future, just to be consistent.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've had an agreement in the past in #223, but I needed to rebase it and it slipped through the cracks.

I've resurrected it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that #223 is in, this should become a use vello::kurbo::…

@PoignardAzur PoignardAzur force-pushed the implement_pass_spec_compose branch from 6346f72 to 188c594 Compare August 14, 2024 20:19
Copy link
Member

@DJMcNab DJMcNab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's hard to judge exactly what this is doing with no widgets actually using it...

Code seems about as expected, I believe.

pub(crate) is_portal: bool,

pub(crate) request_compose: bool,
// TODO - Handle matrix transforms
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Matrices are tricky with text, due to optical size of text (which we don't yet handle). I think changing the scale of a child can only correctly happen in layout

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm leaving that debate for once we do a complete layout refactor.

@PoignardAzur
Copy link
Contributor Author

I think this is ready to merge?

Copy link
Member

@Philipp-M Philipp-M left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I think there are a few unhandled review comments yet (apart from mine)?)


use std::sync::atomic::{AtomicBool, Ordering};

use kurbo::Vec2;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I mean it's just a nit, but I agree, it's slightly cleaner, same for the other use comments here)

Copy link
Member

@DJMcNab DJMcNab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the old ParentWindowOrigin code can be removed now?
I would much prefer that to happen in this PR if so.

self.children.id.unwrap()
}

/// Returns a shared token equivalent to this one.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shared doesn't seem quite right, given that ArenaRef cannot be copied (etc.). That is, ArenaRef does not appear to have any additional abilities over ArenaMut, except for being passed to methods which accept ArenaRef.

This method also doesn't seem to be used?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shared doesn't seem quite right, given that ArenaRef cannot be copied

Well now it can =P

This method also doesn't seem to be used?

Yeah, but I'm writing this as though it was a public crate.

InternalLifeCycle::ParentWindowOrigin { .. } => {
state.parent_window_origin = parent_ctx.widget_state.window_origin();
state.needs_window_origin = false;
// FIXME
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this event need to be removed?

@PoignardAzur
Copy link
Contributor Author

I've done some small fixes to address code review. Next step is removing Lifecycle::ParentWindowOrigin and associated stuff.

@PoignardAzur
Copy link
Contributor Author

I believe this is ready to merge.

@PoignardAzur
Copy link
Contributor Author

We should probably merge #223 first, then rebase this on top of it.

@PoignardAzur PoignardAzur force-pushed the implement_pass_spec_compose branch from 5334339 to 136e54a Compare August 16, 2024 17:02
@PoignardAzur
Copy link
Contributor Author

We should probably merge #223 first, then rebase this on top of it.

Done. I believe this addresses all code review points.

Copy link
Member

@DJMcNab DJMcNab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is compelling! It's really nice to see the back of the parent window origin things

@PoignardAzur PoignardAzur enabled auto-merge August 16, 2024 17:05
@PoignardAzur PoignardAzur added this pull request to the merge queue Aug 16, 2024
Merged via the queue into main with commit 652ee68 Aug 16, 2024
@PoignardAzur PoignardAzur deleted the implement_pass_spec_compose branch August 16, 2024 17:10
@PoignardAzur
Copy link
Contributor Author

... It just now occurs to me, as I start the paint pass, that I completely forgot to hook composition with the Scene transforms. We didn't catch it because widgets don't use the pass yet.

Oh well, I'll hook it up with the Portal widget while I implement the paint pass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants