-
-
Notifications
You must be signed in to change notification settings - Fork 404
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
Implement explicitly setting a center of rotation #783
Conversation
|
Hi, sorry for the late response; I'll try to answer point by point:
According to the documentation, the current transform-order is: rotate -> translate -> scale. But, looking at the code (https://github.com/elkowar/eww/blob/master/crates/eww/src/widgets/transform.rs#L165) it seems to be: scale -> rotate -> translate |
fd4100b
to
ae5cb63
Compare
Update:
|
ae5cb63
to
9e71cf3
Compare
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!
just one minor question, see the comment
cr.translate(transform_origin_x, transform_origin_y); | ||
cr.rotate(perc_to_rad(rotate)); | ||
cr.translate(translate_x, translate_y); | ||
cr.translate(translate_x - transform_origin_x, translate_y - transform_origin_y); |
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 doesn't break the order defined here, right?
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.
Well, even before this patch, the methods called on cr
are in the order:
- scale
- rotate
- translate
whereas in the comment you linked, it's claimed that the order is:
- rotate
- translate
- scale
Sooooo... I don't know? Was it ever in the right order? Or is it sorted by the cairo-Context?
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 doesn't sort them, if i'm understanding the docs right.
i suggest sorting them in the order described in the documentation, though i don't think it makes much of a difference.
also, the only thing causing the merge conflict is the changelog entry, that should be trivial to resolve when rebasing onto master ^^
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.
There is a difference I'm afraid.
On the left side, scale is called after rotate + translate. basically, it warps the contents into a parallelogram when rotated. (the scaling is applied in the original directions of the x and y axis)
On the right is the same eww.yuck, but scale is called before rotate+translate, or the whole, scaled widget is rotated.
Generally speaking, users can always force a specific order by nesting multiple transforms. I did this here, where i nested the rotate+translate transform inside the scale transform:
but it's not entirely the same; the bottom seems to be cut off (Because the size on the y-axis for this widget was limited by the scale to 60%)
soo... do we want the warping rotate as the default (scale after rotate, as documented), or do we want the non-warping rotate as the default (as previously implemented)?
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'm pretty sure non-warping rotation is a saner default, the documentation should be updated accordingly
9fc4393
to
4058a42
Compare
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.
thank you for your work <3
please do not merge yet, I want to double-check it's correct |
The transform-Widget provides "rotate" to rotate its child. However, the default center of rotation is (0, 0) (aka top-left), so it was not possible to, for example, rotate a child in-place. This commit implements the additional options `transform-origin-x` and `transform-origin-y`. Both are optional, and the default value is 0.0 for each, so previous configurations should produce the same results.
4058a42
to
d3113ff
Compare
Ok, that was a bit close for comfort, but re-checking what I did was the right decision. The non-warping version is the one with the previously documented method-order, rotate->translate->scale. I have rebuild this newest force-pushed commit both with Sry for the mix-up. |
thank you for double-checking! just as a heads-up: there should be no difference in how you build if you execute the commands the way you stated ^^ |
Description
The transform-Widget provides "rotate" to rotate its child. However, the default center of rotation is (0, 0) (aka top-left), so it was not possible to, for example, rotate a child in-place.
This commit implements the additional options
rotation-center-x
androtation-center-y
. Both are optional, and the default value is 0.0 for each, so previous configurations should produce the same results.Usage
Showcase
I made a 5 second video of above configuration, but can't embed it here.
Additional Notes
rotation-center-*
andtranslate-*
needs to be mentioned, though it is not "wrong". If an in-place/centered rotation is wanted, and a shift to the right, the shift to the right needs to be added on top of the rotation-center-value to get an in-place rotation.Checklist
Please make sure you can check all the boxes that apply to this PR.
docs/content/main
directory has been adjusted to reflect my changes.cargo fmt
to automatically format all code before committing