-
Notifications
You must be signed in to change notification settings - Fork 120
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 zstack
view to compose views on top of each other
#737
base: main
Are you sure you want to change the base?
Conversation
zstack
view to compose views on top of each otherzstack
view to compose views on top of each other
See also #591, which goes a similar direction. I think to make a I like the general direction, i.e. unifying a potential xilem_svg API using a zstack (instead of separate context such as in the web). |
I don't think that arbitrary transforms should block this landing, though. I don't really have the bandwidth to look at this too closely at the moment, unfortunately. |
To clarify, I didn't mean this to be a requirement, it's orthogonal to this change (and a lot more work...). I'll take a look at the PR when it's out of draft. On a skim it seems reasonable so far. |
0730a16
to
7c21129
Compare
Maybe adding a |
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.
This looks like a good foundation, and it should be a useful view. Some review thoughts from a first pass.
One thing which does concern me is event handling; I suspect that the behaviour will be hard to reason about. Ideally, we'd warn if more than one layer is interactive, but we don't currently have a mechanism to do that.
} | ||
|
||
#[derive(Debug, Clone, Copy, PartialEq, Eq)] | ||
pub enum HorizontalAlignment { |
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.
We may want to check whether we can merge or reuse a few of these enums for different container widgets. (no action required here though, I think that should be done in follow-up PRs)
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.
Lol, I just made this same comment (and then deleted when I saw this)
Can you expand on that a little bit? |
Sure. If you have a child widget of the zstack which accepts events in only a small region, and wants to pass through the rest (for example, a circular button), I don't think that will work because of how Masonry works, that events can only bubble. I haven't thought too deeply about it, and it doesn't need to be addressed in this PR. |
Would it somehow be possible to pass the event to the front most child of which the cursor is within the bounding box? |
Hmm, I think we need a more significant rework of the pointer-intersection logic in masonry anyways, i.e. allow the widgets to customize the pointer intersection behavior (as right now only the bounds are checked). Possibly with a cheaper hierarchical bounds check (BVH) before. I have similar issues in #753. I'm thinking about tackling this, as this is relevant for kurbo shapes with pointer event listeners as well. Anyway, I think this PR (and the linked) just shows issues with the mentioned pointer/widget-intersection logic, which I think is orthogonal and should probably be handled in another PR.... |
I fixed a lot of the comments you all made. After rebasing the PR the copyright symbol in the I made a black semi-transparent background for the copyright text, to make it easier to read. There are still some open comments that are unresolved and that I'd like your input on to continue. |
FWIW I think this should be fixed with #753, as well as supporting custom pointer intersection shapes (like the circular button), when I understand you correctly. |
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.
Handful of small things, but otherwise this looks good.
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.
Thanks! There's just a merge conflict to fix
} | ||
|
||
#[derive(Debug, Clone, Copy, PartialEq, Eq)] | ||
pub enum HorizontalAlignment { |
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.
Lol, I just made this same comment (and then deleted when I saw this)
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.
Looks good, thanks for all the work!
xilem/src/view/zstack.rs
Outdated
|
||
// MARK: Sequence | ||
|
||
/// A trait implementing `ViewSequence` for `ZStackElements`. |
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.
Nit: I think using the plural for ZStackElement
may suggest that there's a type ZStackElements
, so maybe rather ZStackElement
s or
[`ZStackElement`]s
to directly link to the type.
(same for the other occurences of this here)
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.
Makes sense, I fixed it in the latest commit
to make it more readable and to demonstrate more use cases of sized_box.
Still needs documentation
Adds a new
zstack
Xilem view (along with an accompanied Masonry widget).The view is inspired by the ZStack view in SwiftUI, which composes the child view on top of each other.
This pull-request is still work-in-progress.
(top-left, top-right, bottom-left, bottom-right, center).
http_cat
to put copyright on top of image like seen below.