浏览代码

Fixed a bug with multiline labels not calculating their bounds correctly (#141)

* Fixed a bug with multiline labels not calculating their bounds correctly

* Second part of multiline label fix, include the last line in the lines list in Recalc
HLFrye 6 年之前
父节点
当前提交
1bad3994c0
共有 1 个文件被更改,包括 6 次插入2 次删除
  1. 6 2
      Terminal.Gui/Views/Label.cs

+ 6 - 2
Terminal.Gui/Views/Label.cs

@@ -57,7 +57,10 @@ namespace Terminal.Gui {
 				} else
 					cols++;
 			}
-			return new Rect (x, y, cols, ml);
+			if (cols > mw)
+				mw = cols;
+
+			return new Rect (x, y, mw, ml);
 		}
 
 		/// <summary>
@@ -154,6 +157,7 @@ namespace Terminal.Gui {
 					lp = i + 1;
 				}
 			}
+			lineResult.Add(ClipAndJustify(textStr[lp, textLen], width, talign));
 		}
 
 		public override void Redraw (Rect region)
@@ -169,7 +173,7 @@ namespace Terminal.Gui {
 			Clear ();
 			Move (Frame.X, Frame.Y);
 			for (int line = 0; line < lines.Count; line++) {
-				if (line < region.Top || line >= region.Bottom)
+				if (line < region.Top || line > region.Bottom)
 					continue;
 				var str = lines [line];
 				int x;