Browse Source

Merge branch 'master' of https://github.com/migueldeicaza/gui.cs into combobox_fixes

Ross Ferguson 5 years ago
parent
commit
d7de041275

+ 1 - 10
Terminal.Gui/Core/View.cs

@@ -984,15 +984,10 @@ namespace Terminal.Gui {
 								view.LayoutSubviews ();
 							Application.CurrentView = view;
 
-							// Clip the sub-view
-							var savedClip = view.ClipToBounds ();
-
 							// Draw the subview
 							// Use the view's bounds (view-relative; Location will always be (0,0) because
 							view.Redraw (view.Bounds);
 
-							// Undo the clip
-							Driver.Clip = savedClip;
 						}
 						view.NeedDisplay = Rect.Empty;
 						view.childNeedsDisplay = false;
@@ -1591,11 +1586,7 @@ namespace Terminal.Gui {
 						}
 					}
 					if (c_hot_pos > -1) {
-						if (wLen - runeCount == 0) {
-							c_hot_pos += (wLen - runeCount == 0 ? w_hot_pos * (space) - space - w_hot_pos + 1 : space + wLen - runeCount);
-						} else {
-							c_hot_pos += space + wLen - runeCount;
-						}
+						c_hot_pos += w_hot_pos * space - space - w_hot_pos + 1;
 					}
 					break;
 				}

+ 38 - 15
Terminal.Gui/Views/ScrollView.cs

