In my_app.cpp:
void GreetingPanel::Draw(tachyon::GUIApplication& ui)
{ui.BeginLabelGroup();
ui.Label("Name");
ui.Field(name);
ui.Label("Times");
ui.Field(times, tachyon::NumericFieldConfig<int>{ .minVal = 1, .maxVal = 5 });
ui.Label("Excited");
ui.Field(excited, excited ? "Yes" : "No");
ui.EndLabelGroup();Fieldpicks the editor from the type:- text for
std::string - number for
int - toggle for
bool
- text for
- Each field edits the value in place.
NumericFieldConfiglimitstimesto 1..5.- The label group lines each
Labelup with the next control:- the labels go in a label column, which the user can resize
- clicking a label focuses its field
- The toggle's text is recomputed every frame, so it follows the value.
Below the fields, the greeting:
const std::string text = "Hello, " + name + (excited ? "!" : ".");
for (int i = 0; i < times; ++i)
ui.Text(text);- The greeting updates on the next frame after typing.
- The
Textcalls in the loop share a call site, but each gets its own ID.
Close GreetingPanel::Draw with }.