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

Add proportional layout and tests #261

Merged
merged 5 commits into from Jun 8, 2023
Merged

Conversation

tinchodias
Copy link
Collaborator

Fixes #260

Note: It still doesn't take into account minWidth and minHeight. It should, right?
Also, eventually a negative extent.
So another commit must work on those.

@tinchodias
Copy link
Collaborator Author

Unrelated test failures.

@tinchodias
Copy link
Collaborator Author

Given:

  aContainer := BlElement new
    layout: BlProportionalLayout new;
    yourself

that element can have as children elements like this:

  BlElement new
    margin: (BlInsets all: 7);
    constraintsDo: [ :c |
      c proportional fractions:
        (Rectangle
          left: 5 percent
          right: 95 percent
          top: 10 percent
          bottom: 90 percent ) ].

The 5 percent evaluates to the float 0.5. It only provides a more human readable way to express it (maybe).
The Bloc elements have a margin, which is equivalent to the "offset" of the Morphic proportional layout.

The child's constraints can look like this, too:

    constraintsDo: [ :c |
      c proportional horizontal
        leftFraction: 0.05;
        rightFraction: 0.95 ];
      c proportional vertical
        topFraction: 0.1;
        bottomFraction: 0.9 ]

Both horizontal and vertical are part of the inherited layout API, so the BlProportionalLayout also supports them.

@plantec
Copy link
Collaborator

plantec commented May 26, 2023

super thanks

@labordep
Copy link
Contributor

Thanks @tinchodias !

Request from Stef after the experience with Morphic's layout.
@tinchodias
Copy link
Collaborator Author

I removed [:c | c proportional fractions: Rectangle ... ] API after feedback from Stef. Basically, to avoid making the user to create 3 objects (1 Rectangle = 2 Points), to specify those fraction values that at the end, the constraints already hold as 4 numbers by separate.

I have another discussion:
Do we search a better name than "fraction" for the API?
May be "ratio"? leftRatio, rightRatio, etc.?
I don't like "proportion" , because it sounds too long and redundant, like [:c | c proportional horizontal leftProportion: 0.5 ]

@labordep
Copy link
Contributor

labordep commented May 29, 2023 via email

@tinchodias
Copy link
Collaborator Author

@labordep I like your idea!!!

@tinchodias
Copy link
Collaborator Author

Well, so let's merge!

@tinchodias tinchodias merged commit 361dc81 into dev-1.0 Jun 8, 2023
0 of 6 checks passed
@tinchodias tinchodias deleted the 260-Proportional-layout branch June 8, 2023 14:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Proportional layout
3 participants