From a19e0996bbd7a92a220640b50f861c2b6f01b506 Mon Sep 17 00:00:00 2001 From: nakst <> Date: Mon, 13 Sep 2021 09:28:45 +0100 Subject: [PATCH] enable hover state setting --- desktop/api.cpp | 1 + desktop/gui.cpp | 2 +- desktop/settings.cpp | 9 ++++++--- res/System Configuration Template.ini | 1 + shared/strings.cpp | 4 ++++ 5 files changed, 13 insertions(+), 4 deletions(-) diff --git a/desktop/api.cpp b/desktop/api.cpp index 9e61cf8..34de934 100644 --- a/desktop/api.cpp +++ b/desktop/api.cpp @@ -89,6 +89,7 @@ struct GlobalData { volatile float uiScale; volatile bool swapLeftAndRightButtons; volatile bool showCursorShadow; + volatile bool enableHoverState; }; struct ThreadLocalStorage { diff --git a/desktop/gui.cpp b/desktop/gui.cpp index a5726d5..234b27a 100644 --- a/desktop/gui.cpp +++ b/desktop/gui.cpp @@ -1793,7 +1793,7 @@ bool EsElement::RefreshStyleState() { if (((state & UI_STATE_LEFT_PRESSED) && ((state & UI_STATE_HOVERED) || gui.draggingStarted || (state & UI_STATE_STRONG_PRESSED))) || (state & UI_STATE_MENU_SOURCE)) { styleStateFlags |= THEME_PRIMARY_STATE_PRESSED; - } else if (((state & UI_STATE_HOVERED) && !window->pressed) || (window && window->pressed == this)) { + } else if (((state & UI_STATE_HOVERED) && !window->pressed && api.global->enableHoverState) || (window && window->pressed == this)) { styleStateFlags |= THEME_PRIMARY_STATE_HOVERED; } else { styleStateFlags |= THEME_PRIMARY_STATE_IDLE; diff --git a/desktop/settings.cpp b/desktop/settings.cpp index 3bb32f5..7c6f44b 100644 --- a/desktop/settings.cpp +++ b/desktop/settings.cpp @@ -134,6 +134,7 @@ void SettingsUpdateGlobalAndWindowManager() { api.global->clickChainTimeoutMs = EsSystemConfigurationReadInteger(EsLiteral("general"), EsLiteral("click_chain_timeout_ms")); api.global->swapLeftAndRightButtons = EsSystemConfigurationReadInteger(EsLiteral("general"), EsLiteral("swap_left_and_right_buttons")); api.global->showCursorShadow = EsSystemConfigurationReadInteger(EsLiteral("general"), EsLiteral("show_cursor_shadow")); + api.global->enableHoverState = EsSystemConfigurationReadInteger(EsLiteral("general"), EsLiteral("enable_hover_state")); { float newUIScale = EsSystemConfigurationReadInteger(EsLiteral("general"), EsLiteral("ui_scale")) * 0.01f; @@ -637,7 +638,6 @@ void SettingsColorButtonCommand(EsInstance *, EsElement *element, EsCommand *) { EsMutexRelease(&api.systemConfigurationMutex); SettingsWindowColorUpdated(); desktop.configurationModified = true; - ConfigurationWriteToFile(); } void SettingsPageTheme(EsElement *element, SettingsPage *page) { @@ -653,7 +653,7 @@ void SettingsPageTheme(EsElement *element, SettingsPage *page) { EsPanel *table = EsPanelCreate(container, ES_CELL_H_CENTER | ES_PANEL_TABLE | ES_PANEL_HORIZONTAL, &styleSettingsTable); EsPanelSetBands(table, 2); - EsTextDisplayCreate(table, ES_CELL_H_RIGHT, 0, "Wallpaper:", -1); + EsTextDisplayCreate(table, ES_CELL_H_RIGHT, 0, INTERFACE_STRING(DesktopSettingsThemeWallpaper)); EsTextbox *textbox = EsTextboxCreate(table, ES_CELL_H_LEFT | ES_CELL_H_PUSH | ES_TEXTBOX_EDIT_BASED | ES_ELEMENT_FREE_USER_DATA, ES_STYLE_TEXTBOX_BORDERED_SINGLE); size_t currentWallpaperBytes; @@ -685,7 +685,7 @@ void SettingsPageTheme(EsElement *element, SettingsPage *page) { return 0; }; - EsTextDisplayCreate(table, ES_CELL_H_RIGHT, 0, "Window color:", -1); + EsTextDisplayCreate(table, ES_CELL_H_RIGHT, 0, INTERFACE_STRING(DesktopSettingsThemeWindowColor)); EsPanel *panel = EsPanelCreate(table, ES_CELL_H_LEFT | ES_PANEL_HORIZONTAL); uint8_t windowColor = EsSystemConfigurationReadInteger(EsLiteral("general"), EsLiteral("window_color")); @@ -696,6 +696,9 @@ void SettingsPageTheme(EsElement *element, SettingsPage *page) { button->messageUser = SettingsColorButtonMessage; EsButtonOnCommand(button, SettingsColorButtonCommand); } + + table = EsPanelCreate(container, ES_CELL_H_FILL, &styleSettingsCheckboxGroup); + SettingsAddCheckbox(table, INTERFACE_STRING(DesktopSettingsThemeEnableHoverState), 'H', "general", "enable_hover_state"); } SettingsPage settingsPages[] = { diff --git a/res/System Configuration Template.ini b/res/System Configuration Template.ini index 96d895b..1cb8268 100644 --- a/res/System Configuration Template.ini +++ b/res/System Configuration Template.ini @@ -8,6 +8,7 @@ show_cursor_shadow=1 scroll_lines_per_notch=3 ui_scale=100 window_color=3 +enable_hover_state=1 [ui] font_fallback=Inter diff --git a/shared/strings.cpp b/shared/strings.cpp index 5062064..610ac0a 100644 --- a/shared/strings.cpp +++ b/shared/strings.cpp @@ -133,6 +133,10 @@ DEFINE_INTERFACE_STRING(DesktopSettingsMouseCursorTrailsMany, "Many"); DEFINE_INTERFACE_STRING(DesktopSettingsDisplayUIScale, "Interface scale:"); +DEFINE_INTERFACE_STRING(DesktopSettingsThemeWindowColor, "Window color:"); +DEFINE_INTERFACE_STRING(DesktopSettingsThemeEnableHoverState, "Highlight the item the cursor is over"); +DEFINE_INTERFACE_STRING(DesktopSettingsThemeWallpaper, "Wallpaper"); + // File operations. DEFINE_INTERFACE_STRING(FileCannotSave, "The document was not saved.");