Add Landmark support for margin and size in Layout#222
Add Landmark support for margin and size in Layout#222Glitch-On wants to merge 4 commits intocreativescala:mainfrom
Conversation
|
Thanks for doing this. Some CI tasks are failing. Can you run the |
|
Thank's for appreciation |
noelwelsh
left a comment
There was a problem hiding this comment.
There a fundamental problem with this code, which is that is misunderstands what Landmark means. This traces back to the existing documentation, which does not do a very good job of describing the semantics of Landmark, margin, and size.
margin specifies an adjustment to the bounding box. E.g. aPicture.margin(20, 20) adds 20 units (usually pixels) to each side of the bounding box. A Landmark is not an adjustment relative to the existing bounding box, but a point relative to the bounding box's origin. So aPicture.margin(Landmark.point(20, 20)) doesn't make sense, as Landmark.point(20, 20) is the point 20 units above and to the right from the origin.
To solve this there probably needs to be a new type that represents a scalar magnitude relative to some baseline. I think #190 needs the same type.
Also see #225
How you proceed is up to you. If you feel you understand the problem adequately you can have a go at fixing it. If you don't, you can wait for me to make some improvements.
| bottom: Landmark, | ||
| left: Landmark | ||
| ): Drawing[A] = | ||
| margin( |
There was a problem hiding this comment.
There should not be a default implementation here. This implementation will never be useful.
| * GenericLayout does). | ||
| */ | ||
| def size[A](img: Drawing[A], width: Landmark, height: Landmark): Drawing[A] = | ||
| size(img, width.x.eval(0, 0), height.y.eval(0, 0)) |
There was a problem hiding this comment.
There should not be a default implementation here. This implementation will never be useful.
This PR extends the Doodle Layout system to support Landmark-based dimensions for the margin and size methods, enabling percentage-based sizing and margins relative to bounding boxes. #169
Changes
Core Implementation
Layout trait: Added new margin and size method overloads that accept Landmark parameters instead of just Double values
GenericLayout: Implemented the logic to calculate actual dimensions based on landmark percentages relative to bounding box dimensions
LayoutSyntax: Extended the syntax to expose the new landmark-based methods to end users
Examples & Documentation
LandmarkLayoutExamples: Added comprehensive examples demonstrating percentage-based layouts, including: