#pragma once #include #include #include "UITheme.h" // Merges the active UITheme's shape (row gaps, radii, insets, selection // style) with the uiScale-derived sizes into FreeInkUI theme tokens: the // theme says what lists look like, the scale says how big they are. // Everything read here is plain data from ThemeMetrics — the same values an // SD-card theme file will eventually supply. inline freeink::ui::ThemeTokens uiThemeTokens(const freeink::ui::GfxRendererTarget& target) { namespace fui = freeink::ui; const ThemeMetrics& metrics = UITheme::getInstance().getMetrics(); fui::ThemeTokens tokens = fui::themeTokensForLineHeight(target.lineHeight(fui::GfxRendererTarget::FONT_BODY)); // Button-device lists retain the theme's preferred density. The SDK still // grows individual rows for wrapping, subtitles and icons. if (!BoardConfig::hasTouch()) tokens.listMinRowHeight = static_cast(metrics.listRowHeight); tokens.listRowGap = static_cast(metrics.listRowGap); tokens.listRowRadius = static_cast(metrics.listRowRadius); tokens.listInset = static_cast(metrics.listInset); tokens.listSidePadding = static_cast(metrics.listSidePadding); tokens.listSelectionStyle = static_cast(metrics.listSelectionStyle); tokens.listScrollWidth = static_cast(metrics.listScrollWidth); tokens.listScrollSide = static_cast(metrics.listScrollSide); // No extra scroll-track inset: the bezel is already compensated once at the // frame level (GfxRendererTarget::deviceContext() feeds the board's // viewable insets into the fui safe area, and every list band derives from // safeRect()). Adding the same inset here doubled the compensation and // floated the track a full bezel-width inside the visible edge. tokens.listScrollInset = 0; // Screen::header()/status() band height. Without this the SDK's // line-height-derived default applies and fui-drawn headers (OPDS) come out // a different height than every GUI.drawHeader band. tokens.headerHeight = static_cast(metrics.headerHeight); tokens.headerSidePadding = static_cast(metrics.headerSidePadding); tokens.headerUnderline = static_cast(metrics.headerUnderlineSize); tokens.headerTitleAlign = static_cast(metrics.headerTitleAlign); // Control-panel shape (sheet corners, tiles, step buttons, capsule slider), // so the control center follows the theme like every list and header does. tokens.controlRadius = static_cast(metrics.controlRadius); tokens.sheetRadius = static_cast(metrics.sheetRadius); tokens.capsuleRadius = static_cast(metrics.capsuleRadius); tokens.bodyText.bold = metrics.listTitleBold; return tokens; }