Your own CSS classes next to the library's, and switching palettes and font size at runtime.
Your own CSS classes next to the library's, and switching palettes and font size at runtime. Its classes are in custom_theme.css. Walkthrough: Custom theme.
#include <cstdio>
#include <string_view>
{
public:
{
const std::string_view styleFiles[] = { "styles.css", TACHYON_EXAMPLE_DIR "/custom_theme.css" };
SetStyleFiles(styleFiles);
return result;
windowID = idManager.CreateStaticID();
return {};
}
void OnGUI() override
{
if (!window)
return;
Text("My themed app", theme.GetStyle("banner"));
BeginHorizontal();
Button("Dark", [this] { RequestReloadTheme("themes/dark.css", GetGlobalFontScale()); });
Button("Light", [this] { RequestReloadTheme("themes/light.css", GetGlobalFontScale()); });
EndHorizontal();
BeginHorizontal();
Button("Smaller text", [this] { RequestReloadTheme(GetThemePath(), GetGlobalFontScale() * 0.9f); });
Button("Larger text", [this] { RequestReloadTheme(GetThemePath(), GetGlobalFontScale() * 1.1f); });
EndHorizontal();
Button("Careful!", [] {}, theme.GetStyle("warning-button"));
EndVertical();
}
private:
};
int main()
{
ThemeApp app;
if (result)
result = app.Run();
app.Cleanup();
if (!result)
{
return 1;
}
return 0;
}
The application: owns the windows, the systems and the frame loop.
Definition gui_application.h:185
A value, or the Error saying why there is none.
Definition gui_result.h:36
const Error & GetError() const
The error; only valid when !HasValue().
Definition gui_result.h:61
std::string message
what went wrong, for logs and users
Definition gui_result.h:28
A 64-bit element ID whose bit layout depends on its IDMode.
Definition gui_id.h:23
static constexpr ID Invalid()
The "no element" ID (all bits zero); also the default for optional ID parameters.
Definition gui_id.h:66
Per-element overrides of style layout properties.
Definition gui_constraints.h:150
LayoutOverride & FlexGrow(int16_t v) &
Overrides the style's flex-grow / flex-shrink.
Definition gui_constraints.h:317
int2 Size() const
The explicit sizes; kAuto on axes without one.
Definition gui_constraints.h:205