Replace string element render types with RenderCommandType enum, decompose UI elements (Button, CheckBox, chrome) into drawing primitives via ToPrimitives(), emit per-element commands on flush, and move composite into IRenderSource.

This commit is contained in:
Stone_Red
2026-06-16 01:11:01 +02:00
parent 1355fa06b8
commit e90e9ab163
16 changed files with 850 additions and 187 deletions
+26
View File
@@ -1,3 +1,7 @@
using RemSox.UI.GUI.Rendering;
using System.Drawing;
namespace RemSox.UI.GUI.UIEelements.Shapes;
public class Circle() : Shape("Circle")
@@ -7,4 +11,26 @@ public class Circle() : Shape("Circle")
get;
set => SetProperty(nameof(Radius), ref field, value);
}
public bool IsFilled
{
get;
set => SetProperty(nameof(IsFilled), ref field, value);
} = true;
public override IEnumerable<RenderCommand> ToPrimitives(int windowId)
{
yield return new RenderCommand
{
WindowId = windowId,
ElementId = PrimitiveId(0),
Type = IsFilled ? RenderCommandType.DrawFilledCircle : RenderCommandType.DrawCircle,
Position = Position,
Properties = new Dictionary<string, object?>
{
["Color"] = Color,
["Radius"] = Radius,
}
};
}
}
+18
View File
@@ -1,3 +1,5 @@
using RemSox.UI.GUI.Rendering;
using System.Drawing;
namespace RemSox.UI.GUI.UIEelements.Shapes;
@@ -9,4 +11,20 @@ public class Line() : Shape("Line")
get;
set => SetProperty(nameof(EndPosition), ref field, value);
}
public override IEnumerable<RenderCommand> ToPrimitives(int windowId)
{
yield return new RenderCommand
{
WindowId = windowId,
ElementId = PrimitiveId(0),
Type = RenderCommandType.DrawLine,
Position = Position,
Properties = new Dictionary<string, object?>
{
["Color"] = Color,
["EndPosition"] = EndPosition,
}
};
}
}
+23
View File
@@ -0,0 +1,23 @@
using RemSox.UI.GUI.Rendering;
using System.Drawing;
namespace RemSox.UI.GUI.UIEelements.Shapes;
public class Pixel() : Shape("Pixel")
{
public override IEnumerable<RenderCommand> ToPrimitives(int windowId)
{
yield return new RenderCommand
{
WindowId = windowId,
ElementId = PrimitiveId(0),
Type = RenderCommandType.DrawPoint,
Position = Position,
Properties = new Dictionary<string, object?>
{
["Color"] = Color,
}
};
}
}
+18
View File
@@ -1,3 +1,5 @@
using RemSox.UI.GUI.Rendering;
using System.Drawing;
namespace RemSox.UI.GUI.UIEelements.Shapes;
@@ -15,4 +17,20 @@ public class Rectangle() : Shape("Rectangle")
get;
set => SetProperty(nameof(IsFilled), ref field, value);
} = true;
public override IEnumerable<RenderCommand> ToPrimitives(int windowId)
{
yield return new RenderCommand
{
WindowId = windowId,
ElementId = PrimitiveId(0),
Type = IsFilled ? RenderCommandType.DrawFilledRect : RenderCommandType.DrawRectBorder,
Position = Position,
Properties = new Dictionary<string, object?>
{
["Color"] = Color,
["Size"] = Size,
}
};
}
}
+19
View File
@@ -1,3 +1,5 @@
using RemSox.UI.GUI.Rendering;
using System.Drawing;
namespace RemSox.UI.GUI.UIEelements.Shapes;
@@ -21,4 +23,21 @@ public class Text() : UIElement("Text")
get;
set => SetProperty(nameof(FontSize), ref field, value);
} = 12;
public override IEnumerable<RenderCommand> ToPrimitives(int windowId)
{
yield return new RenderCommand
{
WindowId = windowId,
ElementId = PrimitiveId(0),
Type = RenderCommandType.DrawText,
Position = Position,
Properties = new Dictionary<string, object?>
{
["Color"] = Color,
["Content"] = Content,
["FontSize"] = FontSize,
}
};
}
}