WIP of new overlapped drawing

This commit is contained in:
Tig
2024-09-17 17:49:41 -06:00
parent b717892235
commit 78a3dffea9
4 changed files with 38 additions and 72 deletions

View File

@@ -461,10 +461,8 @@ public static partial class Application // Run (Begin, Run, End, Stop)
{
v.LayoutSubviews ();
}
if (v.Visible)
if (v.Visible && (v.NeedsDisplay || v.SubViewNeedsDisplay))
{
v.SetNeedsDisplay ();
v.SetSubViewNeedsDisplay ();
v.Draw ();
}
}
@@ -622,9 +620,9 @@ public static partial class Application // Run (Begin, Run, End, Stop)
if (TopLevels.Count > 0)
{
Top = TopLevels.Peek ();
Top.SetNeedsDisplay ();
}
// BUGBUG: We should not call OnEnter/OnLeave directly; they should only be called by SetHasFocus
if (runState.Toplevel is { HasFocus: true })
{
runState.Toplevel.HasFocus = false;
@@ -635,8 +633,6 @@ public static partial class Application // Run (Begin, Run, End, Stop)
Top.SetFocus ();
}
//Refresh ();
_cachedRunStateToplevel = runState.Toplevel;
runState.Toplevel = null;

View File

@@ -478,7 +478,7 @@ public partial class View // Drawing APIs
return;
}
if (SuperView is { })
if (SuperView is { } || this == Application.Top)
{
Clear ();
}

View File

@@ -768,8 +768,17 @@ public partial class View // Layout APIs
LayoutAdornments ();
}
SetNeedsDisplay ();
SetNeedsLayout ();
SetNeedsDisplay ();
foreach (Toplevel v in Application.TopLevels)
{
if (v.Visible && (v != this))
{
v.SetNeedsDisplay ();
}
}
}
internal bool LayoutNeeded { get; private set; } = true;

View File

@@ -245,35 +245,35 @@ public partial class Toplevel : View
#region Draw
/// <inheritdoc/>
public override void OnDrawContent (Rectangle viewport)
{
if (!Visible)
{
return;
}
///// <inheritdoc/>
//public override void OnDrawContent (Rectangle viewport)
//{
// if (!Visible)
// {
// return;
// }
if (NeedsDisplay || SubViewNeedsDisplay /*|| LayoutNeeded*/)
{
Clear ();
// if (NeedsDisplay || SubViewNeedsDisplay /*|| LayoutNeeded*/)
// {
// Clear ();
//LayoutSubviews ();
//PositionToplevels ();
// //LayoutSubviews ();
// //PositionToplevels ();
// BUGBUG: This appears to be a hack to get ScrollBarViews to render correctly.
foreach (View view in Subviews)
{
if (view.Frame.IntersectsWith (Viewport) && !OutsideTopFrame (this))
{
//view.SetNeedsLayout ();
view.SetNeedsDisplay ();
view.SetSubViewNeedsDisplay ();
}
}
// // BUGBUG: This appears to be a hack to get ScrollBarViews to render correctly.
// foreach (View view in Subviews)
// {
// if (view.Frame.IntersectsWith (Viewport) && !OutsideTopFrame (this))
// {
// //view.SetNeedsLayout ();
// view.SetNeedsDisplay ();
// view.SetSubViewNeedsDisplay ();
// }
// }
base.OnDrawContent (viewport);
}
}
// base.OnDrawContent (viewport);
// }
//}
#endregion
@@ -443,42 +443,3 @@ public class ToplevelEqualityComparer : IEqualityComparer<Toplevel>
return hCode.GetHashCode ();
}
}
/// <summary>
/// Implements the <see cref="IComparer{T}"/> to sort the <see cref="Toplevel"/> from the
/// <see cref="ApplicationOverlapped.OverlappedChildren"/> if needed.
/// </summary>
public sealed class ToplevelComparer : IComparer<Toplevel>
{
/// <summary>
/// Compares two objects and returns a value indicating whether one is less than, equal to, or greater than the
/// other.
/// </summary>
/// <param name="x">The first object to compare.</param>
/// <param name="y">The second object to compare.</param>
/// <returns>
/// A signed integer that indicates the relative values of <paramref name="x"/> and <paramref name="y"/>, as shown
/// in the following table.Value Meaning Less than zero <paramref name="x"/> is less than <paramref name="y"/>.Zero
/// <paramref name="x"/> equals <paramref name="y"/> .Greater than zero <paramref name="x"/> is greater than
/// <paramref name="y"/>.
/// </returns>
public int Compare (Toplevel? x, Toplevel? y)
{
if (ReferenceEquals (x, y))
{
return 0;
}
if (x is null)
{
return -1;
}
if (y is null)
{
return 1;
}
return string.CompareOrdinal (x.Id, y.Id);
}
}