@@ -159,24 +159,36 @@ namespace Terminal.Gui {
 					Driver.AddRune (Driver.UpArrow);
 					Move (col, Bounds.Height - 1);
 					Driver.AddRune (Driver.DownArrow);
+
+					bool hasTopTee = false;
+					bool hasDiamond = false;
+					bool hasBottomTee = false;
 					for (int y = 0; y < bh; y++) {
 						Move (col, y + 1);
-						if (y < by1 - 1 || y > by2)
+						if ((y < by1 || y > by2) && ((position > 0 && !hasTopTee) || (hasTopTee && hasBottomTee))) {
 							special = Driver.Stipple;
-						else {
-							if (by2 - by1 == 0 && by1 < bh - 1)
+						} else {
+							if (y != by2 && y > 1 && by2 - by1 == 0 && by1 < bh - 1 && hasTopTee && !hasDiamond) {
+								hasDiamond = true;
 								special = Driver.Diamond;
-							else {
-								if (y == by1 - 1)
+							} else {
+								if (y == by1 && !hasTopTee) {
+									hasTopTee = true;
 									special = Driver.TopTee;
-								else if (y == by2)
+								} else if ((y >= by2 || by2 == 0) && !hasBottomTee) {
+									hasBottomTee = true;
 									special = Driver.BottomTee;
-								else
+								} else {
 									special = Driver.VLine;
+								}
 							}
 						}
 						Driver.AddRune (special);
 					}
+					if (!hasTopTee) {
+						Move (col, Bounds.Height - 2);
+						Driver.AddRune (Driver.TopTee);
+					}
 				}
 			} else {
 				if (region.Bottom < Bounds.Height - 1)
@@ -206,24 +218,35 @@ namespace Terminal.Gui {
 					Move (0, row);
 					Driver.AddRune (Driver.LeftArrow);
 
+					bool hasLeftTee = false;
+					bool hasDiamond = false;
+					bool hasRightTee = false;
 					for (int x = 0; x < bw; x++) {
-
-						if (x < bx1 || x > bx2) {
+						if ((x < bx1 || x >= bx2 + 1) && ((position > 0 && !hasLeftTee) || (hasLeftTee && hasRightTee))) {
 							special = Driver.Stipple;
 						} else {
-							if (bx2 - bx1 == 0)
+							if (x != bx2 && x > 1 && bx2 - bx1 == 0 && bx1 < bw - 1 && hasLeftTee && !hasDiamond) {
+								hasDiamond = true;
 								special = Driver.Diamond;
-							else {
-								if (x == bx1)
+							} else {
+								if (x == bx1 && !hasLeftTee) {
+									hasLeftTee = true;
 									special = Driver.LeftTee;
-								else if (x == bx2)
+								} else if ((x >= bx2 || bx2 == 0) && !hasRightTee) {
+									hasRightTee = true;
 									special = Driver.RightTee;
-								else
+								} else {
 									special = Driver.HLine;
+								}
 							}
 						}
 						Driver.AddRune (special);
 					}
+					if (!hasLeftTee) {
+						Move (Bounds.Width -2, row);
+						Driver.AddRune (Driver.LeftTee);
+					}
+
 					Driver.AddRune (Driver.RightArrow);
 				}
 			}
@@ -250,7 +273,7 @@ namespace Terminal.Gui {
 					if (pos > 0)
 						SetPosition (pos - 1);
 				} else if (location == barsize + 1) {
-					if (pos + 1 + barsize < Size)
+					if (pos + 1 <= Size + 2)
 						SetPosition (pos + 1);
 				} else {
 					var b1 = pos * barsize / Size;

+ 13 - 5
UICatalog/Scenarios/Buttons.cs

@@ -54,18 +54,25 @@ namespace UICatalog {
 			};
 			Win.Add (colorButtonsLabel);
 
-			View prev = colorButtonsLabel;
+			//View prev = colorButtonsLabel;
+
+			//With this method there is no need to call Top.Ready += () => Top.Redraw (Top.Bounds);
+			var x = Pos.Right (colorButtonsLabel) + 2;
 			foreach (var colorScheme in Colors.ColorSchemes) {
 				var colorButton = new Button ($"{colorScheme.Key}") {
 					ColorScheme = colorScheme.Value,
-					X = Pos.Right (prev) + 2,
+					//X = Pos.Right (prev) + 2,
+					X = x,
 					Y = Pos.Y (colorButtonsLabel),
 				};
 				DoMessage (colorButton, colorButton.Text);
 				Win.Add (colorButton);
-				prev = colorButton;
+				//prev = colorButton;
+				x += colorButton.Frame.Width + 2;
 			}
 			// BUGBUG: For some reason these buttons don't move to correct locations initially. 
+			// This was the only way I find to resolves this with the View prev variable.
+			//Top.Ready += () => Top.Redraw (Top.Bounds);
 
 			Button button;
 			Win.Add (button = new Button ("A super long _Button that will probably expose a bug in clipping or wrapping of text. Will it?") {
@@ -119,7 +126,8 @@ namespace UICatalog {
 			};
 			moveBtn.Clicked = () => {
 				moveBtn.X = moveBtn.Frame.X + 5;
-				computedFrame.LayoutSubviews (); // BUGBUG: This call should not be needed. View.X is not causing relayout correctly
+				// This is already fixed with the call to SetNeedDisplay() in the Pos Dim.
+				//computedFrame.LayoutSubviews (); // BUGBUG: This call should not be needed. View.X is not causing relayout correctly
 			};
 			computedFrame.Add (moveBtn);
 
@@ -212,7 +220,7 @@ namespace UICatalog {
 
 			var muhkb = " ~  s  gui.cs   master ↑10 = Сохранить";
 			var moveUnicodeHotKeyBtn = new Button (muhkb) {
-				X = Pos.Right (moveHotKeyBtn) + 6,
+				X = Pos.Left (absoluteFrame) + 1,
 				Y = Pos.Bottom (radioGroup) + 1,
 				Width = muhkb.Length + 30,
 				ColorScheme = Colors.TopLevel,

+ 1 - 1
UICatalog/Scenarios/Scrolling.cs

@@ -214,7 +214,7 @@ namespace UICatalog {
 
 			int count = 0;
 			var mousePos = new Label ("Mouse: ");
-			mousePos.X = Pos.Center ();
+			mousePos.X = Pos.Right(scrollView) + 1;
 			mousePos.Y = Pos.AnchorEnd (1);
 			mousePos.Width = 50;
 			Application.RootMouseEvent += delegate (MouseEvent me) {

+ 14 - 14
UICatalog/UICatalog.cs

@@ -46,10 +46,10 @@ namespace UICatalog {
 		private static Toplevel _top;
 		private static MenuBar _menu;
 		private static int _nameColumnWidth;
-		private static Window _leftPane;
+		private static FrameView _leftPane;
 		private static List<string> _categories;
 		private static ListView _categoryListView;
-		private static Window _rightPane;
+		private static FrameView _rightPane;
 		private static List<Type> _scenarios;
 		private static ListView _scenarioListView;
 		private static StatusBar _statusBar;
@@ -212,11 +212,11 @@ namespace UICatalog {
 				new MenuBarItem ("_About...", "About this app", () =>  MessageBox.Query ("About UI Catalog", aboutMessage.ToString(), "Ok")),
 			});
 
-			_leftPane = new Window ("Categories") {
+			_leftPane = new FrameView ("Categories") {
 				X = 0,
 				Y = 1, // for menu
 				Width = 25,
-				Height = Dim.Fill (),
+				Height = Dim.Fill (1),
 				CanFocus = false,
 			};
 
@@ -236,12 +236,12 @@ namespace UICatalog {
 			_categoryListView.SelectedItemChanged += CategoryListView_SelectedChanged;
 			_leftPane.Add (_categoryListView);
 
-			_rightPane = new Window ("Scenarios") {
+			_rightPane = new FrameView ("Scenarios") {
 				X = 25,
 				Y = 1, // for menu
 				Width = Dim.Fill (),
-				Height = Dim.Fill (),
-				CanFocus = false,
+				Height = Dim.Fill (1),
+				CanFocus = true,
 
 			};
 
@@ -348,13 +348,13 @@ namespace UICatalog {
 		/// <param name="ke"></param>
 		private static void KeyDownHandler (View.KeyEventEventArgs a)
 		{
-			if (a.KeyEvent.Key == Key.Tab || a.KeyEvent.Key == Key.BackTab) {
-				// BUGBUG: Work around Issue #434 by implementing our own TAB navigation
-				if (_top.MostFocused == _categoryListView)
-					_top.SetFocus (_rightPane);
-				else
-					_top.SetFocus (_leftPane);
-			}
+			//if (a.KeyEvent.Key == Key.Tab || a.KeyEvent.Key == Key.BackTab) {
+			//	// BUGBUG: Work around Issue #434 by implementing our own TAB navigation
+			//	if (_top.MostFocused == _categoryListView)
+			//		_top.SetFocus (_rightPane);
+			//	else
+			//		_top.SetFocus (_leftPane);
+			//}
 
 			if (a.KeyEvent.IsCapslock) {
 				_capslock.Title = "Capslock: On";