added example
This commit is contained in:
parent
f827fb4f18
commit
808dc98488
23 changed files with 263 additions and 33 deletions
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)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue