Skip to content

Commit

Permalink
Merge pull request #50478 from KoBeWi/xalign
Browse files Browse the repository at this point in the history
[3.x] Fix valign with stylebox borders
  • Loading branch information
akien-mga authored Jul 15, 2021
2 parents 231efe0 + dd62aa1 commit 50790a5
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions scene/gui/label.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,25 +118,29 @@ void Label::_notification(int p_what) {
lines_visible = max_lines_visible;
}

float total_h = 0;
total_h += lines_visible * font_h;
total_h += style->get_margin(MARGIN_TOP) + style->get_margin(MARGIN_BOTTOM);

if (lines_visible > 0) {
switch (valign) {
case VALIGN_TOP: {
//nothing
} break;
case VALIGN_CENTER: {
vbegin = (size.y - (lines_visible * font_h - line_spacing)) / 2;
vbegin = (size.y - (total_h - line_spacing)) / 2;
vsep = 0;

} break;
case VALIGN_BOTTOM: {
vbegin = size.y - (lines_visible * font_h - line_spacing);
vbegin = size.y - (total_h - line_spacing);
vsep = 0;

} break;
case VALIGN_FILL: {
vbegin = 0;
if (lines_visible > 1) {
vsep = (size.y - (lines_visible * font_h - line_spacing)) / (lines_visible - 1);
vsep = (size.y - (total_h - line_spacing)) / (lines_visible - 1);
} else {
vsep = 0;
}
Expand Down

0 comments on commit 50790a5

Please sign in to comment.