aded checkbox basics
This commit is contained in:
parent
012f86413f
commit
b31f61061e
6 changed files with 37 additions and 4 deletions
BIN
assets/checkbox.png
Normal file
BIN
assets/checkbox.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 364 B |
BIN
assets/checkbox_checked.png
Normal file
BIN
assets/checkbox_checked.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 443 B |
21
src/Controls/Checkbox.bf
Normal file
21
src/Controls/Checkbox.bf
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
namespace TheaterGui.Controls;
|
||||||
|
|
||||||
|
using System;
|
||||||
|
|
||||||
|
class Checkbox : GuiObject
|
||||||
|
{
|
||||||
|
public sprite Sprite;
|
||||||
|
public sprite SpriteChecked;
|
||||||
|
|
||||||
|
public override GuiObject OnHover(int32 x, int32 y)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public this(StringView pName) : base("Checkbox", pName)
|
||||||
|
{
|
||||||
|
Sprite = App.Textures.GetAsset("checkbox");
|
||||||
|
SpriteChecked = App.Textures.GetAsset("checkbox_checked");
|
||||||
|
Label.Append(pName);
|
||||||
|
}
|
||||||
|
}
|
|
@ -5,13 +5,24 @@ using RaylibBeef;
|
||||||
|
|
||||||
class Label : GuiObject
|
class Label : GuiObject
|
||||||
{
|
{
|
||||||
|
private Vector2 _Measure;
|
||||||
public this(StringView pName) : base(Label, pName)
|
public this(StringView pName) : base(Label, pName)
|
||||||
{
|
{
|
||||||
Label.Append(pName);
|
Label.Append(pName);
|
||||||
|
Padding = 3;
|
||||||
|
_Measure = Raylib.MeasureTextEx(Theme.Font, Label, Theme.FontSize, 0);
|
||||||
|
Height = (.)_Measure.y;
|
||||||
|
Width = (.)_Measure.x;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override GuiObject OnHover(int32 x, int32 y)
|
public override GuiObject OnHover(int32 x, int32 y)
|
||||||
{
|
{
|
||||||
return this;
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Render()
|
||||||
|
{
|
||||||
|
Raylib.DrawTextEx(Theme.Font, Label, .(X,Y), Theme.FontSize, 0, Theme.Text);
|
||||||
|
Raylib.DrawLine(X,Y + (.)_Measure.y,X + (.)_Measure.x, Y + (.)_Measure.y, Theme.Text);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -15,6 +15,8 @@ class Textures
|
||||||
LoadAsset(Theme.Texture_NButton, "n_button");
|
LoadAsset(Theme.Texture_NButton, "n_button");
|
||||||
LoadAsset(Theme.Texture_SquareButton, "square_button");
|
LoadAsset(Theme.Texture_SquareButton, "square_button");
|
||||||
LoadAsset(Theme.Texture_LargeButton, "large_button");
|
LoadAsset(Theme.Texture_LargeButton, "large_button");
|
||||||
|
LoadAsset(Theme.Texture_Checkbox, "checkbox");
|
||||||
|
LoadAsset(Theme.Texture_Checkbox_Checked, "checkbox_checked");
|
||||||
|
|
||||||
LoadAsset(Theme.Texture_TheaterIcon, "theater_icon");
|
LoadAsset(Theme.Texture_TheaterIcon, "theater_icon");
|
||||||
LoadAsset(Theme.Texture_FolderIcon, "folder_icon");
|
LoadAsset(Theme.Texture_FolderIcon, "folder_icon");
|
||||||
|
|
|
@ -27,8 +27,7 @@ public class Theme
|
||||||
public static uint8[?] Texture_LargeButton = Compiler.ReadBinary("assets/large_button.png");
|
public static uint8[?] Texture_LargeButton = Compiler.ReadBinary("assets/large_button.png");
|
||||||
public static uint8[?] Texture_NButton = Compiler.ReadBinary("assets/n_button.png");
|
public static uint8[?] Texture_NButton = Compiler.ReadBinary("assets/n_button.png");
|
||||||
public static uint8[?] Texture_Button = Compiler.ReadBinary("assets/button.png");
|
public static uint8[?] Texture_Button = Compiler.ReadBinary("assets/button.png");
|
||||||
|
public static uint8[?] Texture_Checkbox = Compiler.ReadBinary("assets/checkbox.png");
|
||||||
|
public static uint8[?] Texture_Checkbox_Checked = Compiler.ReadBinary("assets/checkbox_checked.png");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue