Forráskód Böngészése

Fix merge errors and bugs.

BDisp 2 éve
szülő
commit
4745eb51ad

+ 1 - 2
Terminal.Gui/Core/Application.cs

@@ -1230,7 +1230,7 @@ namespace Terminal.Gui {
 			firstIteration = false;
 
 			if (state.Toplevel != Top
-				&& (!Top.NeedDisplay.IsEmpty || Top.ChildNeedsDisplay || Top.LayoutNeeded)) {
+				&& (!Top._needsDisplay.IsEmpty || Top._childNeedsDisplay || Top.LayoutNeeded)) {
 				state.Toplevel.SetNeedsDisplay (state.Toplevel.Bounds);
 				Top.Redraw (Top.Bounds);
 				foreach (var top in toplevels.Reverse ()) {
@@ -1252,7 +1252,6 @@ namespace Terminal.Gui {
 			if (!state.Toplevel._needsDisplay.IsEmpty || state.Toplevel._childNeedsDisplay || state.Toplevel.LayoutNeeded
 				|| MdiChildNeedsDisplay ()) {
 				state.Toplevel.Redraw (state.Toplevel.Bounds);
-				state.Toplevel.OnDrawContentComplete (state.Toplevel.Bounds);
 				if (DebugDrawBounds) {
 					DrawBounds (state.Toplevel);
 				}

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

@@ -1038,7 +1038,7 @@ namespace Terminal.Gui {
 				// BUGBUG: v2 - ? - If layoutstyle is absolute, this overwrites the current frame h/w with 0. Hmmm...
 				frame = new Rect (new Point (actX, actY), new Size (w, h)); // Set frame, not Frame!
 
-	
+
 			}
 			//// BUGBUG: I think these calls are redundant or should be moved into just the AutoSize case
 			if (IsInitialized || LayoutStyle == LayoutStyle.Absolute) {
@@ -1047,7 +1047,7 @@ namespace Terminal.Gui {
 				SetMinWidthHeight ();
 				SetNeedsLayout ();
 				SetNeedsDisplay ();
-			}               
+			}
 		}
 
 		void TextFormatter_HotKeyChanged (object sender, KeyChangedEventArgs e)
@@ -1139,12 +1139,12 @@ namespace Terminal.Gui {
 		/// </summary>
 		public void SetSubViewNeedsDisplay ()
 		{
-			if (ChildNeedsDisplay) {
+			if (_childNeedsDisplay) {
 				return;
 			}
-			ChildNeedsDisplay = true;
-			if (container != null && !container.ChildNeedsDisplay)
-				container.SetSubViewNeedsDisplay ();
+			_childNeedsDisplay = true;
+			if (_superView != null && !_superView._childNeedsDisplay)
+				_superView.SetSubViewNeedsDisplay ();
 		}
 
 		internal bool addingView;
@@ -1493,7 +1493,7 @@ namespace Terminal.Gui {
 		/// <param name="region">View-relative region for the frame to be drawn.</param>
 		/// <param name="padding">The padding to add around the outside of the drawn frame.</param>
 		/// <param name="fill">If set to <see langword="true"/> it fill will the contents.</param>
-		[ObsoleteAttribute ("This method is obsolete in v2. Use use LineCanvas or Frame instead instead.", false)]
+		[ObsoleteAttribute ("This method is obsolete in v2. Use use LineCanvas or Frame instead.", false)]
 		public void DrawFrame (Rect region, int padding = 0, bool fill = false)
 		{
 			var scrRect = ViewToScreen (region);
@@ -1726,7 +1726,7 @@ namespace Terminal.Gui {
 		}
 
 		/// <summary>
-		/// Removes the <see cref="NeedDisplay"/> and the <see cref="ChildNeedsDisplay"/> setting on this view.
+		/// Removes the <see cref="_needsDisplay"/> and the <see cref="_childNeedsDisplay"/> setting on this view.
 		/// </summary>
 		protected void ClearNeedsDisplay ()
 		{
@@ -3505,12 +3505,11 @@ namespace Terminal.Gui {
 				resy = 0;
 				return null;
 			}
-
 			if (start.InternalSubviews != null) {
 				int count = start.InternalSubviews.Count;
 				if (count > 0) {
-					var rx = x - startFrame.X;
-					var ry = y - startFrame.Y;
+					var rx = x - (startFrame.X + start.GetBoundsOffset ().X);
+					var ry = y - (startFrame.Y + start.GetBoundsOffset ().Y);
 					for (int i = count - 1; i >= 0; i--) {
 						View v = start.InternalSubviews [i];
 						if (v.Visible && v.Frame.Contains (rx, ry)) {

+ 12 - 1
Terminal.Gui/Views/Menu.cs

@@ -542,6 +542,9 @@ namespace Terminal.Gui {
 			if (barItems.Children == null) {
 				return;
 			}
+			var savedClip = Driver.Clip;
+			Application.Driver.Clip = Application.Top.Frame;
+
 			Driver.SetAttribute (GetNormalColor ());
 			DrawFrame (Bounds, padding: 0, fill: true);
 
@@ -640,6 +643,8 @@ namespace Terminal.Gui {
 					}
 				}
 			}
+			Driver.Clip = savedClip;
+
 			PositionCursor ();
 		}
 
@@ -1372,7 +1377,13 @@ namespace Terminal.Gui {
 				// menu it belongs to's text
 				for (int i = 0; i < index; i++)
 					pos += Menus [i].TitleLength + (Menus [i].Help.ConsoleWidth > 0 ? Menus [i].Help.ConsoleWidth + 2 : 0) + leftPadding + rightPadding;
-				var locationOffset = SuperView == null ? new Point (0, 0) : new Point (SuperView.Frame.X, SuperView.Frame.Y);
+				var superView = SuperView == null ? Application.Top : SuperView;
+				Point locationOffset;
+				if (superView.Border != null && superView.Border.BorderStyle != BorderStyle.None) {
+					locationOffset = new Point (superView.Frame.X + 1, superView.Frame.Y + 1);
+				} else {
+					locationOffset = new Point (superView.Frame.X, superView.Frame.Y);
+				}
 				openMenu = new Menu (this, Frame.X + pos + locationOffset.X, Frame.Y + 1 + locationOffset.Y, Menus [index]);
 				openCurrentMenu = openMenu;
 				openCurrentMenu.previousSubFocused = openMenu;

+ 18 - 9
UnitTests/TopLevels/ToplevelTests.cs

@@ -1385,14 +1385,14 @@ namespace Terminal.Gui.TopLevelTests {
 		public void Draw_A_Top_Subview_On_A_Dialog ()
 		{
 			var top = Application.Top;
-			var win = new Window ("Window");
+			var win = new Window ();
 			top.Add (win);
 			Application.Begin (top);
 			((FakeDriver)Application.Driver).SetBufferSize (20, 20);
 
 			Assert.Equal (new Rect (0, 0, 20, 20), win.Frame);
 			TestHelpers.AssertDriverContentsWithFrameAre (@"
-┌ Window ──────────┐
+┌──────────────────┐
 │                  │
 │                  │
 │                  │
@@ -1416,7 +1416,13 @@ namespace Terminal.Gui.TopLevelTests {
 			var btnPopup = new Button ("Popup");
 			btnPopup.Clicked += (s, e) => {
 				var viewToScreen = btnPopup.ViewToScreen (top.Frame);
-				var view = new View () { X = 1, Y = viewToScreen.Y + 1, Width = 18, Height = 5 };
+				var view = new View () {
+					X = 1,
+					Y = viewToScreen.Y + 1,
+					Width = 18,
+					Height = 5,
+					Border = new Border () { BorderStyle = BorderStyle.Single }
+				};
 				Application.Current.DrawContentComplete += Current_DrawContentComplete;
 				top.Add (view);
 
@@ -1424,28 +1430,31 @@ namespace Terminal.Gui.TopLevelTests {
 				{
 					Assert.Equal (new Rect (1, 14, 18, 5), view.Frame);
 
-					top.DrawFrame (view.Frame);
+					var savedClip = Application.Driver.Clip;
+					Application.Driver.Clip = top.Frame;
+					view.Redraw (view.Bounds);
 					top.Move (2, 15);
 					View.Driver.AddStr ("One");
 					top.Move (2, 16);
 					View.Driver.AddStr ("Two");
 					top.Move (2, 17);
 					View.Driver.AddStr ("Three");
+					Application.Driver.Clip = savedClip;
 
 					Application.Current.DrawContentComplete -= Current_DrawContentComplete;
 				}
 			};
-			var dialog = new Dialog ("Dialog", 15, 10, btnPopup);
+			var dialog = new Dialog ("", 15, 10, btnPopup);
 			var rs = Application.Begin (dialog);
 
 			Assert.Equal (new Rect (2, 5, 15, 10), dialog.Frame);
 			TestHelpers.AssertDriverContentsWithFrameAre (@"
-┌ Window ──────────┐
+┌──────────────────┐
 │                  │
 │                  │
 │                  │
 │                  │
-│ ┌ Dialog ─────┐  │
+│ ┌─────────────┐  │
 │ │             │  │
 │ │             │  │
 │ │             │  │
@@ -1473,12 +1482,12 @@ namespace Terminal.Gui.TopLevelTests {
 			var firstIteration = false;
 			Application.RunMainLoopIteration (ref rs, true, ref firstIteration);
 			TestHelpers.AssertDriverContentsWithFrameAre (@"
-┌ Window ──────────┐
+┌──────────────────┐
 │                  │
 │                  │
 │                  │
 │                  │
-│ ┌ Dialog ─────┐  │
+│ ┌─────────────┐  │
 │ │             │  │
 │ │             │  │
 │ │             │  │