Refactoring some names I don't like.

This commit is contained in:
H. Utku Maden 2024-07-28 12:34:22 +03:00
parent 92fb8f06a7
commit 3856b3c66e
21 changed files with 89 additions and 90 deletions

@ -1,11 +1,11 @@
using BlurgText;
using Dashboard.CommandMachine;
using Dashboard.ImmediateDraw;
namespace Dashboard.BlurgText
{
public static class BlurgCommand
{
public static void PutBlurgText(this CommandList list, DashboardBlurg blurg, BlurgResult result, QVec2 origin)
public static void PutBlurgText(this DrawList list, DashboardBlurg blurg, BlurgResult result, QVec2 origin)
{
for (int i = 0; i < result.Count; i++)
{

@ -2,7 +2,7 @@ using System;
using System.Collections.Generic;
using OpenTK.Windowing.Desktop;
using OpenTK.Windowing.GraphicsLibraryFramework;
using Dashboard.CommandMachine;
using Dashboard.ImmediateDraw;
using Dashboard.Media;
using Dashboard.OpenGL;
using Dashboard.PAL;
@ -86,7 +86,7 @@ namespace Dashboard.OpenTK
public void PortShow(IDashHandle port, bool shown = true) => ((OpenTKPort)port).Show(shown);
public void PortPaint(IDashHandle port, CommandList commands) => ((OpenTKPort)port).Paint(commands);
public void PortPaint(IDashHandle port, DrawList commands) => ((OpenTKPort)port).Paint(commands);
public void GetMaximumImage(out int width, out int height)
{

@ -2,7 +2,7 @@ using System;
using OpenTK.Mathematics;
using OpenTK.Windowing.Desktop;
using Dashboard.OpenGL;
using Dashboard.CommandMachine;
using Dashboard.ImmediateDraw;
using Dashboard.PAL;
using Dashboard.VertexGenerator;
@ -65,7 +65,7 @@ namespace Dashboard.OpenTK
_window.Focus();
}
public void Paint(CommandList queue)
public void Paint(DrawList queue)
{
QRectangle view = new QRectangle(Size, new QVec2(0, 0));

@ -1,12 +1,12 @@
using System;
using System.Collections.Generic;
using Dashboard.CommandMachine;
using Dashboard.ImmediateDraw;
namespace Dashboard.Controls
{
public abstract class Control : UIBase
{
private readonly CommandList drawCommands = new CommandList();
private readonly DrawList drawCommands = new DrawList();
public Style Style { get; set; } = new Style();
public float Padding
@ -43,10 +43,10 @@ namespace Dashboard.Controls
InvalidateLayout();
}
protected abstract void ValidateVisual(CommandList cmd);
protected abstract void ValidateVisual(DrawList cmd);
protected abstract void ValidateLayout();
protected override void PaintBegin(CommandList cmd)
protected override void PaintBegin(DrawList cmd)
{
base.PaintBegin(cmd);

@ -2,7 +2,7 @@ using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using Dashboard.CommandMachine;
using Dashboard.ImmediateDraw;
namespace Dashboard.Controls
{
@ -19,7 +19,7 @@ namespace Dashboard.Controls
ValidateChildrenLayout();
}
protected override void ValidateVisual(CommandList cmd)
protected override void ValidateVisual(DrawList cmd)
{
throw new NotImplementedException();
}

@ -1,4 +1,4 @@
using Dashboard.CommandMachine;
using Dashboard.ImmediateDraw;
using Dashboard.Media;
using Dashboard.Typography;
@ -20,7 +20,7 @@ namespace Dashboard.Controls
}
}
protected override void ValidateVisual(CommandList cmd)
protected override void ValidateVisual(DrawList cmd)
{
float padding = Padding;
QVec2 origin = new QVec2(padding, padding);

@ -1,6 +1,6 @@
using System;
using Dashboard.CommandMachine;
using Dashboard.ImmediateDraw;
namespace Dashboard.Controls
{
@ -62,19 +62,19 @@ namespace Dashboard.Controls
{
}
protected virtual void PaintBegin(CommandList cmd)
protected virtual void PaintBegin(DrawList cmd)
{
cmd.PushViewport();
cmd.StoreViewport(AbsoluteBounds);
cmd.PushZ();
}
protected virtual void PaintEnd(CommandList cmd)
protected virtual void PaintEnd(DrawList cmd)
{
cmd.PopViewport();
}
public void Paint(CommandList cmd)
public void Paint(DrawList cmd)
{
PaintBegin(cmd);
PaintEnd(cmd);

@ -1,7 +1,7 @@
using System;
using System.Collections.Generic;
using System.Threading;
using Dashboard.CommandMachine;
using Dashboard.ImmediateDraw;
using Dashboard.Controls;
using Dashboard.Media;
using Dashboard.PAL;
@ -86,7 +86,7 @@ namespace Dashboard
return disposable;
}
private CommandList cmd = new CommandList();
private DrawList cmd = new DrawList();
public void Run(View mainView, bool yield = true)
{

@ -1,4 +1,4 @@
namespace Dashboard.CommandMachine
namespace Dashboard.ImmediateDraw
{
/// <summary>
/// Enumeration of built-in Quik commands.

@ -1,8 +1,8 @@
namespace Dashboard.CommandMachine
namespace Dashboard.ImmediateDraw
{
/// <summary>
/// A delegate for a Dashboard engine command.
/// </summary>
/// <param name="stack">The current stack.</param>
public delegate void CommandHandler(CommandEngine state, CommandQueue queue);
public delegate void CommandHandler(DrawingEngine state, DrawQueue queue);
}

@ -1,9 +1,9 @@
using System;
using System.Collections.Generic;
namespace Dashboard.CommandMachine
namespace Dashboard.ImmediateDraw
{
public class CommandEngine
public class DrawingEngine
{
private int _zIndex = 0;
private readonly Stack<int> _zStack = new Stack<int>();
@ -22,7 +22,7 @@ namespace Dashboard.CommandMachine
public StyleStack Style { get; } = new StyleStack(new Style());
protected CommandEngine()
protected DrawingEngine()
{
Reset();
}
@ -34,9 +34,9 @@ namespace Dashboard.CommandMachine
return id;
}
public void ProcessCommands(QRectangle bounds, CommandList queue)
public void ProcessCommands(QRectangle bounds, DrawList queue)
{
CommandQueue iterator = queue.GetEnumerator();
DrawQueue iterator = queue.GetEnumerator();
if (!iterator.Peek().IsCommand)
throw new ArgumentException("The first element in the iterator must be a command frame.");
@ -113,7 +113,7 @@ namespace Dashboard.CommandMachine
}
}
protected virtual void ChildProcessCommand(Command name, CommandQueue queue)
protected virtual void ChildProcessCommand(Command name, DrawQueue queue)
{
}
@ -129,7 +129,7 @@ namespace Dashboard.CommandMachine
_matrixStack.Push(QMat4.Identity);
}
private void ConditionalHandler(CommandQueue iterator)
private void ConditionalHandler(DrawQueue iterator)
{
Frame frame = iterator.Dequeue();
@ -171,7 +171,7 @@ namespace Dashboard.CommandMachine
}
}
private static readonly Dictionary<Type, ICommandListSerializer> s_serializers = new Dictionary<Type, ICommandListSerializer>();
private static readonly Dictionary<Type, IDrawListSerializer> s_serializers = new Dictionary<Type, IDrawListSerializer>();
/// <summary>
/// Add a custom serializer to the command engine.
@ -179,7 +179,7 @@ namespace Dashboard.CommandMachine
/// <typeparam name="T">Type object type.</typeparam>
/// <param name="serializer">The serializer.</param>
/// <param name="overwrite">True to allow overwriting.</param>
public static void AddSerializer<T>(ICommandListSerializer serializer, bool overwrite = false)
public static void AddSerializer<T>(IDrawListSerializer serializer, bool overwrite = false)
{
if (overwrite)
{
@ -197,8 +197,8 @@ namespace Dashboard.CommandMachine
/// <typeparam name="T">Type object type.</typeparam>
/// <param name="serializer">The serializer.</param>
/// <param name="overwrite">True to allow overwriting.</param>
public static void AddSerializer<T>(ICommandListSerializer<T> serializer, bool overwrite = false)
=> AddSerializer<T>((ICommandListSerializer)serializer, overwrite);
public static void AddSerializer<T>(IDrawListSerializer<T> serializer, bool overwrite = false)
=> AddSerializer<T>((IDrawListSerializer)serializer, overwrite);
/// <summary>
/// Get a serializer for the given object.
@ -206,16 +206,16 @@ namespace Dashboard.CommandMachine
/// <typeparam name="T">The object type.</typeparam>
/// <param name="value">Required parameter for the C# type inference to work.</param>
/// <returns>The serializer.</returns>
public static ICommandListSerializer<T> GetSerializer<T>(ICommandListSerializable<T>? value)
where T : ICommandListSerializable<T>, new()
public static IDrawListSerializer<T> GetSerializer<T>(IDrawListSerializable<T>? value)
where T : IDrawListSerializable<T>, new()
{
if (!s_serializers.TryGetValue(typeof(T), out var serializer))
{
serializer = new CommandListSerializableSerializer<T>();
serializer = new DrawListSerializableSerializer<T>();
AddSerializer<T>(serializer);
}
return (ICommandListSerializer<T>)serializer;
return (IDrawListSerializer<T>)serializer;
}
/// <summary>
@ -224,9 +224,9 @@ namespace Dashboard.CommandMachine
/// <typeparam name="T">The object type.</typeparam>
/// <param name="value">Required parameter for the C# type inference to work.</param>
/// <returns>The serializer.</returns>
public static ICommandListSerializer<T> GetSerializer<T>(T? value)
public static IDrawListSerializer<T> GetSerializer<T>(T? value)
{
return (ICommandListSerializer<T>)s_serializers[typeof(T)];
return (IDrawListSerializer<T>)s_serializers[typeof(T)];
}
}
}

@ -4,9 +4,9 @@ using System.Collections;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
namespace Dashboard.CommandMachine
namespace Dashboard.ImmediateDraw
{
public class CommandList : IEnumerable<Frame>
public class DrawList : IEnumerable<Frame>
{
private readonly List<Frame> _frames = new List<Frame>();
@ -307,7 +307,7 @@ namespace Dashboard.CommandMachine
}
}
public void Splice(CommandList list)
public void Splice(DrawList list)
{
foreach (Frame frame in list)
{
@ -322,7 +322,7 @@ namespace Dashboard.CommandMachine
/// <param name="value">What to write into the command list.</param>
public void Write<T>(T value)
{
CommandEngine.GetSerializer(value).Serialize(value, this);
DrawingEngine.GetSerializer(value).Serialize(value, this);
}
/// <summary>
@ -330,18 +330,18 @@ namespace Dashboard.CommandMachine
/// </summary>
/// <typeparam name="T">The type of the value to serialize.</typeparam>
/// <param name="value">What to write into the command list.</param>
public void Write<T>(ICommandListSerializable<T> value)
where T : ICommandListSerializable<T>, new()
public void Write<T>(IDrawListSerializable<T> value)
where T : IDrawListSerializable<T>, new()
{
CommandEngine.GetSerializer(value).Serialize((T)value, this);
DrawingEngine.GetSerializer(value).Serialize((T)value, this);
}
public CommandQueue GetEnumerator() => new CommandQueue(_frames);
public DrawQueue GetEnumerator() => new DrawQueue(_frames);
IEnumerator<Frame> IEnumerable<Frame>.GetEnumerator() => GetEnumerator();
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
}
public class CommandQueue : IEnumerator<Frame>
public class DrawQueue : IEnumerator<Frame>
{
private readonly IReadOnlyList<Frame> _frames;
private int _current;
@ -350,7 +350,7 @@ namespace Dashboard.CommandMachine
object IEnumerator.Current => Current;
public CommandQueue(IReadOnlyList<Frame> frames)
public DrawQueue(IReadOnlyList<Frame> frames)
{
_current = -1;
_frames = frames;
@ -399,7 +399,7 @@ namespace Dashboard.CommandMachine
/// <param name="value">The deserialized value.</param>
public void Read<T>([NotNull] out T? value)
{
value = CommandEngine.GetSerializer(default(T)).Deserialize(this);
value = DrawingEngine.GetSerializer(default(T)).Deserialize(this);
}
/// <summary>
@ -407,10 +407,10 @@ namespace Dashboard.CommandMachine
/// </summary>
/// <typeparam name="T">Type of the object to deserialize.</typeparam>
/// <param name="value">The deserialized value.</param>
public void Read<T>([NotNull] out ICommandListSerializable<T>? value)
where T : ICommandListSerializable<T>, new()
public void Read<T>([NotNull] out IDrawListSerializable<T>? value)
where T : IDrawListSerializable<T>, new()
{
value = CommandEngine.GetSerializer(value = null).Deserialize(this);
value = DrawingEngine.GetSerializer(value = null).Deserialize(this);
}
/// <inheritdoc/>

@ -1,7 +1,7 @@
using System;
using System.Runtime.InteropServices;
namespace Dashboard.CommandMachine
namespace Dashboard.ImmediateDraw
{
[StructLayout(LayoutKind.Explicit)]
public struct Frame

@ -1,4 +1,4 @@
namespace Dashboard.CommandMachine
namespace Dashboard.ImmediateDraw
{
/// <summary>
/// Enumeration of command types in the Dashboard command lists.

@ -1,4 +1,4 @@
namespace Dashboard.CommandMachine
namespace Dashboard.ImmediateDraw
{
public enum ImageCommandFlags
{

@ -1,42 +1,41 @@
using System.Diagnostics.CodeAnalysis;
using System.Threading;
namespace Dashboard.CommandMachine
namespace Dashboard.ImmediateDraw
{
public interface ICommandListSerializable { }
public interface IDrawListSerializable { }
/// <summary>
/// Interface for objects that can be serialized into the Dashboard command stream.
/// </summary>
public interface ICommandListSerializable<T> : ICommandListSerializable
public interface IDrawListSerializable<T> : IDrawListSerializable
{
/// <summary>
/// Seralize object.
/// </summary>
/// <param name="list">The object to serialize into.</param>
void Serialize(CommandList list);
void Serialize(DrawList list);
/// <summary>
/// Deserialize object.
/// </summary>
/// <param name="queue">The command queue to deserialize from.</param>
void Deserialize(CommandQueue queue);
void Deserialize(DrawQueue queue);
}
/// <summary>
/// Base interface for all Command List serializers.
/// </summary>
public interface ICommandListSerializer { }
public interface IDrawListSerializer { }
public interface ICommandListSerializer<T> : ICommandListSerializer
public interface IDrawListSerializer<T> : IDrawListSerializer
{
/// <summary>
/// Serialize an object into the command list.
/// </summary>
/// <param name="value">The object to serialize.</param>
/// <param name="list">The command list to serialize into.</param>
void Serialize(T value, CommandList list);
void Serialize(T value, DrawList list);
/// <summary>
/// Deserialize an object from the command queue.
@ -44,24 +43,24 @@ namespace Dashboard.CommandMachine
/// <param name="queue">The command queue.</param>
/// <returns>The object deserialized from the command queue.</returns>
[return: NotNull]
T Deserialize(CommandQueue queue);
T Deserialize(DrawQueue queue);
}
/// <summary>
/// Class for automatic serialization of <see cref="ICommandListSerializable"/> objects.
/// Class for automatic serialization of <see cref="IDrawListSerializable"/> objects.
/// </summary>
/// <typeparam name="T">The object type to convert.</typeparam>
internal class CommandListSerializableSerializer<T> : ICommandListSerializer<T>
where T : ICommandListSerializable<T>, new()
internal class DrawListSerializableSerializer<T> : IDrawListSerializer<T>
where T : IDrawListSerializable<T>, new()
{
public T Deserialize(CommandQueue queue)
public T Deserialize(DrawQueue queue)
{
T value = new T();
value.Deserialize(queue);
return value;
}
public void Serialize(T value, CommandList list)
public void Serialize(T value, DrawList list)
{
value.Serialize(list);
}

@ -1,4 +1,4 @@
using Dashboard.CommandMachine;
using Dashboard.ImmediateDraw;
using Dashboard.Controls;
using System;
using System.Collections.Generic;
@ -70,12 +70,12 @@ namespace Dashboard.PAL
platform.PortFocus(handle);
}
public void Paint(CommandList? list = null)
public void Paint(DrawList? list = null)
{
if (UIElement == null)
return;
list ??= new CommandList();
list ??= new DrawList();
list.Clear();
UIElement.Bounds = new QRectangle(Size, new QVec2(0,0));

@ -1,5 +1,5 @@
using System;
using Dashboard.CommandMachine;
using Dashboard.ImmediateDraw;
using Dashboard.Media;
namespace Dashboard.PAL
@ -54,7 +54,7 @@ namespace Dashboard.PAL
void PortUnsubscribeEvent(IDashHandle port, EventHandler handler);
void PortFocus(IDashHandle port);
void PortShow(IDashHandle port, bool shown = true);
void PortPaint(IDashHandle port, CommandList commands);
void PortPaint(IDashHandle port, DrawList commands);
void GetMaximumImage(out int width, out int height);
void GetMaximumImage(out int width, out int height, out int depth);
}

@ -1,4 +1,4 @@
using Dashboard.CommandMachine;
using Dashboard.ImmediateDraw;
using Dashboard.Media;
using System;
using System.Collections.Generic;
@ -102,7 +102,7 @@ namespace Dashboard.Typography
return new QVec2(width, height);
}
public static void TypesetHorizontalDirect(this CommandList list, ReadOnlySpan<char> str, QVec2 origin, float size, QFont font)
public static void TypesetHorizontalDirect(this DrawList list, ReadOnlySpan<char> str, QVec2 origin, float size, QFont font)
{
Dictionary<QImage, FontDrawInfo> drawInfo = new Dictionary<QImage, FontDrawInfo>();
var enumerator = new LineEnumerator(str);

@ -1,12 +1,12 @@
using System;
using System.Collections.Generic;
using Dashboard.CommandMachine;
using Dashboard.ImmediateDraw;
using Dashboard.Media;
using Dashboard.Typography;
namespace Dashboard.VertexGenerator
{
public class VertexGeneratorEngine : CommandEngine
public class VertexGeneratorEngine : DrawingEngine
{
public DrawQueue DrawQueue { get; } = new DrawQueue();
@ -41,7 +41,7 @@ namespace Dashboard.VertexGenerator
DrawQueue.Clear();
}
protected override void ChildProcessCommand(Command name, CommandQueue queue)
protected override void ChildProcessCommand(Command name, ImmediateDraw.DrawQueue queue)
{
base.ChildProcessCommand(name, queue);
@ -67,7 +67,7 @@ namespace Dashboard.VertexGenerator
}
private readonly List<QLine> LineList = new List<QLine>();
private void LineProc(CommandQueue queue)
private void LineProc(ImmediateDraw.DrawQueue queue)
{
Frame frame = queue.Dequeue();
@ -292,7 +292,7 @@ namespace Dashboard.VertexGenerator
}
private readonly List<QBezier> BezierList = new List<QBezier>();
private void BezierProc(CommandQueue queue)
private void BezierProc(ImmediateDraw.DrawQueue queue)
{
Frame a = queue.Dequeue();
Frame b;
@ -409,7 +409,7 @@ namespace Dashboard.VertexGenerator
}
private readonly List<QRectangle> RectangleList = new List<QRectangle>();
private void RectangleProc(CommandQueue queue)
private void RectangleProc(ImmediateDraw.DrawQueue queue)
{
Frame frame = queue.Dequeue();
RectangleList.Clear();
@ -1012,7 +1012,7 @@ namespace Dashboard.VertexGenerator
DrawQueue.AddElement(s1); DrawQueue.AddElement(s2); DrawQueue.AddElement(4);
}
private void ImageProc(CommandQueue queue)
private void ImageProc(ImmediateDraw.DrawQueue queue)
{
Frame frame = queue.Dequeue();
ImageCommandFlags flags = (ImageCommandFlags)frame.I1;
@ -1029,7 +1029,7 @@ namespace Dashboard.VertexGenerator
}
}
private void Image2d(CommandQueue queue, QImage image, int count, bool uv)
private void Image2d(ImmediateDraw.DrawQueue queue, QImage image, int count, bool uv)
{
DrawQueue.StartDrawCall(Viewport, image);
@ -1073,7 +1073,7 @@ namespace Dashboard.VertexGenerator
DrawQueue.EndDrawCall();
}
private void Image3d(CommandQueue queue, QImage image, int count)
private void Image3d(ImmediateDraw.DrawQueue queue, QImage image, int count)
{
DrawQueue.StartDrawCall(Viewport, image);

@ -1,5 +1,5 @@
using Dashboard;
using Dashboard.CommandMachine;
using Dashboard.ImmediateDraw;
using Dashboard.Controls;
using Dashboard.OpenTK;
using Dashboard.Media.Defaults;
@ -27,7 +27,7 @@ namespace Dashboard.Demo
BlurgResult? result;
// private readonly Label Label = new Label() { Text = "Hello world!", Position = new QVec2(300, 300) };
protected override void PaintBegin(CommandList cmd)
protected override void PaintBegin(DrawList cmd)
{
base.PaintBegin(cmd);