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

Crop tooltip displays incorrect center coordinates when rotating #1071

Closed
leejuyuu opened this issue May 4, 2024 · 3 comments · Fixed by #1073
Closed

Crop tooltip displays incorrect center coordinates when rotating #1071

leejuyuu opened this issue May 4, 2024 · 3 comments · Fixed by #1073
Labels

Comments

@leejuyuu
Copy link
Collaborator

leejuyuu commented May 4, 2024

Describe the bug

When the crop rectangle is rotated with the drag handle, the tooltip displays the center x and y coordinates. The displayed values change when rotating the rectangle, which is incorrect as the rectangle rotates around the center.

To Reproduce

  1. Open the crop tool and drag any rectangle.
  2. Drag to rotate the rectangle, and a tooltip with "center x: 123, y: 456..." will be displayed. The values will change as the rectangle is rotated.
  3. Drag to translate the rotated rectangle. The displayed coordinates values are correct now.

Expected behavior

The center coordinates should be fixed when rotating the rectangle.

Screenshots

nomacs_crop_rotate.mp4

Desktop:

  • OS: Arch Linux
  • Nomacs version: 3.17.2295 (94e9ada)
@leejuyuu
Copy link
Collaborator Author

leejuyuu commented May 4, 2024

@haferburg It's probably unrelated, but would you mind confirming this on your system?

@haferburg
Copy link
Contributor

Yes, it's also buggy on Ubuntu. The angle starts at +-90 degrees, which is odd. It should start at 0 IMO.
When you release the mouse button, the rectangle sometimes snaps, probably to 0 or 90 degrees. But the angle value in the toolbar isn't updated from the snapping.

It was my suspicion that #944 was caused by adding the rotate functionality.

It's a bit unclear to me how rotate is supposed to work, from a design perspective. It's probably: First the (axis-aligned) rectangle is defined, then the rotation is applied. So the (x,y,w,h) coordinates of the rectangle don't change when the rotation changes.
Otherwise you'd have to define the rectangle by the center c_x, c_y, plus a width and height and an angle. But this seems awkward and unintuitive for the basic use case without any rotation.

@leejuyuu
Copy link
Collaborator Author

@haferburg Thanks for confirming! The angle offset is indeed odd. I did not observe any snapping to 0 or 90 degrees.

The implementation seems quite similar to the first case you described, but the rotation changes are somehow stored not as an angle, but as a transformation matrix mixed with the center offsetting translations.

@leejuyuu leejuyuu added the bug label May 14, 2024
leejuyuu added a commit to leejuyuu/nomacs that referenced this issue May 14, 2024
Fixes nomacs#1071

The tooltip of the crop tool displays the center coordinates of the crop
rectangle when it is rotated, however, the displayed value changes when
we rotate around the center.

The value is incorrect because the center is not properly translated
before applying the rotation transform, which rotates around the
origin. This patch calculates the coordinates to be displayed
considering only the translation because rotation around the center
should not change its position.
novomesk pushed a commit that referenced this issue May 20, 2024
Fixes #1071

The tooltip of the crop tool displays the center coordinates of the crop
rectangle when it is rotated, however, the displayed value changes when
we rotate around the center.

The value is incorrect because the center is not properly translated
before applying the rotation transform, which rotates around the
origin. This patch calculates the coordinates to be displayed
considering only the translation because rotation around the center
should not change its position.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants