From 72735ae6352085ef842f6ed496889115afd76ce4 Mon Sep 17 00:00:00 2001 From: MightyPlaza <123664421+MightyPlaza@users.noreply.github.com> Date: Sun, 8 Oct 2023 00:29:15 +0000 Subject: [PATCH] feat: add splash_offset (#98) closes: #96 --- README.md | 2 ++ src/Hyprpaper.cpp | 4 ++-- src/Hyprpaper.hpp | 1 + src/config/ConfigManager.cpp | 8 +++++++- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index a7d44c5..04105d8 100644 --- a/README.md +++ b/README.md @@ -124,6 +124,8 @@ in the config. # Misc You can set `splash = true` to enable the splash rendering over the wallpaper. +The value for `splash_offset` sets, in percentage, the splash rendering offset relative to the bottom of the display. + ## Unloading If you use a lot of wallpapers, consider unloading those that you no longer need. This will mean you need to load them again if you wish to use them for a second time, but will free the memory used by the preloaded bitmap. (Usually 8 - 20MB, depending on the resolution) diff --git a/src/Hyprpaper.cpp b/src/Hyprpaper.cpp index 7a9b108..935f345 100644 --- a/src/Hyprpaper.cpp +++ b/src/Hyprpaper.cpp @@ -541,9 +541,9 @@ void CHyprpaper::renderWallpaperForMonitor(SMonitor* pMonitor) { cairo_text_extents_t textExtents; cairo_text_extents(PCAIRO, SPLASH.c_str(), &textExtents); - cairo_move_to(PCAIRO, ((DIMENSIONS.x - textExtents.width * scale) / 2.0) / scale, (DIMENSIONS.y * 0.99 - textExtents.height * scale) / scale); + cairo_move_to(PCAIRO, ((DIMENSIONS.x - textExtents.width * scale) / 2.0) / scale, ((DIMENSIONS.y * (100 - m_fSplashOffset)) / 100 - textExtents.height * scale) / scale); - Debug::log(LOG, "Splash font size: %d, pos: %.2f, %.2f", FONTSIZE, (DIMENSIONS.x - textExtents.width) / 2.0 / scale, DIMENSIONS.y * 0.95 - textExtents.height / scale); + Debug::log(LOG, "Splash font size: %d, pos: %.2f, %.2f", FONTSIZE, (DIMENSIONS.x - textExtents.width) / 2.0 / scale, ((DIMENSIONS.y * (100 - m_fSplashOffset)) / 100 - textExtents.height * scale) / scale); cairo_show_text(PCAIRO, SPLASH.c_str()); diff --git a/src/Hyprpaper.hpp b/src/Hyprpaper.hpp index 16a173d..10dc569 100644 --- a/src/Hyprpaper.hpp +++ b/src/Hyprpaper.hpp @@ -38,6 +38,7 @@ public: bool m_bIPCEnabled = true; bool m_bRenderSplash = false; + float m_fSplashOffset = 2; std::string m_szExplicitConfigPath; bool m_bNoFractionalScale = false; diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index f82e1b7..c370c17 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -113,7 +113,13 @@ void CConfigManager::parseKeyword(const std::string& COMMAND, const std::string& g_pHyprpaper->m_bIPCEnabled = VALUE == "1" || VALUE == "yes" || VALUE == "on" || VALUE == "true"; else if (COMMAND == "splash") g_pHyprpaper->m_bRenderSplash = VALUE == "1" || VALUE == "yes" || VALUE == "on" || VALUE == "true"; - else + else if (COMMAND == "splash_offset") { + try { + g_pHyprpaper->m_fSplashOffset = std::clamp(std::stof(VALUE), 0.f, 100.f); + } catch (std::exception& e) { + parseError = "invalid splash_offset value " + VALUE; + } + } else parseError = "unknown keyword " + COMMAND; }