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

Update the minimum size of Label if necessary when resizing #77573

Closed

Conversation

Rindbee
Copy link
Contributor

@Rindbee Rindbee commented May 28, 2023

Previously, the necessary call to update the minimum size was missing.

Fixes #74052.
Supersedes #77568.

@Rindbee Rindbee requested a review from a team as a code owner May 28, 2023 12:52
@YeldhamDev YeldhamDev added this to the 4.1 milestone May 28, 2023
@YeldhamDev
Copy link
Member

You probably want to fix the spelling error in "Label". 😛

@Rindbee Rindbee changed the title Update the minimum size of Lable if necessary when resizing Update the minimum size of Label if necessary when resizing May 28, 2023
@Rindbee Rindbee force-pushed the update-minimum-size-if-necessary branch from 544d368 to cc68dfe Compare May 28, 2023 14:11
Previously, the necessary call to update the minimum size was missing.
@Rindbee Rindbee force-pushed the update-minimum-size-if-necessary branch from cc68dfe to 45ac7e3 Compare May 28, 2023 14:38
@@ -654,7 +654,10 @@ void Label::_notification(int p_what) {
} break;

case NOTIFICATION_RESIZED: {
lines_dirty = true;
if (autowrap_mode != TextServer::AUTOWRAP_OFF || overrun_behavior != TextServer::OVERRUN_NO_TRIMMING) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels wrong because at the end of _shape we already call update_minimum_size() but for the opposite checks. Are you sure it's here where we're supposed to fix it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For these modes and behaviors, a change in size may result in a change in the minimum size. The minimum height varies due to the size's width in these modes.

godot/scene/gui/label.cpp

Lines 676 to 683 in 2f57da2

if (autowrap_mode != TextServer::AUTOWRAP_OFF) {
return Size2(1, (clip || overrun_behavior != TextServer::OVERRUN_NO_TRIMMING) ? 1 : min_size.height) + min_style;
} else {
if (clip || overrun_behavior != TextServer::OVERRUN_NO_TRIMMING) {
min_size.width = 1;
}
return min_size + min_style;
}

Under the opposite option, changing the size does not actually change the minimum size. Calling update_minimum_size() in _shape() does not seem necessary unless you just switched to these options.

@YuriSizov
Copy link
Contributor

Superseded by #77651.

@YuriSizov YuriSizov closed this Jun 2, 2023
@Rindbee Rindbee deleted the update-minimum-size-if-necessary branch June 2, 2023 12:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Label + [autowrap] in VBoxContainer changes its size at startup (like line_spacing)
3 participants