Add StackLayout and GridLayout classes for window UI element layouts

This commit is contained in:
Stone_Red
2026-06-16 18:20:20 +02:00
parent 99c98e74a2
commit e3ece1fb4a
4 changed files with 205 additions and 11 deletions
+37 -11
View File
@@ -1,4 +1,5 @@
using RemSox.Processing;
using RemSox.UI.GUI.Layout;
using RemSox.UI.GUI.Rendering;
using RemSox.UI.GUI.UIEelements.Controls;
using RemSox.UI.GUI.Windows;
@@ -21,13 +22,15 @@ internal class DesktopProcess() : Process("Desktop Manager")
WindowManager.InvalidateAll();
// Test window 1: interactive controls
// Test window 1: interactive controls using stack layout
Window testWindow = WindowManager.CreateWindow(this, "UI Controls", new Size(280, 260));
testWindow.AutoFlush = true;
Button button = testWindow.CreateUIElement<Button>(b =>
StackLayout stack = testWindow.CreateStackLayout(20, 30, 6);
stack.UniformWidth = 240;
Button button = stack.Add<Button>(b =>
{
b.Position = new Point(20, 30);
b.Size = new Size(240, 25);
b.Text = "Click Me";
b.BackgroundColor = Color.LightBlue;
@@ -39,9 +42,8 @@ internal class DesktopProcess() : Process("Desktop Manager")
button.BackgroundColor = Color.LightGreen;
};
CheckBox check = testWindow.CreateUIElement<CheckBox>(c =>
CheckBox check = stack.Add<CheckBox>(c =>
{
c.Position = new Point(20, 65);
c.Size = new Size(240, 20);
c.Text = "Check Me";
c.IsChecked = true;
@@ -52,25 +54,22 @@ internal class DesktopProcess() : Process("Desktop Manager")
check.Text = check.IsChecked ? "Checked!" : "Unchecked!";
};
RadioButton radio = testWindow.CreateUIElement<RadioButton>(r =>
RadioButton radio = stack.Add<RadioButton>(r =>
{
r.Position = new Point(20, 95);
r.Size = new Size(240, 20);
r.Text = "Radio Option";
r.IsChecked = true;
});
Slider slider = testWindow.CreateUIElement<Slider>(s =>
Slider slider = stack.Add<Slider>(s =>
{
s.Position = new Point(20, 130);
s.Size = new Size(240, 24);
s.BackgroundColor = Color.SteelBlue;
s.Value = 60;
});
ProgressBar progress = testWindow.CreateUIElement<ProgressBar>(p =>
ProgressBar progress = stack.Add<ProgressBar>(p =>
{
p.Position = new Point(20, 170);
p.Size = new Size(240, 20);
p.BackgroundColor = Color.DimGray;
p.FillColor = Color.LimeGreen;
@@ -131,6 +130,33 @@ internal class DesktopProcess() : Process("Desktop Manager")
});
shapesCheck.OnCheckedChanged += (_, _) => { };
// Test window 3: grid layout
Window gridWin = WindowManager.CreateWindow(this, "Grid Layout", new Size(260, 160));
gridWin.AutoFlush = true;
GridLayout grid = gridWin.CreateGridLayout(10, 25,
new int[] { 70, 70, 70 },
new int[] { 25, 25, 25 },
6);
for (int row = 0; row < 3; row++)
{
for (int col = 0; col < 3; col++)
{
int r = row, c = col;
Button btn = grid.Add<Button>(col, row, b =>
{
b.Text = $"[{c},{r}]";
b.BackgroundColor = (c + r) % 2 == 0 ? Color.SteelBlue : Color.DimGray;
});
btn.OnClick += (_, _) =>
{
btn.Text = "X";
};
}
}
}
internal override void Tick()