feat: add splash_offset (#98)

closes: #96
This commit is contained in:
MightyPlaza 2023-10-08 00:29:15 +00:00 committed by GitHub
parent e5a18a171d
commit 72735ae635
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 3 deletions

View File

@ -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)

View File

@ -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());

View File

@ -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;

View File

@ -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;
}