added example file

This commit is contained in:
Booklordofthedings 2024-06-30 14:38:28 +02:00
parent 5661fffed1
commit f827fb4f18
9 changed files with 43 additions and 13 deletions

4
.gitignore vendored
View file

@ -1,5 +1,5 @@
# ---> Beef # ---> Beef
build/ **/build
recovery/ **/recovery
BeefSpace_User.toml BeefSpace_User.toml

View file

Before

Width:  |  Height:  |  Size: 64 KiB

After

Width:  |  Height:  |  Size: 64 KiB

Before After
Before After

View file

6
examples/BeefProj.toml Normal file
View file

@ -0,0 +1,6 @@
FileVersion = 1
Dependencies = {corlib = "*", TheaterGui = "*"}
[Project]
Name = "examples"
StartupObject = "examples.Program"

5
examples/BeefSpace.toml Normal file
View file

@ -0,0 +1,5 @@
FileVersion = 1
Projects = {examples = {Path = "."}, TheaterGui = {Path = ".."}}
[Workspace]
StartupProject = "examples"

View file

@ -0,0 +1,12 @@
namespace examples;
using TheaterGui.Components;
class MainScreen : Screen
{
public this() : base("MainScreen")
{
//Add ui items here via AddChild() and terminate the row via EndRow()
//The padding object can be used to add padding to every ui object
}
}

11
examples/src/Program.bf Normal file
View file

@ -0,0 +1,11 @@
namespace examples;
using TheaterGui;
class Program
{
public static void Main()
{
App.Run<MainScreen>("Example Gui",1920,1080);
}
}

View file

@ -4,7 +4,7 @@ using System;
class ScreenGenerator : Compiler.Generator class ScreenGenerator : Compiler.Generator
{ {
public override String Name => "TheaterGui -> Generate Screen" public override String Name => "TheaterGui -> Screen"
public override void InitUI() public override void InitUI()
{ {
@ -17,14 +17,14 @@ class ScreenGenerator : Compiler.Generator
if (name.EndsWith(".bf", .OrdinalIgnoreCase)) if (name.EndsWith(".bf", .OrdinalIgnoreCase))
name.RemoveFromEnd(3); name.RemoveFromEnd(3);
outFileName.Append(scope $"TG{name}"); outFileName.Append(scope $"{name}");
outText.Append(scope $""" outText.Append(scope $"""
namespace {Namespace}; namespace {Namespace};
using TheaterGui.Components; using TheaterGui.Components;
class TG{name} : Screen class {name} : Screen
{{ {{
public this() : base("{name}") public this() : base("{name}")
{{ {{

View file

@ -52,15 +52,11 @@ class Input
internal static void HandleRightClick() internal static void HandleRightClick()
{ {
if (App.[Friend]_Popups.Count > 0) //We dont stack up rightclicks
{ if (App.GetTopmostPopup() case .Ok(let top))
var top = App.[Friend]_Popups[App.[Friend]_Popups.Count - 1];
if (top is RightClickPopup) if (top is RightClickPopup)
{ delete App.[Friend]_Popups.GetAndRemove(top).Value;
App.[Friend]_Popups.Remove(top);
delete top;
}
}
Toolbar.ToolbarCategory popupCat = new .("Items"); Toolbar.ToolbarCategory popupCat = new .("Items");
App.CurrentScreen.OnRightClick((.)App.Mouse.x, (.)App.Mouse.y, popupCat); App.CurrentScreen.OnRightClick((.)App.Mouse.x, (.)App.Mouse.y, popupCat);
if (popupCat.Items.Count > 0) if (popupCat.Items.Count > 0)