Browse Source

Merge pull request #50478 from KoBeWi/xalign

[3.x] Fix valign with stylebox borders
Rémi Verschelde 4 years ago
parent
commit
50790a5893
1 changed files with 7 additions and 3 deletions
  1. 7 3
      scene/gui/label.cpp

+ 7 - 3
scene/gui/label.cpp

@@ -118,25 +118,29 @@ void Label::_notification(int p_what) {
 			lines_visible = max_lines_visible;
 			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) {
 		if (lines_visible > 0) {
 			switch (valign) {
 			switch (valign) {
 				case VALIGN_TOP: {
 				case VALIGN_TOP: {
 					//nothing
 					//nothing
 				} break;
 				} break;
 				case VALIGN_CENTER: {
 				case VALIGN_CENTER: {
-					vbegin = (size.y - (lines_visible * font_h - line_spacing)) / 2;
+					vbegin = (size.y - (total_h - line_spacing)) / 2;
 					vsep = 0;
 					vsep = 0;
 
 
 				} break;
 				} break;
 				case VALIGN_BOTTOM: {
 				case VALIGN_BOTTOM: {
-					vbegin = size.y - (lines_visible * font_h - line_spacing);
+					vbegin = size.y - (total_h - line_spacing);
 					vsep = 0;
 					vsep = 0;
 
 
 				} break;
 				} break;
 				case VALIGN_FILL: {
 				case VALIGN_FILL: {
 					vbegin = 0;
 					vbegin = 0;
 					if (lines_visible > 1) {
 					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 {
 					} else {
 						vsep = 0;
 						vsep = 0;
 					}
 					}