-
Notifications
You must be signed in to change notification settings - Fork 258
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
docs(examples): show layout constraints #393
Conversation
The screen shot looks great! For me personally something that would also be useful is describing in the documentation the math of the linear program for solving the constraints. I’m happy to take a stab at that over the weekend. |
Codecov Report
@@ Coverage Diff @@
## main #393 +/- ##
=======================================
Coverage 85.10% 85.10%
=======================================
Files 40 40
Lines 8727 8727
=======================================
Hits 7427 7427
Misses 1300 1300 |
I don't know whether that would necessarily be worth your time, especially since we get pretty close to it with taffy for the cost of significantly less code and the benefit of fixing some annoying gaps. I'm a big fan of simple / obvious code over complex code when possible. |
Shows the way that layout constraints interact visually ![example](https://vhs.charm.sh/vhs-1ZNoNLNlLtkJXpgg9nCV5e.gif)
Here's a ChatGPT generated solution for the mathematical program:
When I did this in Julia, I added one additional constraint. I added a weak constraint saying all widths should be the same for each element for horizontal layouts OR all heights should be the same for each element for vertical layouts. Because it is a weak constraint, it is the last to take precedence. That seemed to give me results that I felt were more intuitive or what a user might naturally expect. |
This talk on YouTube is a great resource for understanding why Cassowary is typically used for this kind of problem, and gives some insight into the math above: https://www.youtube.com/watch?v=gxfyb3ipUFg |
Merging this to help make it easier to visually look at various layout changes. |
Shows the way that layout constraints interact visually
Review Notes
I'm not sure if this is "good" as an example for users to get value out of the code, as it isn't super simple code. But it covers a reasonable combination of all constraints. It doesn't cover layout margins, and situations where constraints cause gaps (e.g. when Percentage results in a size < full cell width).
Inspired by the following issues:
Constraint
variants #354