QuasarEngine
Cross-platform 3D engine and editor
Loading...
Searching...
No Matches
Quasar::ImGuiTheme Namespace Reference

The look of the ImGui interface. More...

Functions

void ApplyStyle (ImGuiStyle &style, float dpiScale)
 Replaces the colors, spacing and rounding of a style with the engine theme.
std::filesystem::path GetFontPath ()
 Returns where the engine font is expected: resources/fonts/Inter/Inter-Regular.ttf, in the folder of the executable.
bool LoadFont (ImFontAtlas &atlas, const std::filesystem::path &file)
 Loads a font file as the default font of an atlas, at FontSize.

Variables

constexpr float FontSize = 16.0f
 Height of the text in pixels on a standard screen, before the DPI scale.

Detailed Description

The look of the ImGui interface.

The colors, spacing and font size are defined in ImGuiTheme.cpp, so they can be changed in one place.

Function Documentation

◆ ApplyStyle()

void Quasar::ImGuiTheme::ApplyStyle ( ImGuiStyle & style,
float dpiScale )

Replaces the colors, spacing and rounding of a style with the engine theme.

The spacing and the text are multiplied by the DPI scale, so they keep the same physical size on high-DPI screens.

Parameters
styleThe style to change, usually ImGui::GetStyle(). Every value is replaced.
dpiScaleThe content scale of the monitor: 1 on a standard screen, 2 on a screen with twice the pixel density. Values of 0 or less are read as 1.

◆ GetFontPath()

std::filesystem::path Quasar::ImGuiTheme::GetFontPath ( )

Returns where the engine font is expected: resources/fonts/Inter/Inter-Regular.ttf, in the folder of the executable.

The build copies the engine resources there.

Returns
The path of the font file, or an empty path if the folder of the executable cannot be found.

◆ LoadFont()

bool Quasar::ImGuiTheme::LoadFont ( ImFontAtlas & atlas,
const std::filesystem::path & file )

Loads a font file as the default font of an atlas, at FontSize.

When the file is missing or is not a font, the scalable font embedded in ImGui is used instead, and the reason is logged as an engine warning.

Parameters
atlasThe atlas that receives the font, usually ImGui::GetIO().Fonts. It must not have any font yet.
fileThe TrueType or OpenType file to load.
Returns
True if the file was loaded, false if the embedded font is used.