Skip to content
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

Add passthrough code #714

Closed
wants to merge 1 commit into from
Closed

Add passthrough code #714

wants to merge 1 commit into from

Conversation

PoignardAzur
Copy link
Contributor

This code should help people who want to embed Masonry in a video game UI.

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 this is_passthrough mechanism also needs to care about pointer capture.

/// Whether this widgets obstructs pointer events for something behind the window.
///
/// Somewhat experimental.
fn is_passthrough(&self) -> bool {
Copy link
Member

Choose a reason for hiding this comment

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

What's the semantic difference between this and accepts_pointer_interaction?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

is_passthrough doesn't affect children.

There's probably a way to design these features to be more orthogonal and principled, but this is meant to be a quick-and-easy fix.

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.

Happy to see this. egui and others have similar and it is definitely something that was on our wishlist that I hadn't gotten around to yet.

@@ -325,6 +326,28 @@ impl RenderRoot {
self.cursor_icon
}

pub fn is_passthrough(&self, pos: PhysicalPosition<f64>) -> bool {
Copy link
Contributor

Choose a reason for hiding this comment

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

This needs a doc comment.

@@ -325,6 +326,28 @@ impl RenderRoot {
self.cursor_icon
}

pub fn is_passthrough(&self, pos: PhysicalPosition<f64>) -> bool {
let pos = Vec2::new(pos.x, pos.y) / self.scale_factor;
Copy link
Contributor

Choose a reason for hiding this comment

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

Would be nice if we were just using dpi::LogicalPosition here.

@@ -199,6 +199,13 @@ pub trait Widget: AsAny {
false
}

/// Whether this widgets obstructs pointer events for something behind the window.
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd add a pointer back to the RenderRoot method and the doc comment that will be there which can contain the more complete explanation.

@PoignardAzur
Copy link
Contributor Author

I'm closing this for now. I think a better solution would be one using the Widget::accepts_pointer_interaction() method.

The quick-and-dirty way to do it would be to add an accepts_pointer_interaction flag to Flex and Grid widgets.

The principled way to do it would be figuring out styling so that pointer interaction can be one of the style attributes. Still working on that.

@PoignardAzur PoignardAzur deleted the passthrough_widgets branch January 10, 2025 16:31
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.

3 participants