From 5ab424ce892c3b309fde8b48716ce111e44f4db4 Mon Sep 17 00:00:00 2001 From: Tig Date: Thu, 29 Aug 2024 18:07:36 -0600 Subject: [PATCH] Initial commit. Fixed z-order --- Terminal.Gui/View/View.Drawing.cs | 66 +++++++++++----------------- Terminal.Gui/View/View.Navigation.cs | 2 +- 2 files changed, 27 insertions(+), 41 deletions(-) diff --git a/Terminal.Gui/View/View.Drawing.cs b/Terminal.Gui/View/View.Drawing.cs index 9762ba98b..c076839cf 100644 --- a/Terminal.Gui/View/View.Drawing.cs +++ b/Terminal.Gui/View/View.Drawing.cs @@ -1,6 +1,4 @@ -using System.Drawing; - -namespace Terminal.Gui; +namespace Terminal.Gui; public partial class View // Drawing APIs { @@ -56,7 +54,7 @@ public partial class View // Drawing APIs public bool SubViewNeedsDisplay { get; private set; } /// - /// Gets or sets whether this View will use it's SuperView's for rendering any + /// Gets or sets whether this View will use it's SuperView's for rendering any /// lines. If the rendering of any borders drawn by this Frame will be done by its parent's /// SuperView. If (the default) this View's method will be /// called to render the borders. @@ -86,7 +84,8 @@ public partial class View // Drawing APIs /// /// If has only /// the portion of the content - /// area that is visible within the will be cleared. This is useful for views that have a + /// area that is visible within the will be cleared. This is useful for views that have + /// a /// content area larger than the Viewport (e.g. when is /// enabled) and want /// the area outside the content to be visually distinct. @@ -143,15 +142,15 @@ public partial class View // Drawing APIs /// Sets the 's clip region to . /// - /// - /// By default, the clip rectangle is set to the intersection of the current clip region and the - /// . This ensures that drawing is constrained to the viewport, but allows - /// content to be drawn beyond the viewport. - /// - /// - /// If has set, clipping will be - /// applied to just the visible content area. - /// + /// + /// By default, the clip rectangle is set to the intersection of the current clip region and the + /// . This ensures that drawing is constrained to the viewport, but allows + /// content to be drawn beyond the viewport. + /// + /// + /// If has set, clipping will be + /// applied to just the visible content area. + /// /// /// /// The current screen-relative clip region, which can be then re-applied by setting @@ -336,6 +335,7 @@ public partial class View // Drawing APIs public virtual Attribute GetFocusColor () { ColorScheme cs = ColorScheme; + if (cs is null) { cs = new (); @@ -403,7 +403,7 @@ public partial class View // Drawing APIs return false; } - var screen = ViewportToScreen (new Point (col, row)); + Point screen = ViewportToScreen (new Point (col, row)); Driver?.Move (screen.X, screen.Y); return true; @@ -442,12 +442,14 @@ public partial class View // Drawing APIs /// /// /// The Location and Size indicate what part of the View's content, defined - /// by , is visible and should be drawn. The coordinates taken by and + /// by , is visible and should be drawn. The coordinates taken by + /// and /// are relative to , thus if ViewPort.Location.Y is 5 /// the 6th row of the content should be drawn using MoveTo (x, 5). /// /// - /// If is larger than ViewPort.Size drawing code should use + /// If is larger than ViewPort.Size drawing code should use + /// /// to constrain drawing for better performance. /// /// @@ -503,24 +505,13 @@ public partial class View // Drawing APIs // TODO: Implement OnDrawSubviews (cancelable); if (_subviews is { } && SubViewNeedsDisplay) { - IEnumerable subviewsNeedingDraw; - if (TabStop == TabBehavior.TabGroup && _subviews.Count(v => v.Arrangement.HasFlag (ViewArrangement.Overlapped)) > 0) - { - // TODO: This is a temporary hack to make overlapped non-Toplevels have a zorder. See also View.SetFocus - subviewsNeedingDraw = _subviews.Where ( - view => view.Visible - && (view.NeedsDisplay || view.SubViewNeedsDisplay || view.LayoutNeeded) - ).Reverse (); + IEnumerable subviewsNeedingDraw = _subviews.Where ( + view => view.Visible + && (view.NeedsDisplay + || view.SubViewNeedsDisplay + || view.LayoutNeeded) + ); - } - else - { - subviewsNeedingDraw = _subviews.Where ( - view => view.Visible - && (view.NeedsDisplay || view.SubViewNeedsDisplay || view.LayoutNeeded) - ); - - } foreach (View view in subviewsNeedingDraw) { if (view.LayoutNeeded) @@ -608,10 +599,7 @@ public partial class View // Drawing APIs /// If the view has not been initialized ( is ), this method /// does nothing. /// - public void SetNeedsDisplay () - { - SetNeedsDisplay (Viewport); - } + public void SetNeedsDisplay () { SetNeedsDisplay (Viewport); } /// Expands the area of this view needing to be redrawn to include . /// @@ -671,8 +659,6 @@ public partial class View // Drawing APIs if (SuperView is { SubViewNeedsDisplay: false }) { SuperView.SetSubViewNeedsDisplay (); - - return; } } diff --git a/Terminal.Gui/View/View.Navigation.cs b/Terminal.Gui/View/View.Navigation.cs index ed8e2b844..200367c02 100644 --- a/Terminal.Gui/View/View.Navigation.cs +++ b/Terminal.Gui/View/View.Navigation.cs @@ -453,7 +453,7 @@ public partial class View // Focus and cross-view navigation management (TabStop if (Arrangement.HasFlag (ViewArrangement.Overlapped)) { - SuperView?.MoveSubviewToStart (this); + SuperView?.MoveSubviewToEnd (this); } NotifyFocusChanged (HasFocus, previousFocusedView, this);