-
Notifications
You must be signed in to change notification settings - Fork 343
scene: add functions to place node on top/bottom #3251
Conversation
Not sure if noop is a good behavior. Placing a node above/below itself doesn't make sense in the first place, so I'd rather add a |
The motivation is to make this tinywl code from #3250 simpler and avoid this special case: Lines 123 to 127 in 3723ddd
|
As the order of nodes is modified with "place above/below" operations, placing a node on the top is a special case anyway. IMO, it wouldn't hurt to be a bit explicit and have a check like "does this node need to be moved in the first place?", maybe with a That's just my personal preference though. At the very least, your proposed behavior probably needs to be documented in |
Barely related, but |
Yeah, I think I'd agree with @vyivel here. We should introduce a way to place on top or at the bottom, because that's a pretty common thing to do for compositors. But in general compositors either want to place above/below or on top/at the bottom -- ie, having functions which do both doesn't make it easier to write compositors. |
Currently these functions remove the node from the scene if the sibling argument is the same node as the node. To prevent confusion when misusing this API, assert that the nodes are distinct and document this.
fba262b
to
feae4bc
Compare
Ok, updated place above/below to assert that the nodes are distinct and added API to place a node on the top/bottom. I think you two are right and making the operation of placing a node above itself an assertion failure is a good idea. |
These are very common operations for compositors (including tinywl) to perform.
feae4bc
to
88024d3
Compare
Renamed the new functions to |
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.
LGTM, thanks!
Currently these functions remove the node from the scene if the sibling
argument is the same node as the node. Making this case a noop is much
more predictable behavior.