IDisplayView, render statistics
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
using PropertyChanged.SourceGenerator;
|
||||
using PropertyChanged.SourceGenerator;
|
||||
using TerminalUI.Models;
|
||||
using TerminalUI.Traits;
|
||||
|
||||
namespace TerminalUI.Controls;
|
||||
|
||||
public partial class Border<T> : ContentView<T>
|
||||
public partial class Border<T> : ContentView<T>, IDisplayView
|
||||
{
|
||||
[Notify] private Thickness _borderThickness = 1;
|
||||
[Notify] private Thickness _padding = 0;
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
using PropertyChanged.SourceGenerator;
|
||||
using TerminalUI.Color;
|
||||
using TerminalUI.Models;
|
||||
using TerminalUI.Traits;
|
||||
|
||||
namespace TerminalUI.Controls;
|
||||
|
||||
public partial class Rectangle<T> : View<T>
|
||||
public partial class Rectangle<T> : View<T>, IDisplayView
|
||||
{
|
||||
private record RenderState(
|
||||
Position Position,
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using PropertyChanged.SourceGenerator;
|
||||
using TerminalUI.Color;
|
||||
using TerminalUI.Extensions;
|
||||
using TerminalUI.Models;
|
||||
using TerminalUI.Traits;
|
||||
|
||||
namespace TerminalUI.Controls;
|
||||
|
||||
[DebuggerDisplay("Text = {Text}")]
|
||||
public partial class TextBlock<T> : View<T>
|
||||
public partial class TextBlock<T> : View<T>, IDisplayView
|
||||
{
|
||||
private record RenderState(
|
||||
Position Position,
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System.Diagnostics;
|
||||
using GeneralInputKey;
|
||||
using PropertyChanged.SourceGenerator;
|
||||
using TerminalUI.Color;
|
||||
@@ -7,7 +8,8 @@ using TerminalUI.Traits;
|
||||
|
||||
namespace TerminalUI.Controls;
|
||||
|
||||
public partial class TextBox<T> : View<T>, IFocusable
|
||||
[DebuggerDisplay("Text = {Text}")]
|
||||
public partial class TextBox<T> : View<T>, IFocusable, IDisplayView
|
||||
{
|
||||
private record RenderState(
|
||||
string? Text,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System.Buffers;
|
||||
using System.Buffers;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.CompilerServices;
|
||||
@@ -6,6 +6,7 @@ using PropertyChanged.SourceGenerator;
|
||||
using TerminalUI.Color;
|
||||
using TerminalUI.ConsoleDrivers;
|
||||
using TerminalUI.Models;
|
||||
using TerminalUI.Traits;
|
||||
|
||||
namespace TerminalUI.Controls;
|
||||
|
||||
@@ -118,6 +119,7 @@ public abstract partial class View<T> : IView<T>
|
||||
|
||||
public bool Render(in RenderContext renderContext, Position position, Size size)
|
||||
{
|
||||
renderContext.Statistics.ProcessedViews++;
|
||||
if (!Attached)
|
||||
throw new InvalidOperationException("Cannot render unattached view");
|
||||
|
||||
@@ -149,7 +151,16 @@ public abstract partial class View<T> : IView<T>
|
||||
);
|
||||
}
|
||||
|
||||
return RenderMethod(renderContext, position, size);
|
||||
var renderResult = RenderMethod(renderContext, position, size);
|
||||
if (renderResult)
|
||||
{
|
||||
renderContext.Statistics.RenderedViews++;
|
||||
|
||||
if (this is IDisplayView)
|
||||
renderContext.Statistics.RenderedDisplayViews++;
|
||||
}
|
||||
|
||||
return renderResult;
|
||||
}
|
||||
|
||||
protected void RenderEmpty(in RenderContext renderContext, Position position, Size size)
|
||||
|
||||
Reference in New Issue
Block a user