diff --git a/PrismOS/Kernel.cs b/PrismOS/Kernel.cs index 046c20a0..b6ed79c1 100644 --- a/PrismOS/Kernel.cs +++ b/PrismOS/Kernel.cs @@ -33,6 +33,7 @@ protected override void BeforeRun() Radius = 0, Draggable = false, Visible = true, + TitleVisible = false, Elements = new() { new Libraries.Graphics.GUI.Elements.Button() @@ -43,15 +44,25 @@ protected override void BeforeRun() Height = 32, Radius = 0, Text = "Start", - OnClick = (ref Libraries.Graphics.GUI.Elements.Element E) => { WM.Windows[0].Elements[1].Visible = !WM.Windows[0].Elements[1].Visible; }, + OnClick = (ref Libraries.Graphics.GUI.Elements.Element E) => { WM.Windows[0].Elements[2].Visible = !WM.Windows[0].Elements[2].Visible; }, OnUpdate = (ref Libraries.Graphics.GUI.Elements.Element E) => { }, }, + new Libraries.Graphics.GUI.Elements.Button() + { + X = 70, + Y = 0, + Width = 32, + Height = 32, + Radius = 0, + Text = "M", + OnClick = (ref Libraries.Graphics.GUI.Elements.Element E) => { WM.Windows.Add(new() { X = 200, Y = 50, Width = 300, Height = 150, Draggable = true, }); }, + }, new Libraries.Graphics.GUI.Elements.Panel() { X = 0, - Y = -400, - Width = 64, - Height = 400, + Y = -300, + Width = 150, + Height = 300, Color = new(Color.Black, 128), Visible = false, Radius = 0, diff --git a/PrismOS/Libraries/Graphics/GUI/WindowManager.cs b/PrismOS/Libraries/Graphics/GUI/WindowManager.cs index 9be06de0..590436f7 100644 --- a/PrismOS/Libraries/Graphics/GUI/WindowManager.cs +++ b/PrismOS/Libraries/Graphics/GUI/WindowManager.cs @@ -10,10 +10,10 @@ public class Window { public int X, Y, Width, Height, Radius; public List Elements = new(); - public bool Visible = true, Draggable = true; + public bool Visible = true, Draggable = true, TitleVisible = true; + public bool Moving; + public int IX, IY; } - public bool Moving; - public int IX, IY; public void Update(Canvas Canvas) { @@ -27,21 +27,21 @@ public void Update(Canvas Canvas) { if (Mouse.MouseState == Cosmos.System.MouseState.Left) { - if (Mouse.X > Window.X && Mouse.X < Window.X + Window.Width && Mouse.Y > Window.Y - 15 && Mouse.Y < Window.Y && !Moving) + if (Mouse.X > Window.X && Mouse.X < Window.X + Window.Width && Mouse.Y > Window.Y - 15 && Mouse.Y < Window.Y && !Window.Moving) { - Moving = true; - IX = (int)Mouse.X - Window.X; - IY = (int)Mouse.Y - Window.Y; + Window.Moving = true; + Window.IX = (int)Mouse.X - Window.X; + Window.IY = (int)Mouse.Y - Window.Y; } } else { - Moving = false; + Window.Moving = false; } - if (Moving) + if (Window.Moving) { - Window.X = (int)Mouse.X - IX; - Window.Y = (int)Mouse.Y - IY; + Window.X = (int)Mouse.X - Window.IX; + Window.Y = (int)Mouse.Y - Window.IY; } } @@ -51,6 +51,10 @@ public void Update(Canvas Canvas) if (Window.Visible) { + if (Window.TitleVisible) + { + Canvas.DrawFilledRectangle(Window.X, Window.Y - 15, Window.Width, 15, 0, Color.Black); + } Canvas.DrawFilledRectangle(Window.X, Window.Y, Window.Width, Window.Height, Window.Radius, Color.StackOverflowBlack); }