added example
This commit is contained in:
parent
f827fb4f18
commit
808dc98488
23 changed files with 263 additions and 33 deletions
BIN
ExampleGui.png
BIN
ExampleGui.png
Binary file not shown.
Before Width: | Height: | Size: 64 KiB |
|
@ -2,4 +2,4 @@
|
|||
|
||||
__Visit the wiki tab to get information on how to get started or on how this library works internally__
|
||||
|
||||

|
||||

|
BIN
example.png
Normal file
BIN
example.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 59 KiB |
15
examples/src/Box.bf
Normal file
15
examples/src/Box.bf
Normal file
|
@ -0,0 +1,15 @@
|
|||
namespace examples;
|
||||
|
||||
using TheaterGui.Components;
|
||||
|
||||
class Box : Container
|
||||
{
|
||||
public this() : base("Box")
|
||||
{
|
||||
//Add ui items here via AddChild() and terminate the row via EndRow()
|
||||
Margin = 5;
|
||||
|
||||
AddChild(new Checkb());
|
||||
AddChild(new Radios());
|
||||
}
|
||||
}
|
45
examples/src/Buttons.bf
Normal file
45
examples/src/Buttons.bf
Normal file
|
@ -0,0 +1,45 @@
|
|||
namespace examples;
|
||||
|
||||
using TheaterGui.Components;
|
||||
|
||||
class StandartButton : Button
|
||||
{
|
||||
public this() : base("Basic Button")
|
||||
{
|
||||
Margin = 5;
|
||||
}
|
||||
|
||||
//What happens when the button is clicked
|
||||
public override void ClickAction()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
class LButton : LargeButton
|
||||
{
|
||||
public this() : base("Large Button")
|
||||
{
|
||||
Margin = 5;
|
||||
}
|
||||
|
||||
//What happens when the button is clicked
|
||||
public override void ClickAction()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
class CButton : NButton
|
||||
{
|
||||
public this() : base(400, 50, "Custom sized button")
|
||||
{
|
||||
Margin = 5;
|
||||
}
|
||||
|
||||
//What happens when the button is clicked
|
||||
public override void ClickAction()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
18
examples/src/Checkb.bf
Normal file
18
examples/src/Checkb.bf
Normal file
|
@ -0,0 +1,18 @@
|
|||
namespace examples;
|
||||
|
||||
using TheaterGui.Components;
|
||||
|
||||
class Checkb : Checkbox
|
||||
{
|
||||
public this() : base("Check me!")
|
||||
{
|
||||
Checked = true;
|
||||
Description = "Beef is awesome";
|
||||
}
|
||||
|
||||
//What happens when the button is clicked
|
||||
public override void OnCheck(bool checkValue)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
33
examples/src/ExampleToolbar.bf
Normal file
33
examples/src/ExampleToolbar.bf
Normal file
|
@ -0,0 +1,33 @@
|
|||
namespace examples;
|
||||
|
||||
using TheaterGui.Components;
|
||||
|
||||
class ExampleToolbar : Toolbar
|
||||
{
|
||||
public this() : base("Toolbar")
|
||||
{
|
||||
AddToolbarCategories(
|
||||
new .("Help",
|
||||
new .("Version", new => PrintVersion)
|
||||
),
|
||||
|
||||
new .("About",
|
||||
new .("TheaterGui", new => PrintAbout),
|
||||
new .("Booklordofthedings", new => PrintAbout)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public void PrintVersion()
|
||||
{
|
||||
System.Console.WriteLine("1.0");
|
||||
}
|
||||
|
||||
public void PrintAbout()
|
||||
{
|
||||
System.Console.WriteLine("""
|
||||
TheaterGui by Booklordofthedings
|
||||
A simple easy to use gui library for tools
|
||||
""");
|
||||
}
|
||||
}
|
23
examples/src/HorSlider.bf
Normal file
23
examples/src/HorSlider.bf
Normal file
|
@ -0,0 +1,23 @@
|
|||
namespace examples;
|
||||
|
||||
using TheaterGui.Components;
|
||||
|
||||
class HorSlider : HSlider
|
||||
{
|
||||
public this() : base("HorSlider")
|
||||
{
|
||||
//Use the thing above to set the length of the bar
|
||||
Min = 0;
|
||||
Max = 100;
|
||||
Value = 50;
|
||||
ReactToValueChange = true; //This indicates wether OnValueChange gets actually called
|
||||
Description = "A default horizontal slider";
|
||||
|
||||
MarginTop = 50;
|
||||
}
|
||||
|
||||
public override void OnValueChange(float newVal)
|
||||
{
|
||||
System.Console.WriteLine(Value);
|
||||
}
|
||||
}
|
|
@ -7,6 +7,42 @@ 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
|
||||
AddChild(new ExampleToolbar());
|
||||
|
||||
AddChild(new Label("Changing the width allows you to see these buttons reordered"));
|
||||
EndRow();
|
||||
|
||||
AddChild(new OpenButton());
|
||||
AddChild(new OpenButton());
|
||||
AddChild(new OpenButton());
|
||||
AddChild(new OpenButton());
|
||||
AddChild(new OpenButton());
|
||||
AddChild(new OpenButton());
|
||||
AddChild(new OpenButton());
|
||||
AddChild(new OpenButton());
|
||||
AddChild(new OpenButton());
|
||||
AddChild(new OpenButton());
|
||||
AddChild(new OpenButton());
|
||||
AddChild(new OpenButton());
|
||||
AddChild(new OpenButton());
|
||||
AddChild(new OpenButton());
|
||||
AddChild(new OpenButton());
|
||||
AddChild(new OpenButton());
|
||||
AddChild(new OpenButton());
|
||||
AddChild(new OpenButton());
|
||||
EndRow();
|
||||
|
||||
AddChild(new StandartButton());
|
||||
AddChild(new LButton());
|
||||
AddChild(new CButton());
|
||||
EndRow();
|
||||
|
||||
AddChild(new HorSlider());
|
||||
AddChild(new VertSlider());
|
||||
EndRow();
|
||||
|
||||
|
||||
AddChild(new Box());
|
||||
AddChild(new Box());
|
||||
}
|
||||
}
|
21
examples/src/OpenButton.bf
Normal file
21
examples/src/OpenButton.bf
Normal file
|
@ -0,0 +1,21 @@
|
|||
namespace examples;
|
||||
|
||||
using TheaterGui.Components;
|
||||
|
||||
class OpenButton : IconButton
|
||||
{
|
||||
public this() : base("OpenButton")
|
||||
{
|
||||
Icon = .Icon_Folder; //Use this to set the icon sprite
|
||||
Margin = 5;
|
||||
MarginTop = 40;
|
||||
MarginBottom = 40;
|
||||
Description = "Open a file dialogue";
|
||||
}
|
||||
|
||||
//What happens when the button is clicked
|
||||
public override void ClickAction()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
19
examples/src/Radios.bf
Normal file
19
examples/src/Radios.bf
Normal file
|
@ -0,0 +1,19 @@
|
|||
namespace examples;
|
||||
|
||||
using TheaterGui.Components;
|
||||
|
||||
class Radios : RadioButton
|
||||
{
|
||||
public this() : base("Radios")
|
||||
{
|
||||
|
||||
Description = "";
|
||||
//Use SetBoxes(int, params StringView) to set the elements of the radio buttons
|
||||
SetBoxes(3, "Windows", "Linux", "Mac", "Web");
|
||||
}
|
||||
|
||||
//React to the check event, or use the Checked field to get the value directly
|
||||
public override void OnCheck(int32 value)
|
||||
{
|
||||
}
|
||||
}
|
20
examples/src/VertSlider.bf
Normal file
20
examples/src/VertSlider.bf
Normal file
|
@ -0,0 +1,20 @@
|
|||
namespace examples;
|
||||
|
||||
using TheaterGui.Components;
|
||||
|
||||
class VertSlider : VSlider
|
||||
{
|
||||
public this() : base("VertSlider")
|
||||
{
|
||||
//Use the thing above to set the length of the bar
|
||||
Min = 0;
|
||||
Max = 100;
|
||||
Value = 50;
|
||||
ReactToValueChange = true; //This indicates wether OnValueChange gets actually called
|
||||
}
|
||||
|
||||
public override void OnValueChange(float newVal)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
|
@ -4,7 +4,7 @@ using System;
|
|||
|
||||
class ButtonGenerator : Compiler.Generator
|
||||
{
|
||||
public override String Name => "TheaterGui -> Generate Button"
|
||||
public override String Name => "TheaterGui -> Button"
|
||||
|
||||
public override void InitUI()
|
||||
{
|
||||
|
@ -22,14 +22,14 @@ class ButtonGenerator : Compiler.Generator
|
|||
var enabled = bool.Parse(mParams["enabled"]);
|
||||
var description = mParams["description"];
|
||||
|
||||
outFileName.Append(scope $"TG{name}");
|
||||
outFileName.Append(scope $"{name}");
|
||||
|
||||
outText.Append(scope $"""
|
||||
namespace {Namespace};
|
||||
|
||||
using TheaterGui.Components;
|
||||
|
||||
class TG{name} : Button
|
||||
class {name} : Button
|
||||
{{
|
||||
public this() : base("{name}")
|
||||
{{
|
||||
|
|
|
@ -4,7 +4,7 @@ using System;
|
|||
|
||||
class CheckboxGenerator : Compiler.Generator
|
||||
{
|
||||
public override String Name => "TheaterGui -> Generate Checkbox"
|
||||
public override String Name => "TheaterGui -> Checkbox"
|
||||
|
||||
public override void InitUI()
|
||||
{
|
||||
|
@ -22,14 +22,14 @@ class CheckboxGenerator : Compiler.Generator
|
|||
var enabled = bool.Parse(mParams["enabled"]);
|
||||
var description = mParams["description"];
|
||||
|
||||
outFileName.Append(scope $"TG{name}");
|
||||
outFileName.Append(scope $"{name}");
|
||||
|
||||
outText.Append(scope $"""
|
||||
namespace {Namespace};
|
||||
|
||||
using TheaterGui.Components;
|
||||
|
||||
class TG{name} : Checkbox
|
||||
class {name} : Checkbox
|
||||
{{
|
||||
public this() : base("{name}")
|
||||
{{
|
||||
|
|
|
@ -4,7 +4,7 @@ using System;
|
|||
|
||||
class ContainerGenerator : Compiler.Generator
|
||||
{
|
||||
public override String Name => "TheaterGui -> Generate Container"
|
||||
public override String Name => "TheaterGui -> Container"
|
||||
|
||||
public override void InitUI()
|
||||
{
|
||||
|
@ -17,18 +17,19 @@ class ContainerGenerator : Compiler.Generator
|
|||
if (name.EndsWith(".bf", .OrdinalIgnoreCase))
|
||||
name.RemoveFromEnd(3);
|
||||
|
||||
outFileName.Append(scope $"TG{name}");
|
||||
outFileName.Append(scope $"{name}");
|
||||
|
||||
outText.Append(scope $"""
|
||||
namespace {Namespace};
|
||||
|
||||
using TheaterGui.Components;
|
||||
|
||||
class TG{name} : Screen
|
||||
class {name} : Container
|
||||
{{
|
||||
public this() : base("{name}")
|
||||
{{
|
||||
//Add ui items here via AddChild() and terminate the row via EndRow()
|
||||
Margin = 5;
|
||||
}}
|
||||
}}
|
||||
""");
|
||||
|
|
|
@ -23,7 +23,7 @@ class DropdownGenerator : Compiler.Generator
|
|||
var entries = mParams["content"];
|
||||
|
||||
|
||||
outFileName.Append(scope $"TG{name}");
|
||||
outFileName.Append(scope $"{name}");
|
||||
|
||||
outText.Append(scope $"""
|
||||
namespace {Namespace};
|
||||
|
|
|
@ -4,7 +4,7 @@ using System;
|
|||
|
||||
class IconButtonGenerator : Compiler.Generator
|
||||
{
|
||||
public override String Name => "TheaterGui -> Generate Icon Button"
|
||||
public override String Name => "TheaterGui -> Icon Button"
|
||||
|
||||
public override void InitUI()
|
||||
{
|
||||
|
@ -22,14 +22,14 @@ class IconButtonGenerator : Compiler.Generator
|
|||
var enabled = bool.Parse(mParams["enabled"]);
|
||||
var description = mParams["description"];
|
||||
|
||||
outFileName.Append(scope $"TG{name}");
|
||||
outFileName.Append(scope $"{name}");
|
||||
|
||||
outText.Append(scope $"""
|
||||
namespace {Namespace};
|
||||
|
||||
using TheaterGui.Components;
|
||||
|
||||
class TG{name} : IconButton
|
||||
class {name} : IconButton
|
||||
{{
|
||||
public this() : base("{name}")
|
||||
{{
|
||||
|
|
|
@ -4,7 +4,7 @@ using System;
|
|||
|
||||
class LargeButtonGenerator : Compiler.Generator
|
||||
{
|
||||
public override String Name => "TheaterGui -> Generate Large Button"
|
||||
public override String Name => "TheaterGui -> Large Button"
|
||||
|
||||
public override void InitUI()
|
||||
{
|
||||
|
@ -22,14 +22,14 @@ class LargeButtonGenerator : Compiler.Generator
|
|||
var enabled = bool.Parse(mParams["enabled"]);
|
||||
var description = mParams["description"];
|
||||
|
||||
outFileName.Append(scope $"TG{name}");
|
||||
outFileName.Append(scope $"{name}");
|
||||
|
||||
outText.Append(scope $"""
|
||||
namespace {Namespace};
|
||||
|
||||
using TheaterGui.Components;
|
||||
|
||||
class TG{name} : LargeButton
|
||||
class {name} : LargeButton
|
||||
{{
|
||||
public this() : base("{name}")
|
||||
{{
|
||||
|
|
|
@ -4,7 +4,7 @@ using System;
|
|||
|
||||
class NButtonGenerator : Compiler.Generator
|
||||
{
|
||||
public override String Name => "TheaterGui -> Generate NButton"
|
||||
public override String Name => "TheaterGui -> NButton"
|
||||
|
||||
public override void InitUI()
|
||||
{
|
||||
|
@ -22,14 +22,14 @@ class NButtonGenerator : Compiler.Generator
|
|||
var enabled = bool.Parse(mParams["enabled"]);
|
||||
var description = mParams["description"];
|
||||
|
||||
outFileName.Append(scope $"TG{name}");
|
||||
outFileName.Append(scope $"{name}");
|
||||
|
||||
outText.Append(scope $"""
|
||||
namespace {Namespace};
|
||||
|
||||
using TheaterGui.Components;
|
||||
|
||||
class TG{name} : NButton
|
||||
class {name} : NButton
|
||||
{{
|
||||
public this() : base("{name}")
|
||||
{{
|
||||
|
|
|
@ -4,11 +4,11 @@ using System;
|
|||
|
||||
class RadioButtonGenerator : Compiler.Generator
|
||||
{
|
||||
public override String Name => "TheaterGui -> Generate Radio Button"
|
||||
public override String Name => "TheaterGui -> Radio Button"
|
||||
|
||||
public override void InitUI()
|
||||
{
|
||||
AddEdit("name", "ComponentName Name", "");
|
||||
AddEdit("name", "Component Name", "");
|
||||
AddCheckbox("enabled", "Enabled", true);
|
||||
AddEdit("description", "Description", "");
|
||||
}
|
||||
|
@ -22,14 +22,14 @@ class RadioButtonGenerator : Compiler.Generator
|
|||
var enabled = bool.Parse(mParams["enabled"]);
|
||||
var description = mParams["description"];
|
||||
|
||||
outFileName.Append(scope $"TG{name}");
|
||||
outFileName.Append(scope $"{name}");
|
||||
|
||||
outText.Append(scope $"""
|
||||
namespace {Namespace};
|
||||
|
||||
using TheaterGui.Components;
|
||||
|
||||
class TG{name} : RadioButton
|
||||
class {name} : RadioButton
|
||||
{{
|
||||
public this() : base("{name}")
|
||||
{{
|
||||
|
|
|
@ -28,8 +28,7 @@ class ScreenGenerator : Compiler.Generator
|
|||
{{
|
||||
public this() : base("{name}")
|
||||
{{
|
||||
//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
|
||||
//Add UI items here via AddChild() and terminate the row via EndRow()
|
||||
}}
|
||||
}}
|
||||
""");
|
||||
|
|
|
@ -4,7 +4,7 @@ using System;
|
|||
|
||||
class SliderGenerator : Compiler.Generator
|
||||
{
|
||||
public override String Name => "TheaterGui -> Generate Slider"
|
||||
public override String Name => "TheaterGui -> Slider"
|
||||
|
||||
public override void InitUI()
|
||||
{
|
||||
|
@ -29,14 +29,14 @@ class SliderGenerator : Compiler.Generator
|
|||
var dfault = mParams["dfault"];
|
||||
|
||||
|
||||
outFileName.Append(scope $"TG{name}");
|
||||
outFileName.Append(scope $"{name}");
|
||||
|
||||
outText.Append(scope $"""
|
||||
namespace {Namespace};
|
||||
|
||||
using TheaterGui.Components;
|
||||
|
||||
class TG{name} : {(fixedLength == "True") ? "" : "N" }{(orientation == "Horizontal") ? "H" : "V"}Slider
|
||||
class {name} : {(fixedLength == "True") ? "" : "N" }{(orientation == "Horizontal") ? "H" : "V"}Slider
|
||||
{{
|
||||
public this() : base({(fixedLength == "True") ? "" : "64, "}"{name}")
|
||||
{{
|
||||
|
|
|
@ -4,7 +4,7 @@ using System;
|
|||
|
||||
class ToolbarGenerator : Compiler.Generator
|
||||
{
|
||||
public override String Name => "TheaterGui -> Generate Toolbar"
|
||||
public override String Name => "TheaterGui -> Toolbar"
|
||||
|
||||
public override void InitUI()
|
||||
{
|
||||
|
@ -18,14 +18,14 @@ class ToolbarGenerator : Compiler.Generator
|
|||
name.RemoveFromEnd(3);
|
||||
|
||||
|
||||
outFileName.Append(scope $"TG{name}");
|
||||
outFileName.Append(scope $"{name}");
|
||||
|
||||
outText.Append(scope $"""
|
||||
namespace {Namespace};
|
||||
|
||||
using TheaterGui.Components;
|
||||
|
||||
class TG{name} : Toolbar
|
||||
class {name} : Toolbar
|
||||
{{
|
||||
public this() : base("{name}")
|
||||
{{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue