console and mining tab visual improvements

This commit is contained in:
2026-02-27 13:30:06 -06:00
parent 48ce983966
commit eebfd5947e
13 changed files with 962 additions and 183 deletions

View File

@@ -36,16 +36,68 @@ namespace Layout {
// DPI Scaling (must be first — other accessors multiply by dpiScale())
// ============================================================================
// ============================================================================
// User Font Scale (accessibility, 1.03.0, persisted in Settings)
// ============================================================================
namespace detail {
inline float& userFontScaleRef() { static float s = 1.0f; return s; }
inline bool& fontReloadNeededRef() { static bool s = false; return s; }
}
/**
* @brief Get the current display DPI scale factor.
* @brief Get the user's font scale preference (1.03.0).
* Multiplied into font loading so glyphs render at the chosen size.
*/
inline float userFontScale() { return detail::userFontScaleRef(); }
/**
* @brief Set the user's font scale and flag a font reload.
* Called from the settings UI; the main loop detects the flag and
* calls Typography::reload().
*/
inline void setUserFontScale(float v) {
v = std::max(1.0f, std::min(1.5f, v));
if (v != detail::userFontScaleRef()) {
detail::userFontScaleRef() = v;
detail::fontReloadNeededRef() = true;
}
}
/**
* @brief Consume the pending font-reload flag (returns true once).
*/
inline bool consumeUserFontReload() {
bool v = detail::fontReloadNeededRef();
detail::fontReloadNeededRef() = false;
return v;
}
// ============================================================================
// DPI Scaling (must be after userFontScale — dpiScale includes it)
// ============================================================================
/**
* @brief Get the raw hardware DPI scale factor (no user font scale).
*
* Returns the DPI scale set during typography initialization (e.g. 2.0 for
* 200 % Windows scaling). All pixel constants from TOML are in *logical*
* pixels and must be multiplied by this factor before being used as ImGui
* coordinates (which are physical pixels on Windows Per-Monitor DPI v2).
* 200 % Windows scaling). Use this when you need the pure hardware DPI
* without the user's accessibility font scale applied.
*/
inline float rawDpiScale() {
return dragonx::ui::material::Typography::instance().getDpiScale();
}
/**
* @brief Get the effective DPI scale factor including user font scale.
*
* Returns rawDpiScale() * userFontScale(). At userFontScale() == 1.0
* this is identical to the hardware DPI. All pixel constants from TOML
* are in *logical* pixels and should be multiplied by this factor so that
* containers grow proportionally when the user increases font scale.
*/
inline float dpiScale() {
return dragonx::ui::material::Typography::instance().getDpiScale();
return rawDpiScale() * userFontScale();
}
/**
@@ -165,11 +217,12 @@ inline LayoutTier currentTier(float availW, float availH) {
*/
inline float hScale(float availWidth) {
const auto& S = schema::UI();
float dp = dpiScale();
float rw = S.drawElement("responsive", "ref-width").sizeOr(1200.0f) * dp;
float rawDp = rawDpiScale(); // reference uses hardware DPI only
float dp = dpiScale(); // output includes user font scale
float rw = S.drawElement("responsive", "ref-width").sizeOr(1200.0f) * rawDp;
float minH = S.drawElement("responsive", "min-h-scale").sizeOr(0.5f);
float maxH = S.drawElement("responsive", "max-h-scale").sizeOr(1.5f);
// Clamp the logical (DPI-neutral) portion, then apply DPI.
// Clamp the logical (DPI-neutral) portion, then apply effective DPI.
float logical = std::clamp(availWidth / rw, minH, maxH);
return logical * dp;
}
@@ -185,8 +238,9 @@ inline float hScale() {
*/
inline float vScale(float availHeight) {
const auto& S = schema::UI();
float dp = dpiScale();
float rh = S.drawElement("responsive", "ref-height").sizeOr(700.0f) * dp;
float rawDp = rawDpiScale(); // reference uses hardware DPI only
float dp = dpiScale(); // output includes user font scale
float rh = S.drawElement("responsive", "ref-height").sizeOr(700.0f) * rawDp;
float minV = S.drawElement("responsive", "min-v-scale").sizeOr(0.5f);
float maxV = S.drawElement("responsive", "max-v-scale").sizeOr(1.4f);
float logical = std::clamp(availHeight / rh, minV, maxV);
@@ -205,8 +259,9 @@ inline float vScale() {
*/
inline float densityScale(float availHeight) {
const auto& S = schema::UI();
float dp = dpiScale();
float rh = S.drawElement("responsive", "ref-height").sizeOr(700.0f) * dp;
float rawDp = rawDpiScale(); // reference uses hardware DPI only
float dp = dpiScale(); // output includes user font scale
float rh = S.drawElement("responsive", "ref-height").sizeOr(700.0f) * rawDp;
float minDen = S.drawElement("responsive", "min-density").sizeOr(0.6f);
float maxDen = S.drawElement("responsive", "max-density").sizeOr(1.2f);
float logical = std::clamp(availHeight / rh, minDen, maxDen);