소스 검색

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