Kruptein / PlanarAlly

A companion tool for when you travel into the planes.
https://www.planarally.io/
MIT License
393 stars 70 forks source link

[BUG] Note icon positon inconsistent between shape types #1408

Closed rexy712 closed 3 months ago

rexy712 commented 4 months ago

Describe the bug When enabling the option to 'Show note icon on shape', the note icon is currently drawn as a standalone shape which references another 'base shape' to derive its final position. Depending on what type of shape the base shape is, the note anchors to different places on the shape.

For example, on a circle, the refPoint is defined as the center of the circle, so the note icon anchors to the base shape's center. On a circle with radius = 1 grid square, this makes the icon draw off the shape entirely. On a circle with radius > 1 grid square, the icon draws somewhere close to the center of the circle.

On a rectangle shape, the refPoint is defined as the top left corner. So the note icon is drawn on the left side of the rectangle within its bounds (assuming no rotation). This is also true for any shape derived from BaseRect, including assets.

For the polygon tool and brush tool, the refPoint is defined as the first point, so the note icon is drawn in completely different places depending on how the shape was drawn.

To Reproduce Steps to reproduce the behavior:

  1. Draw a shape with the polygon tool.
  2. Attach a note and enable show note icon
  3. Note is drawn relative to refPoint, not a uniform location.

Expected behavior For rectangles, the behavior is perfectly fine and expected.

For circles, I think the best option would be to draw the icon aligned to one side near where the bounding box touches the circle edge. Probably the left side to best align with the style of rectangles. This would make it clearly attached to the circle even when the circle is large, but still keep it off to the side instead of smack dab in the middle.

For the polygon and brush shapes, it would be a decent idea to also draw relative to the top left of the bounding box to keep a consistent style. The problem there is that these can be any shape. So when the bounding box is not drawn, the icon may be in a seemingly unrelated spot. So maybe it's best these be drawn relative to the starting point, I'm not sure on this one.

Screenshots swappy-20240221_120243

Desktop:

Additional notes Honestly this might not even be considered an issue for some people, but it seems like a small aesthetic change that would make it feel more consistent. This should be treated as a low priority item.

Kruptein commented 4 months ago

Haha yeah this is one of the kinks I was talking about in that PR :V.