Skip to content

Commit

Permalink
improve desktop
Browse files Browse the repository at this point in the history
  • Loading branch information
terminal-cs committed May 1, 2022
1 parent bfd172b commit 9e3451f
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 15 deletions.
19 changes: 15 additions & 4 deletions PrismOS/Kernel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ protected override void BeforeRun()
Radius = 0,
Draggable = false,
Visible = true,
TitleVisible = false,
Elements = new()
{
new Libraries.Graphics.GUI.Elements.Button()
Expand All @@ -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,
Expand Down
26 changes: 15 additions & 11 deletions PrismOS/Libraries/Graphics/GUI/WindowManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ public class Window
{
public int X, Y, Width, Height, Radius;
public List<Elements.Element> 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)
{
Expand All @@ -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;
}
}

Expand All @@ -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);
}

Expand Down

0 comments on commit 9e3451f

Please sign in to comment.