Skip to content

Commit

Permalink
button clicking works :D
Browse files Browse the repository at this point in the history
  • Loading branch information
terminal-cs committed Mar 17, 2022
1 parent 9761f79 commit 237ab25
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
9 changes: 3 additions & 6 deletions PrismOS/Kernel.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
using static PrismOS.Libraries.Graphics.ContentPage;
using Mouse = Cosmos.System.MouseManager;
using Cosmos.System.FileSystem.VFS;
using System.Collections.Generic;
using PrismOS.Libraries.Graphics;
using Cosmos.System.FileSystem;
using System;
using XSharp.Assembler.x86;
using static PrismOS.Libraries.Graphics.ContentPage;

namespace PrismOS
{
Expand All @@ -22,8 +20,8 @@ public struct Strings_EN
{
new(5, (Canvas.Font.Default.Height + 2) * 0, 0, 0, 0, "FPS: 0", null, Page1, 0x01),
new(5, (Canvas.Font.Default.Height + 2) * 1, 0, 0, 0, "Runtime: .Net 5.0", null, Page1, 0x01),
new(5, (Canvas.Font.Default.Height + 2) * 2, 0, 0, 0, "UpTime: ", null, Page1, 0x01),
new(5, (Canvas.Font.Default.Height + 2) * 3, 100, 25, 0, "Reboot", null, Page1, 0x02, (ref Element This) => { This.Text = "Hello!"; }),
new(5, (Canvas.Font.Default.Height + 2) * 2, 100, 14, 0, "Reboot", null, Page1, 0x02, (ref Element This) => { Cosmos.System.Power.Reboot(); }),
new(5, (Canvas.Font.Default.Height + 2) * 3, 100, 14, 0, "Shutdown", null, Page1, 0x02, (ref Element This) => { Cosmos.System.Power.Shutdown(); }),
});
public static DateTime BootTime = DateTime.UtcNow;

Expand All @@ -42,7 +40,6 @@ protected override void Run()
Canvas.Clear(Color.CoolGreen);
Page1.Update(Canvas);
Page1.Children[0].Text = "FPS: " + Canvas.FPS;
Page1.Children[2].Text = "UpTime: " + DateTime.UtcNow.Subtract(BootTime).ToString("d Days, h Hours, mm Minutes, ss Seconds.");
Canvas.DrawFilledRectangle(0, Canvas.Height - 25, Canvas.Width, 25, 0, Color.StackOverflowBlack);
Canvas.DrawString(5, Canvas.Height - Canvas.Font.Default.Height, Strings_EN.OSMessage, Color.White);
Canvas.DrawBitmap((int)Mouse.X, (int)Mouse.Y, Files.Resources.Cursor);
Expand Down
8 changes: 4 additions & 4 deletions PrismOS/Libraries/Graphics/ContentPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,6 @@ public void Update(Canvas Canvas)
for (int I = 0; I < Children.Count; I++)
{
Element E = Children[I];
E.Hovering = IsMouseWithin(E.X, E.Y, E.Width, E.Height);
E.Clicked = E.Hovering && Mouse.MouseState == Cosmos.System.MouseState.Left;
if (E.Clicked && Mouse.MouseState != Cosmos.System.MouseState.Left)
{
E.Clicked = false;
Expand All @@ -89,6 +87,8 @@ public void Update(Canvas Canvas)
E.ClickEvent.Invoke(ref E);
}
}
E.Hovering = IsMouseWithin(X + E.X, X + E.Y, E.Width, E.Height);
E.Clicked = E.Hovering && Mouse.MouseState == Cosmos.System.MouseState.Left;

if (E.Type == 0x00)
{
Expand Down Expand Up @@ -116,8 +116,8 @@ public void Update(Canvas Canvas)
{
C = Color.SystemColors.Button;
}
Canvas.DrawFilledRectangle(E.X, E.Y, E.Width, E.Height, E.Radius, C);
Canvas.DrawString(E.X, E.Y, E.Text, Color.SystemColors.TitleText);
Canvas.DrawFilledRectangle(X + E.X, Y + E.Y, E.Width, E.Height, E.Radius, C);
Canvas.DrawString(X + E.X, Y + E.Y, E.Text, Color.SystemColors.TitleText);
} // Button
}
}
Expand Down

0 comments on commit 237ab25

Please sign in to comment.