mirror of
https://github.com/hyprwm/hyprlock.git
synced 2024-12-22 21:39:47 +01:00
renderer: add text trim with option to disable (#310)
* renderer: add text trim with option to disable * refactor: format CAsyncResourceGatherer::renderText * config: change disable_text_trim to text_trim
This commit is contained in:
parent
21226c1206
commit
c87af3aa1f
2 changed files with 15 additions and 7 deletions
|
@ -44,6 +44,7 @@ void CConfigManager::init() {
|
||||||
m_config.addSpecialConfigValue(name, "shadow_boost", Hyprlang::FLOAT{1.2});
|
m_config.addSpecialConfigValue(name, "shadow_boost", Hyprlang::FLOAT{1.2});
|
||||||
|
|
||||||
m_config.addConfigValue("general:disable_loading_bar", Hyprlang::INT{0});
|
m_config.addConfigValue("general:disable_loading_bar", Hyprlang::INT{0});
|
||||||
|
m_config.addConfigValue("general:text_trim", Hyprlang::INT{1});
|
||||||
m_config.addConfigValue("general:hide_cursor", Hyprlang::INT{0});
|
m_config.addConfigValue("general:hide_cursor", Hyprlang::INT{0});
|
||||||
m_config.addConfigValue("general:grace", Hyprlang::INT{0});
|
m_config.addConfigValue("general:grace", Hyprlang::INT{0});
|
||||||
m_config.addConfigValue("general:no_fade_in", Hyprlang::INT{0});
|
m_config.addConfigValue("general:no_fade_in", Hyprlang::INT{0});
|
||||||
|
|
|
@ -281,7 +281,14 @@ void CAsyncResourceGatherer::renderText(const SPreloadRequest& rq) {
|
||||||
const CColor FONTCOLOR = rq.props.contains("color") ? std::any_cast<CColor>(rq.props.at("color")) : CColor(1.0, 1.0, 1.0, 1.0);
|
const CColor FONTCOLOR = rq.props.contains("color") ? std::any_cast<CColor>(rq.props.at("color")) : CColor(1.0, 1.0, 1.0, 1.0);
|
||||||
const std::string FONTFAMILY = rq.props.contains("font_family") ? std::any_cast<std::string>(rq.props.at("font_family")) : "Sans";
|
const std::string FONTFAMILY = rq.props.contains("font_family") ? std::any_cast<std::string>(rq.props.at("font_family")) : "Sans";
|
||||||
const bool ISCMD = rq.props.contains("cmd") ? std::any_cast<bool>(rq.props.at("cmd")) : false;
|
const bool ISCMD = rq.props.contains("cmd") ? std::any_cast<bool>(rq.props.at("cmd")) : false;
|
||||||
const std::string TEXT = ISCMD ? g_pHyprlock->spawnSync(rq.asset) : rq.asset;
|
|
||||||
|
static auto* const TRIM = (Hyprlang::INT* const*)g_pConfigManager->getValuePtr("general:text_trim");
|
||||||
|
std::string TEXT = ISCMD ? g_pHyprlock->spawnSync(rq.asset) : rq.asset;
|
||||||
|
|
||||||
|
if (**TRIM) {
|
||||||
|
TEXT.erase(0, TEXT.find_first_not_of(" \n\r\t"));
|
||||||
|
TEXT.erase(TEXT.find_last_not_of(" \n\r\t") + 1);
|
||||||
|
}
|
||||||
|
|
||||||
auto CAIROSURFACE = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 1920, 1080 /* dummy value */);
|
auto CAIROSURFACE = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 1920, 1080 /* dummy value */);
|
||||||
auto CAIRO = cairo_create(CAIROSURFACE);
|
auto CAIRO = cairo_create(CAIROSURFACE);
|
||||||
|
|
Loading…
Reference in a new issue