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

Improve multicolumn legend layout #39052

Merged
merged 4 commits into from Oct 5, 2020

Conversation

jdugge
Copy link
Contributor

@jdugge jdugge commented Sep 26, 2020

Correct calculation of target column heights in multicolumn legends

Multicolumn legends sometimes have uneven column lengths even in cases where equally sized columns would be possible. This is caused by the fact that the heuristic currently calculates the target column height by summing the height of all legend items including the space between items and dividing it by the number of columns, without taking into account that the first item in each column has no space above it.

This pull request corrects this behavior by reducing the total height of all legend items by the inter-item space that is not required due to the column breaks.

Fixes #37417

@github-actions github-actions bot added this to the 3.16.0 milestone Sep 26, 2020
@jdugge
Copy link
Contributor Author

jdugge commented Sep 27, 2020

The change leads to a different output for the testColumnBreaks4() unit test.

Old behaviour:
expected_legend_column_breaks4

New behaviour:
legend_column_breaks4

The new layout is less tall than the old result, while still respecting the manual column breaks. I think that the new behavior is preferable.

@jdugge jdugge changed the title First item in each legend column has no space above it Improve multicolumn legend layout Sep 27, 2020
@bru500
Copy link

bru500 commented Sep 27, 2020

Great, thank you! Missed this much better behaviour.

@nyalldawson
Copy link
Collaborator

Nice fix!

I agree about the reference image -- can you update this so that the tests pass again?

@jdugge
Copy link
Contributor Author

jdugge commented Oct 5, 2020

@nyalldawson Done

@nyalldawson nyalldawson merged commit 4465034 into qgis:master Oct 5, 2020
@nyalldawson
Copy link
Collaborator

Thanks @jdugge !

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.

Legends in layouts 'Split Layers' with uneven Columns
3 participants