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

Double-clicking a mouse handle for a layout label resizes to fit text #59651

Merged
merged 6 commits into from
Dec 4, 2024

Conversation

nyalldawson
Copy link
Collaborator

Double-clicking a handle will auto-size the label to exactly fit
the contained text (growing or shrinking as needed). The opposite
side of the label will remaining fixed in place, so eg double-click
the bottom-right handle causes the bottom-right corner of the label
to move.

@nyalldawson nyalldawson added Feature Print Layouts Related to QGIS Print Layouts, Atlas or Reporting frameworks Needs Documentation When merging a labeled PR, an issue will be created in the Doc repo. Changelog Items that are queued to appear in the visual changelog - remove after harvesting labels Nov 29, 2024
@qgis-bot
Copy link
Collaborator

@nyalldawson
This pull request has been tagged as requiring documentation.

A documentation ticket will be opened at https://github.com/qgis/QGIS-Documentation when this PR is merged.

Please update the description (not the comments) with helpful description and screenshot to help the work from documentors.
Also, any commit having [needs-doc] or [Needs Documentation] in will see its message pushed to the issue, so please be as verbose as you can.

Thank you!

@github-actions github-actions bot added this to the 3.42.0 milestone Nov 29, 2024
@qgis-bot
Copy link
Collaborator

@nyalldawson

This pull request has been tagged for the changelog.

  • The description will be harvested so please provide a "nearly-ready" text for the final changelog
  • If possible, add a nice illustration of the feature. Only the first one in the description will be harvested (GIF accepted as well)
  • If you can, it's better to give credits to your sponsor, see below for different formats.

You can edit the description.

Format available for credits
  • Funded by NAME
  • Funded by URL
  • Funded by NAME URL
  • Sponsored by NAME
  • Sponsored by URL
  • Sponsored by NAME URL

Thank you!

Copy link

github-actions bot commented Nov 29, 2024

🪟 Windows builds

Download Windows builds of this PR for testing.
Debug symbols for this build are available here.
(Built from commit 2c943be)

🪟 Windows Qt6 builds

Download Windows Qt6 builds of this PR for testing.
(Built from commit 2c943be)

@YoannQDQ
Copy link
Contributor

That's great! Unfortunately sizeForText seems a bit unreliable. It does not always compute the right size...

…layout item

Doing so can cause unintentional moves of the item
This accounts for eg antialiasing based rounding, and avoids us
returning a size which is only just exactly enough to fit
the text
Double-clicking a handle will auto-size the label to exactly fit
the contained text (growing or shrinking as needed). The opposite
side of the label will remaining fixed in place, so eg double-click
the bottom-right handle causes the bottom-right corner of the label
to move.
@qgis qgis deleted a comment from github-actions bot Dec 2, 2024
@qgis qgis deleted a comment from github-actions bot Dec 2, 2024
@nyalldawson
Copy link
Collaborator Author

@YoannQDQ

Unfortunately sizeForText seems a bit unreliable. It does not always compute the right size...

Have you got some examples I could check that with? I'll address in a follow up PR

@YoannQDQ
Copy link
Contributor

YoannQDQ commented Dec 3, 2024

@nyalldawson Any label really.

test_label_resize.zip

Here is an example project with a single layout that contains 4 labelItems:

  • label1 : no html rendering, single line
  • label2 : no html rendering, multiline
  • label3 : html rendering, single line, no <br/>
  • label4 : html rendering, single line, with <br/>
  • label5 : html rendering, multiline, no <br/>
  • label6 : html rendering, multiline, with <br/>

I called adjustSizeToText() on each of them. Here's the result:

image

@nyalldawson
Copy link
Collaborator Author

@YoannQDQ Ah, I think that'll be improved by the fix in this pr already

@nyalldawson
Copy link
Collaborator Author

@YoannQDQ also, good point regarding HTML mode, I hadn't considered that. I've now set it so that no auto-sizing happens if the label is in HTML mode

@nyalldawson nyalldawson merged commit 77ee4cb into qgis:master Dec 4, 2024
31 checks passed
@nyalldawson nyalldawson deleted the dbl_click_label branch December 4, 2024 19:13
@qgis-bot
Copy link
Collaborator

qgis-bot commented Dec 4, 2024

@nyalldawson
A documentation ticket has been opened at qgis/QGIS-Documentation#9447
It is your responsibility to visit this ticket and add as much detail as possible for the documentation team to correctly document this change.
Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelog Items that are queued to appear in the visual changelog - remove after harvesting Feature Needs Documentation When merging a labeled PR, an issue will be created in the Doc repo. Print Layouts Related to QGIS Print Layouts, Atlas or Reporting frameworks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants