Browse Source

Fixed some bugs.

BDisp 4 năm trước cách đây
mục cha
commit
4fbb5be165
2 tập tin đã thay đổi với 29 bổ sung32 xóa
  1. 26 29
      Terminal.Gui/Views/ScrollBarView.cs
  2. 3 3
      UICatalog/Scenarios/Editor.cs

+ 26 - 29
Terminal.Gui/Views/ScrollBarView.cs

@@ -29,7 +29,7 @@ namespace Terminal.Gui {
 		bool autoHideScrollBars = true;
 		Dim originalHostWidth, originalHostHeight;
 		bool hosted;
-		bool showBothScrollIndicator => OtherScrollBarView != null && OtherScrollBarView.showScrollIndicator;
+		bool showBothScrollIndicator => OtherScrollBarView != null && OtherScrollBarView.showScrollIndicator && showScrollIndicator;
 
 		/// <summary>
 		/// Initializes a new instance of the <see cref="Gui.ScrollBarView"/> class using <see cref="LayoutStyle.Absolute"/> layout.
@@ -256,38 +256,35 @@ namespace Terminal.Gui {
 				return;
 			}
 
-			if (vertical) {
-				if (Host.Bounds.Height == 0 || Host.Bounds.Height > size) {
-					if (showScrollIndicator) {
-						ShowScrollIndicator = false;
-					}
-				} else if (Host.Bounds.Height > 0 && Host.Bounds.Height == size) {
-					pending = true;
-				} else if (!showScrollIndicator) {
-					ShowScrollIndicator = true;
+			int barsize = vertical ? Bounds.Height : Bounds.Width;
+
+			if (barsize == 0 || barsize > size) {
+				if (showScrollIndicator) {
+					ShowScrollIndicator = false;
+				}
+			} else if (barsize > 0 && barsize == size && OtherScrollBarView != null && OtherScrollBarView.pending) {
+				if (showScrollIndicator) {
+					ShowScrollIndicator = false;
 				}
+				if (OtherScrollBarView != null && showBothScrollIndicator) {
+					OtherScrollBarView.ShowScrollIndicator = false;
+				}
+			} else if (barsize > 0 && barsize == size && OtherScrollBarView != null && !OtherScrollBarView.pending) {
+				pending = true;
+				OtherScrollBarView.Redraw (OtherScrollBarView.Bounds);
 			} else {
-				if (Host.Bounds.Width == 0 || Host.Bounds.Width > size) {
-					if (showScrollIndicator) {
-						ShowScrollIndicator = false;
-					}
-				} else if (Host.Bounds.Width > 0 && Host.Bounds.Width == size && OtherScrollBarView.pending) {
-					if (showScrollIndicator) {
-						ShowScrollIndicator = false;
-					}
-					if (showBothScrollIndicator) {
-						OtherScrollBarView.showScrollIndicator = false;
-					}
-				} else {
-					if (OtherScrollBarView.pending) {
-						if (!showBothScrollIndicator) {
-							OtherScrollBarView.showScrollIndicator = true;
-						}
-					}
-					if (!showScrollIndicator) {
-						ShowScrollIndicator = true;
+				if (OtherScrollBarView != null && OtherScrollBarView.pending) {
+					if (!showBothScrollIndicator) {
+						OtherScrollBarView.ShowScrollIndicator = true;
+						OtherScrollBarView.Redraw (OtherScrollBarView.Bounds);
 					}
 				}
+				if (!showScrollIndicator) {
+					ShowScrollIndicator = true;
+				}
+			}
+			if (OtherScrollBarView != null) {
+				OtherScrollBarView.pending = false;
 			}
 		}
 

+ 3 - 3
UICatalog/Scenarios/Editor.cs

@@ -94,7 +94,7 @@ namespace UICatalog {
 			_textView.DrawContent += (e) => {
 				_vertical.Size = _textView.Lines - 1;
 				_vertical.ContentOffset = _textView.TopRow;
-				horizontal.Size = _textView.Maxlength - 1;
+				horizontal.Size = _textView.Maxlength;
 				horizontal.ContentOffset = _textView.LeftColumn;
 				_vertical.ColorScheme = horizontal.ColorScheme = _textView.ColorScheme;
 				if (_vertical.ShowScrollIndicator) {
@@ -182,8 +182,8 @@ namespace UICatalog {
 			sb.Append ("Hello world.\n");
 			sb.Append ("This is a test of the Emergency Broadcast System.\n");
 
-			for (int i = 0; i < 40; i++) {
-				sb.Append ("This is a test with a very long line and many lines to test the ScrollViewBar against the TextView.\n");
+			for (int i = 0; i < 30; i++) {
+				sb.Append ($"{i} - This is a test with a very long line and many lines to test the ScrollViewBar against the TextView. - {i}\n");
 			}
 			var sw = System.IO.File.CreateText (fileName);
 			sw.Write (sb.ToString ());