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

Document meaning of position and size of rects #665

Closed
wants to merge 1 commit into from

Conversation

lukasrad02
Copy link
Contributor

In #663 we've fixed a bug related to the position and size of viewports and simulated regions. To prevent similar bugs to occur again, this PR should improve the documentation of these values.

@lukasrad02 lukasrad02 added documentation Improvements or additions to documentation shared Issues mainly related to shared labels Feb 9, 2023
@lukasrad02 lukasrad02 self-assigned this Feb 9, 2023
@@ -22,14 +22,20 @@ export class SimulatedRegion {
public readonly type = 'simulatedRegion';

/**
* top-left position
* Position of the viewport.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* Position of the viewport.
* Position of the simulated region.

@@ -22,14 +22,20 @@ export class SimulatedRegion {
public readonly type = 'simulatedRegion';

/**
* top-left position
* Position of the viewport.
* For positive {@link size}s, this refers to the upper left corner of the simulated region, but during resizing, corners may be swapped.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* For positive {@link size}s, this refers to the upper left corner of the simulated region, but during resizing, corners may be swapped.
* For positive {@link size}s, this refers to the upper left corner of the simulated region, but after resizing, corners may be swapped.

To make clear that this does not only happens while resizing (so in the act of it) but also persists thereafter.

*
* @deprecated Do not access directly, use helper methods from models/utils/position/position-helpers(-mutable) instead.
*/
@ValidateNested()
@IsPosition()
public readonly position: Position;

/**
* Size of the viewport.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* Size of the viewport.
* Size of the simulated region.

*
* @deprecated Do not access directly, use helper methods from models/utils/position/position-helpers(-mutable) instead.
*/
@ValidateNested()
@IsPosition()
public readonly position: Position;

/**
* Size of the viewport.
* The width of a viewport grows to the left, the height grows downwards.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* The width of a viewport grows to the left, the height grows downwards.
* The width of a simulated region grows to the left, the height grows downwards.

@@ -21,14 +21,20 @@ export class Viewport {
public readonly type = 'viewport';

/**
* top-left position
* Position of the viewport.
* For positive {@link size}s, this refers to the upper left corner of the viewport, but during resizing, corners may be swapped.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* For positive {@link size}s, this refers to the upper left corner of the viewport, but during resizing, corners may be swapped.
* For positive {@link size}s, this refers to the upper left corner of the viewport, but after resizing, corners may be swapped.

Same argument as with the simulated regions.

*
* @deprecated Do not access directly, use helper methods from models/utils/position/position-helpers(-mutable) instead.
*/
@ValidateNested()
@IsPosition()
public readonly position: Position;

/**
* Size of the viewport.
* The width of a viewport grows to the left, the height grows downwards.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
* The width of a viewport grows to the left, the height grows downwards.
* The width of a viewport grows to the right, the height grows downwards.

Or am I wrong again?

Copy link
Contributor

@ClFeSc ClFeSc Feb 9, 2023

Choose a reason for hiding this comment

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

No, should be correct (your suggestion, not the current version).

@Dassderdie
Copy link
Collaborator

There are still multiple occurrences of topLeftCoordinate missing in this PR.

I also believe the ResizeRectangleInteraction is currently only working by chance.
It seems to rely on PolygonGeometryHelper.getElementCoordinates putting the (x, y)-coordinate first.

To fix this, I propose to change the position of a Viewport and SimulatedRegion to be the center of the rectangle instead and enforce the Size to be positive. This should also reduce confusion in the future.

I would offer to do this migration sometime in the next week.

@lukasrad02
Copy link
Contributor Author

I would offer to do this migration sometime in the next week.

Sounds good, thank you!

So we can close this PR as it will be obsolete after your changes anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation shared Issues mainly related to shared
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants