Label
See the LabelDemo.cs.
using Gridrand.Contracts;
namespace Gridrand.RimGui.Manual
{
/// <summary>
/// Demonstrates various labeled elements such as sliders, numeric inputs, text inputs, dropdowns, and color pickers.
/// </summary>
class LabelDemo : ManualBase, IManual
{
// Ratio for label size in label-input UI components
float labelRatio = 0.3f;
bool boolValue;
int sliderIntValue = 100;
int numericIntValue = 100;
float numericFloatValue = 10000f;
int intValue1;
int intValue2 = 50;
int intValue3 = 10000;
float floatValue;
double doubleValue;
string stringValue = "0123456789";
SampleEnum sampleEnum;
Color32 color = Color32.Red;
Vector2 v2 = new(10f, 10f);
Vector3 v3 = new(10f, 10f, 10f);
Vector4 v4 = new(10f, 10f, 10f, 10f);
Vector2Int v2Int = new(10, 10);
Vector3Int v3Int = new(10, 10, 10);
Rect rect = new(10, 10, 10, 10);
RectInt rectInt = new(10, 10, 10, 10);
Bounds bounds = new(Vector3.One, Vector3.One);
BoundsInt boundsInt = new(Vector3Int.One, Vector3Int.One);
public LabelDemo(ManualBaseResource p) : base(p)
{
}
public void Draw()
{
Gui.Heading("Settings");
// Input for adjusting the label-to-input ratio
using (Ranges.BeginFloat(0.1f, 0.9f))
Gui.LabelInputNumeric("Label Ratio", ref labelRatio);
// Apply label size ratio to all labeled inputs
using var s = Style.LabelSizes.Begin(Size.Ratio(labelRatio));
Gui.Separator();
// Various labeled UI components
Gui.LabelText("Text", "text");
Gui.LabelSliderNumeric("Slider 0-100", ref sliderIntValue, 0, 100);
Gui.LabelInput("Bool", ref boolValue);
Gui.LabelInputNumeric("ulong", ref numericIntValue);
Gui.LabelInputNumeric("float", ref numericFloatValue);
using (Ranges.BeginInt(0, 1))
Gui.LabelInputNumeric("int 0-1", ref intValue1);
using (Ranges.BeginInt(0, 100))
Gui.LabelInputNumeric("int 0-100", ref intValue2);
using (Ranges.BeginInt(0, 10000))
Gui.LabelInputNumeric("int 0-10000", ref intValue3);
using (Ranges.BeginFloat(0f, 100f))
Gui.LabelInputNumeric("float 0f-100f", ref floatValue);
using (Ranges.BeginDouble(0d, 1000d))
Gui.LabelInputNumeric("double 0d-1000d", ref doubleValue);
Gui.LabelInput("string", ref stringValue);
Gui.Spacing();
v2 = Gui.LabelInput("Vector2", v2);
v3 = Gui.LabelInput("Vector3", v3);
v4 = Gui.LabelInput("Vector4", v4);
v2Int = Gui.LabelInput("Vector2Int", v2Int);
v3Int = Gui.LabelInput("Vector3Int", v3Int);
rect = Gui.LabelInput("Rect", rect);
rectInt = Gui.LabelInput("RectInt", rectInt);
bounds = Gui.LabelInput("Bounds", bounds);
boundsInt = Gui.LabelInput("BoundsInt", boundsInt);
Gui.LabelInput("InputColor", ref color);
Gui.LabelDropdown("Dropdown", ref sampleEnum);
}
enum SampleEnum
{
A,
B,
C
}
}
}