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 box_align and justify for boxes #5404

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

shawna-p
Copy link
Contributor

This PR adds two properties to boxes, addressing #5094 and #3666.

In particular, it has the following functionality:

justify

  • True - All lines but the final line will have their items evenly distributed such that they reach the edges of the box.
  • "first" - Only the first line will be evenly distributed.
  • "all" - All lines, including the final line, will be evenly distributed
  • False - No distribution; the default
    Lines which only have one item do not get justified (as there is no way to do so) and are considered unjustified for the purposes of box_align.

box_align

  • A value (typically between 0.0 and 1.0 but not required) which will be used to align the contents of box lines which are not justified. Has no effect if box_wrap is False. Only aligns lines relative to the tallest/widest row but does not cause size changes for the box.
  • It has an accompanying config value, box_reverse_align, to revert a feature that can happen with the box_reverse change introduced in 8.2.
    • If you use box_reverse True in 8.2, wrapped rows in an hbox will appear right-aligned (in the way they appeared left-aligned when box_reverse False). This would reverse the box_align property, with 0.0 aligning items to the right and 1.0 to the left, which seems unintuitive, so when box_reverse is True for an 8.2 box, I flip the value of box_align (so 0.0 becomes 1.0, 0.2 becomes 0.8, etc.).
    • Setting config.box_reverse_align = False reverts this behavior so box_align 0.0 with box_reverse True will result in right-aligned rows (and equivalents for vbox).

NOTE

I would like box_align to be a proper style property, alongside other box_ and alignment properties, and have structured my PR such that it is expected to be a style property. However, I believe there is some piece I am missing as it is not recognized as a style property in my tests. Therefore, this code does not work directly as it throws an error about box_align not being a recognized style property.

I have, however, tested this code by making it a keyword instead and it is functioning as expected. If needed I can adapt the PR to make it a keyword instead.

Merging this PR should also be followed up by including a line in the Incompatible section explaining config.box_reverse_align for 8.2 box_reverse compatibility.

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.

None yet

1 participant