Add box_align and justify for boxes #5404
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 distributedFalse
- No distribution; the defaultLines 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
box_wrap
is False. Only aligns lines relative to the tallest/widest row but does not cause size changes for the box.box_reverse_align
, to revert a feature that can happen with thebox_reverse
change introduced in 8.2.box_reverse True
in 8.2, wrapped rows in an hbox will appear right-aligned (in the way they appeared left-aligned whenbox_reverse False
). This would reverse thebox_align
property, with 0.0 aligning items to the right and 1.0 to the left, which seems unintuitive, so whenbox_reverse
is True for an 8.2 box, I flip the value ofbox_align
(so 0.0 becomes 1.0, 0.2 becomes 0.8, etc.).config.box_reverse_align = False
reverts this behavior sobox_align 0.0
withbox_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 aboutbox_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.2box_reverse
compatibility.