fix(ui): apply the saved appearance settings at startup

Low-spec mode, theme effects, blur, UI and noise opacity and the
console scanline reached the live effects state only once the Settings
page or the first-run wizard was opened. "Effects off" and low-spec
therefore reverted at every launch, and the animated defaults kept the
main loop busy (91% of a core on an idle Lite wallet whose effects were
saved off).

- App::applyVisualSettings(): one low-spec-aware path from the saved
  prefs to the effects state, used at startup (after the skin, since
  setActiveSkin reloads the effect config), by the low-spec hotkey, the
  wizard and the Settings page.
- Low-spec stays a runtime-only override. The Settings page shows the
  overrides but persists the real prefs from its snapshot, and opening
  it under low-spec no longer turns theme effects and blur back on.
  Unticking a low-spec in the wizard that was loaded rather than ticked
  there now restores the saved prefs.
- Theme effects on/off always pairs with reduced transparency (the
  rainbow, shimmer and glare layers), as at startup and in the hotkeys.
- kAcrylicMaxBlur moves to imgui_acrylic.h, so startup clamps blur
  values saved in the old 0-4 range the way the slider does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-03 19:52:09 -05:00
co-authored by Claude Opus 5.5
parent 402a3053dc
commit fffab228d1
5 changed files with 97 additions and 50 deletions
+39 -21
View File
@@ -491,6 +491,12 @@ bool App::init()
skinMgr.setActiveSkin(skinId); skinMgr.setActiveSkin(skinId);
} }
// Apply the saved appearance prefs (low-spec, theme effects, blur, opacity, noise). Until now they
// only took effect once the Settings page or wizard was opened, so "effects off" / low-spec reverted
// at every launch and the animated defaults kept the main loop rendering continuously. After the
// skin, because setActiveSkin reloads the effect config (not the enabled flag).
applyVisualSettings();
// Apply saved language // Apply saved language
std::string lang = settings_->getLanguage(); std::string lang = settings_->getLanguage();
if (!lang.empty()) { if (!lang.empty()) {
@@ -583,6 +589,31 @@ bool App::init()
// ============================================================================ // ============================================================================
// Pre-frame: font atlas rebuilds (must run BEFORE ImGui::NewFrame) // Pre-frame: font atlas rebuilds (must run BEFORE ImGui::NewFrame)
// ============================================================================ // ============================================================================
void App::applyVisualSettings()
{
if (!settings_) return;
namespace fx = ui::effects;
const bool lowSpec = settings_->getLowSpecMode();
fx::setLowSpecMode(lowSpec);
if (lowSpec) {
// Low-spec overrides the heavy effects at runtime only; the saved prefs stay as they are so
// turning low-spec off restores them.
fx::ImGuiAcrylic::ApplyBlurAmount(0.0f);
fx::ImGuiAcrylic::SetUIOpacity(1.0f);
fx::ThemeEffects::instance().setEnabled(false);
fx::ThemeEffects::instance().setReducedTransparency(true);
ui::ConsoleTab::s_scanline_enabled = false;
} else {
const bool effects = settings_->getThemeEffectsEnabled();
fx::ImGuiAcrylic::ApplyBlurAmount(std::min(settings_->getBlurMultiplier(), fx::kAcrylicMaxBlur));
fx::ImGuiAcrylic::SetUIOpacity(settings_->getUIOpacity());
fx::ThemeEffects::instance().setEnabled(effects);
fx::ThemeEffects::instance().setReducedTransparency(!effects);
ui::ConsoleTab::s_scanline_enabled = settings_->getScanlineEnabled();
}
fx::ImGuiAcrylic::SetNoiseOpacity(settings_->getNoiseOpacity());
}
void App::preFrame() void App::preFrame()
{ {
ImGuiIO& io = ImGui::GetIO(); ImGuiIO& io = ImGui::GetIO();
@@ -1465,28 +1496,15 @@ void App::handleGlobalShortcuts()
// (checked BEFORE Ctrl+Down so it doesn't also trigger theme effects) // (checked BEFORE Ctrl+Down so it doesn't also trigger theme effects)
if (io.KeyCtrl && io.KeyShift && !io.WantTextInput && ImGui::IsKeyPressed(ImGuiKey_DownArrow)) { if (io.KeyCtrl && io.KeyShift && !io.WantTextInput && ImGui::IsKeyPressed(ImGuiKey_DownArrow)) {
bool newLow = !ui::effects::isLowSpecMode(); bool newLow = !ui::effects::isLowSpecMode();
ui::effects::setLowSpecMode(newLow); if (settings_) {
if (newLow) { // Persist the mode (and the opaque window low-spec implies) but not the effect prefs:
// Disable all heavy effects at runtime (don't overwrite saved prefs) // applyVisualSettings overrides them at runtime, so turning low-spec off restores them.
ui::effects::ImGuiAcrylic::ApplyBlurAmount(0.0f); settings_->setLowSpecMode(newLow);
ui::effects::ImGuiAcrylic::SetUIOpacity(1.0f); if (newLow) settings_->setWindowOpacity(1.0f);
ui::effects::ThemeEffects::instance().setEnabled(false); settings_->save();
ui::effects::ThemeEffects::instance().setReducedTransparency(true); applyVisualSettings();
if (settings_) {
settings_->setLowSpecMode(true);
settings_->setWindowOpacity(1.0f);
settings_->save();
}
} else { } else {
// Restore effect settings from saved preferences ui::effects::setLowSpecMode(newLow);
if (settings_) {
settings_->setLowSpecMode(false);
settings_->save();
ui::effects::ImGuiAcrylic::ApplyBlurAmount(settings_->getBlurMultiplier());
ui::effects::ImGuiAcrylic::SetUIOpacity(settings_->getUIOpacity());
ui::effects::ThemeEffects::instance().setEnabled(settings_->getThemeEffectsEnabled());
ui::effects::ThemeEffects::instance().setReducedTransparency(!settings_->getThemeEffectsEnabled());
}
} }
ui::Notifications::instance().info(newLow ? TR("appx_low_spec_mode_enabled") : TR("appx_low_spec_mode_disabled")); ui::Notifications::instance().info(newLow ? TR("appx_low_spec_mode_enabled") : TR("appx_low_spec_mode_disabled"));
} }
+8
View File
@@ -125,6 +125,14 @@ public:
float logicDeltaTime() const { return logic_dt_; } float logicDeltaTime() const { return logic_dt_; }
static constexpr float kMaxLogicDeltaSeconds = 6.0f; static constexpr float kMaxLogicDeltaSeconds = 6.0f;
/**
* @brief Push the saved appearance prefs (low-spec, theme effects, blur, UI and noise opacity,
* console scanline) to the live effects state. Low-spec overrides the rest without touching the
* saved values. Called at startup, by the low-spec hotkey, the first-run wizard and the Settings
* page, so every path applies the same thing.
*/
void applyVisualSettings();
/** /**
* @brief Pre-frame tasks that must run BEFORE ImGui::NewFrame(). * @brief Pre-frame tasks that must run BEFORE ImGui::NewFrame().
* *
+6 -7
View File
@@ -357,13 +357,9 @@ void App::renderFirstRunWizard() {
if (lang.first == wiz_cur_lang) { wiz_language_index = idx; break; } if (lang.first == wiz_cur_lang) { wiz_language_index = idx; break; }
idx++; idx++;
} }
// Apply loaded settings to runtime so visuals match slider values // Apply the loaded settings to the runtime (same low-spec-aware path as startup) so the
ui::effects::setLowSpecMode(wiz_low_spec); // visuals match the slider values
ui::effects::ImGuiAcrylic::ApplyBlurAmount(wiz_blur_amount); applyVisualSettings();
ui::effects::ImGuiAcrylic::SetUIOpacity(wiz_ui_opacity);
ui::effects::ThemeEffects::instance().setEnabled(wiz_theme_effects);
ui::effects::ThemeEffects::instance().setReducedTransparency(!wiz_theme_effects);
ui::ConsoleTab::s_scanline_enabled = wiz_scanline;
wiz_appearance_init = true; wiz_appearance_init = true;
} }
@@ -538,6 +534,9 @@ void App::renderFirstRunWizard() {
settings_->setScanlineEnabled(wiz_scanline); settings_->setScanlineEnabled(wiz_scanline);
settings_->setLowSpecMode(wiz_low_spec); settings_->setLowSpecMode(wiz_low_spec);
settings_->save(); settings_->save();
// Make the runtime match what was just saved, both ways: unticking a low-spec that was
// loaded rather than ticked here has no snapshot, so the branch above pushes nothing.
applyVisualSettings();
} }
ImGui::PopStyleVar(); ImGui::PopStyleVar();
ImGui::SameLine(); ImGui::SameLine();
+5
View File
@@ -11,6 +11,11 @@ namespace dragonx {
namespace ui { namespace ui {
namespace effects { namespace effects {
// Top of the Acrylic slider's range (the blur-radius multiplier at 100%). The panels frost at full
// alpha now, so this only controls how BLURRY the max is — kept gentle (the old max of 4.0 was way
// too strong). Saved values from the old 0–4 range are clamped to it wherever they're applied.
inline constexpr float kAcrylicMaxBlur = 1.25f;
/** /**
* @brief ImGui integration for acrylic effects * @brief ImGui integration for acrylic effects
* *
+39 -22
View File
@@ -60,10 +60,8 @@ namespace ui {
using namespace material; using namespace material;
// Top of the Acrylic slider's range (the blur-radius multiplier at 100%). The panels frost at full // Top of the Acrylic slider's range; the slider reads 0–100% of it (shared with App::applyVisualSettings).
// alpha now, so this only controls how BLURRY the max is — kept gentle (the old max of 4.0 was way static constexpr float kAcrylicMaxBlur = effects::kAcrylicMaxBlur;
// too strong). The slider still reads 0–100%; this is just what 100% maps to.
static constexpr float kAcrylicMaxBlur = 1.25f;
// Helper: build "TranslatedLabel##id" for ImGui widgets that use label as ID // Helper: build "TranslatedLabel##id" for ImGui widgets that use label as ID
static std::string TrId(const char* tr_key, const char* id) { static std::string TrId(const char* tr_key, const char* id) {
@@ -212,6 +210,7 @@ static void enterLowSpec(bool applyEffects) {
effects::ImGuiAcrylic::ApplyBlurAmount(0.0f); effects::ImGuiAcrylic::ApplyBlurAmount(0.0f);
effects::ImGuiAcrylic::SetUIOpacity(1.0f); effects::ImGuiAcrylic::SetUIOpacity(1.0f);
effects::ThemeEffects::instance().setEnabled(false); effects::ThemeEffects::instance().setEnabled(false);
effects::ThemeEffects::instance().setReducedTransparency(true);
ConsoleTab::s_scanline_enabled = false; ConsoleTab::s_scanline_enabled = false;
} }
} }
@@ -230,6 +229,7 @@ static void exitLowSpec(bool applyEffects) {
effects::ImGuiAcrylic::ApplyBlurAmount(s_settingsState.blur_amount); effects::ImGuiAcrylic::ApplyBlurAmount(s_settingsState.blur_amount);
effects::ImGuiAcrylic::SetUIOpacity(s_settingsState.ui_opacity); effects::ImGuiAcrylic::SetUIOpacity(s_settingsState.ui_opacity);
effects::ThemeEffects::instance().setEnabled(s_settingsState.theme_effects_enabled); effects::ThemeEffects::instance().setEnabled(s_settingsState.theme_effects_enabled);
effects::ThemeEffects::instance().setReducedTransparency(!s_settingsState.theme_effects_enabled);
ConsoleTab::s_scanline_enabled = s_settingsState.scanline_enabled; ConsoleTab::s_scanline_enabled = s_settingsState.scanline_enabled;
} }
s_settingsState.low_spec_snapshot.valid = false; s_settingsState.low_spec_snapshot.valid = false;
@@ -374,7 +374,8 @@ static void evaluateLiteLifecycleRequestFromPageState(App* app) {
// (APPEARANCE card now uses ChannelsSplit like all other cards) // (APPEARANCE card now uses ChannelsSplit like all other cards)
static void loadSettingsPageState(config::Settings* settings) { static void loadSettingsPageState(App* app) {
config::Settings* settings = app ? app->settings() : nullptr;
if (!settings) return; if (!settings) return;
s_settingsState.save_ztxs = settings->getSaveZtxs(); s_settingsState.save_ztxs = settings->getSaveZtxs();
@@ -413,10 +414,8 @@ static void loadSettingsPageState(config::Settings* settings) {
s_settingsState.balance_layout = settings->getBalanceLayout(); s_settingsState.balance_layout = settings->getBalanceLayout();
s_settingsState.scanline_enabled = settings->getScanlineEnabled(); s_settingsState.scanline_enabled = settings->getScanlineEnabled();
ConsoleTab::s_scanline_enabled = s_settingsState.scanline_enabled;
s_settingsState.theme_effects_enabled = settings->getThemeEffectsEnabled(); s_settingsState.theme_effects_enabled = settings->getThemeEffectsEnabled();
s_settingsState.low_spec_mode = settings->getLowSpecMode(); s_settingsState.low_spec_mode = settings->getLowSpecMode();
effects::setLowSpecMode(s_settingsState.low_spec_mode);
s_settingsState.reduce_motion = settings->getReduceMotion(); s_settingsState.reduce_motion = settings->getReduceMotion();
s_settingsState.font_scale = settings->getFontScale(); s_settingsState.font_scale = settings->getFontScale();
Layout::setUserFontScale(s_settingsState.font_scale); // sync with Layout on load Layout::setUserFontScale(s_settingsState.font_scale); // sync with Layout on load
@@ -444,11 +443,20 @@ static void loadSettingsPageState(config::Settings* settings) {
snprintf(s_settingsState.rpc_password, sizeof(s_settingsState.rpc_password), "%s", rpcCfg.rpcpassword.c_str()); snprintf(s_settingsState.rpc_password, sizeof(s_settingsState.rpc_password), "%s", rpcCfg.rpcpassword.c_str());
s_settingsState.rpc_plaintext_remote = rpc::Connection::usesPlaintextRemote(rpcCfg); s_settingsState.rpc_plaintext_remote = rpc::Connection::usesPlaintextRemote(rpcCfg);
// Apply loaded visual effects settings // Apply the loaded appearance prefs through the same low-spec-aware path as startup (it used to push
effects::ImGuiAcrylic::ApplyBlurAmount(s_settingsState.blur_amount); // the raw prefs, so opening Settings turned theme effects and blur back on under low-spec). Under
effects::ImGuiAcrylic::SetUIOpacity(s_settingsState.ui_opacity); // low-spec the controls show the overrides and the snapshot keeps the saved prefs, so unticking
effects::ImGuiAcrylic::SetNoiseOpacity(s_settingsState.noise_opacity); // low-spec restores them; enterLowSpec(false) only mirrors what applyVisualSettings applied.
effects::ThemeEffects::instance().setEnabled(s_settingsState.theme_effects_enabled); app->applyVisualSettings();
if (!s_settingsState.low_spec_mode) {
s_settingsState.low_spec_snapshot.valid = false;
} else {
// Keep a snapshot already taken this session (a Reload after ticking low-spec here): it still
// holds the prefs from before low-spec, e.g. the window opacity low-spec saved as 1.0.
const LowSpecSnapshot kept = s_settingsState.low_spec_snapshot;
enterLowSpec(false);
if (kept.valid) s_settingsState.low_spec_snapshot = kept;
}
s_settingsState.initialized = true; s_settingsState.initialized = true;
} }
@@ -473,16 +481,22 @@ static void saveSettingsPageState(config::Settings* settings) {
settings->setLanguage(it->first); settings->setLanguage(it->first);
} }
// Visual effects settings // Visual effects settings. Under low-spec the controls show the low-spec overrides; persist the
settings->setAcrylicEnabled(s_settingsState.acrylic_enabled); // user's real prefs (held in the snapshot) instead, so low-spec stays a runtime-only override and
settings->setAcrylicQuality(s_settingsState.blur_amount > 0.001f ? static_cast<int>(effects::AcrylicQuality::Low) : static_cast<int>(effects::AcrylicQuality::Off)); // turning it off restores them, the same as the hotkey.
settings->setBlurMultiplier(s_settingsState.blur_amount); const bool lowSpecOverrides = s_settingsState.low_spec_mode && s_settingsState.low_spec_snapshot.valid;
settings->setUIOpacity(s_settingsState.ui_opacity); const LowSpecSnapshot& realPrefs = s_settingsState.low_spec_snapshot;
settings->setWindowOpacity(s_settingsState.window_opacity); const float blur = lowSpecOverrides ? realPrefs.blur_amount : s_settingsState.blur_amount;
settings->setAcrylicEnabled(lowSpecOverrides ? realPrefs.acrylic_enabled : s_settingsState.acrylic_enabled);
settings->setAcrylicQuality(blur > 0.001f ? static_cast<int>(effects::AcrylicQuality::Low) : static_cast<int>(effects::AcrylicQuality::Off));
settings->setBlurMultiplier(blur);
settings->setUIOpacity(lowSpecOverrides ? realPrefs.ui_opacity : s_settingsState.ui_opacity);
settings->setWindowOpacity(s_settingsState.window_opacity); // 1.0 under low-spec, as the hotkey saves it
settings->setNoiseOpacity(s_settingsState.noise_opacity); settings->setNoiseOpacity(s_settingsState.noise_opacity);
settings->setGradientBackground(s_settingsState.gradient_background); settings->setGradientBackground(s_settingsState.gradient_background);
settings->setScanlineEnabled(s_settingsState.scanline_enabled); settings->setScanlineEnabled(lowSpecOverrides ? realPrefs.scanline_enabled : s_settingsState.scanline_enabled);
settings->setThemeEffectsEnabled(s_settingsState.theme_effects_enabled); settings->setThemeEffectsEnabled(lowSpecOverrides ? realPrefs.theme_effects_enabled
: s_settingsState.theme_effects_enabled);
settings->setLowSpecMode(s_settingsState.low_spec_mode); settings->setLowSpecMode(s_settingsState.low_spec_mode);
settings->setReduceMotion(s_settingsState.reduce_motion); settings->setReduceMotion(s_settingsState.reduce_motion);
settings->setFontScale(s_settingsState.font_scale); settings->setFontScale(s_settingsState.font_scale);
@@ -616,7 +630,7 @@ static void renderSettingsTabBar(float availWidth) {
void RenderSettingsPage(App* app) { void RenderSettingsPage(App* app) {
// Load settings state on first render // Load settings state on first render
if (!s_settingsState.initialized && app->settings()) { if (!s_settingsState.initialized && app->settings()) {
loadSettingsPageState(app->settings()); loadSettingsPageState(app);
} }
// Sync low-spec / theme-effects state from runtime each frame // Sync low-spec / theme-effects state from runtime each frame
@@ -1022,6 +1036,9 @@ void RenderSettingsPage(App* app) {
efFlow(TR("theme_effects")); efFlow(TR("theme_effects"));
if (ImGui::Checkbox(TrId("theme_effects", "effects").c_str(), &s_settingsState.theme_effects_enabled)) { if (ImGui::Checkbox(TrId("theme_effects", "effects").c_str(), &s_settingsState.theme_effects_enabled)) {
effects::ThemeEffects::instance().setEnabled(s_settingsState.theme_effects_enabled); effects::ThemeEffects::instance().setEnabled(s_settingsState.theme_effects_enabled);
// Paired with the enable flag everywhere (startup, hotkeys): off also drops the
// translucent rainbow/shimmer/glare layers, so turning effects on has to restore them.
effects::ThemeEffects::instance().setReducedTransparency(!s_settingsState.theme_effects_enabled);
saveSettingsPageState(app->settings()); saveSettingsPageState(app->settings());
} }
if (ImGui::IsItemHovered()) material::Tooltip("%s", TR("tt_theme_effects")); if (ImGui::IsItemHovered()) material::Tooltip("%s", TR("tt_theme_effects"));
@@ -2664,7 +2681,7 @@ void RenderSettingsPage(App* app) {
if (ImGui::IsItemHovered()) material::Tooltip("%s", TR("tt_save_settings")); if (ImGui::IsItemHovered()) material::Tooltip("%s", TR("tt_save_settings"));
af.next(material::ActionButtonWidth(TR("reset_to_defaults"), ICON_MD_RESTORE)); af.next(material::ActionButtonWidth(TR("reset_to_defaults"), ICON_MD_RESTORE));
if (material::ActionButton("##aboutreset", TR("reset_to_defaults"), ICON_MD_RESTORE, AT::Tertiary)) { if (material::ActionButton("##aboutreset", TR("reset_to_defaults"), ICON_MD_RESTORE, AT::Tertiary)) {
if (app->settings()) { loadSettingsPageState(app->settings()); Notifications::instance().info(TR("settings_reloaded")); } if (app->settings()) { loadSettingsPageState(app); Notifications::instance().info(TR("settings_reloaded")); }
} }
if (ImGui::IsItemHovered()) material::Tooltip("%s", TR("tt_reset_settings")); if (ImGui::IsItemHovered()) material::Tooltip("%s", TR("tt_reset_settings"));
} }