Avoid measuring labels width-for-height#1299
Merged
GeopJr merged 1 commit intoGeopJr:mainfrom Dec 28, 2024
Merged
Conversation
Mark the wrappable label hexpand, and use xalign to align the text to the left -- this is just like what spoiler_label_rev already does. This now hits the fast path introduced in https://gitlab.gnome.org/GNOME/gtk/-/commit/4150f2d3d255b90d4c28bb08d186153a97a3d3fb, avoiding measuring the label width-for-height. The header_button ("%s boosted", "in reply to %s") already has halign set to start. Also give it valign of center. This should not change anything about the resulting layout at all, since the label is always allocated exactly its natural height (same as minimum height), but since https://gitlab.gnome.org/GNOME/gtk/-/commit/16911e183ca12c441bc6bbbb650f63e25f02016e GTK will in this case horizontally align for the overall natural width rather than for the natural width for allocated height; thus we avoid measuring the label width-for-height. But note that this is not in any way a guarantee, we just exploit a specific aspect of GTK behavior here. Signed-off-by: Sergey Bugaev <[email protected]>
Owner
|
LGTM, thanks! |
GeopJr
pushed a commit
that referenced
this pull request
Mar 1, 2025
Mark the wrappable label hexpand, and use xalign to align the text to the left -- this is just like what spoiler_label_rev already does. This now hits the fast path introduced in https://gitlab.gnome.org/GNOME/gtk/-/commit/4150f2d3d255b90d4c28bb08d186153a97a3d3fb, avoiding measuring the label width-for-height. The header_button ("%s boosted", "in reply to %s") already has halign set to start. Also give it valign of center. This should not change anything about the resulting layout at all, since the label is always allocated exactly its natural height (same as minimum height), but since https://gitlab.gnome.org/GNOME/gtk/-/commit/16911e183ca12c441bc6bbbb650f63e25f02016e GTK will in this case horizontally align for the overall natural width rather than for the natural width for allocated height; thus we avoid measuring the label width-for-height. But note that this is not in any way a guarantee, we just exploit a specific aspect of GTK behavior here. Signed-off-by: Sergey Bugaev <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
These were the remaining places in Tuba where labels were still being measured width-for-height (at least, on my timeline right now), and with these simple changes, we seem to get rid of them too. See the commit message.
There are likely some more small things here and there; for instance I saw a similarly start-aligned wrappable "By %s" button. That should be avoidable using the same valign=center trick.