diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp
index f130b80..e1b8fec 100644
--- a/src/config/ConfigManager.cpp
+++ b/src/config/ConfigManager.cpp
@@ -37,6 +37,7 @@ void CConfigManager::init() {
m_config.addSpecialConfigValue("input-field", "halign", Hyprlang::STRING{"center"});
m_config.addSpecialConfigValue("input-field", "valign", Hyprlang::STRING{"center"});
m_config.addSpecialConfigValue("input-field", "position", Hyprlang::VEC2{0, -20});
+ m_config.addSpecialConfigValue("input-field", "placeholder_text", Hyprlang::STRING{"Input Password"});
m_config.addSpecialCategory("label", Hyprlang::SSpecialCategoryOptions{.key = nullptr, .anonymousKeyBased = true});
m_config.addSpecialConfigValue("label", "monitor", Hyprlang::STRING{""});
@@ -97,6 +98,7 @@ std::vector CConfigManager::getWidgetConfigs() {
{"halign", m_config.getSpecialConfigValue("input-field", "halign", k.c_str())},
{"valign", m_config.getSpecialConfigValue("input-field", "valign", k.c_str())},
{"position", m_config.getSpecialConfigValue("input-field", "position", k.c_str())},
+ {"placeholder_text", m_config.getSpecialConfigValue("input-field", "placeholder_text", k.c_str())},
}
});
// clang-format on
diff --git a/src/renderer/widgets/PasswordInputField.cpp b/src/renderer/widgets/PasswordInputField.cpp
index c686e25..63c4e27 100644
--- a/src/renderer/widgets/PasswordInputField.cpp
+++ b/src/renderer/widgets/PasswordInputField.cpp
@@ -13,6 +13,19 @@ CPasswordInputField::CPasswordInputField(const Vector2D& viewport, const std::un
pos = std::any_cast(props.at("position"));
pos = posFromHVAlign(viewport, size, pos, std::any_cast(props.at("halign")), std::any_cast(props.at("valign")));
+
+ std::string placeholderText = std::any_cast(props.at("placeholder_text"));
+ if (!placeholderText.empty()) {
+ placeholder.resourceID = "placeholder:" + std::to_string((uintptr_t)this);
+ CAsyncResourceGatherer::SPreloadRequest request;
+ request.id = placeholder.resourceID;
+ request.asset = placeholderText;
+ request.type = CAsyncResourceGatherer::eTargetType::TARGET_TEXT;
+ request.props["font_family"] = std::string{"Sans"};
+ request.props["color"] = CColor{1.0 - font.r, 1.0 - font.g, 1.0 - font.b, 0.5};
+ request.props["font_size"] = 12;
+ g_pRenderer->asyncResourceGatherer->requestAsyncAssetPreload(request);
+ }
}
void CPasswordInputField::updateFade() {
@@ -105,5 +118,17 @@ bool CPasswordInputField::draw(const SRenderData& data) {
const auto PASSLEN = g_pHyprlock->getPasswordBufferLen();
+ if (PASSLEN == 0 && !placeholder.resourceID.empty()) {
+ if (!placeholder.asset)
+ placeholder.asset = g_pRenderer->asyncResourceGatherer->getAssetByID(placeholder.resourceID);
+
+ if (placeholder.asset) {
+ Vector2D pos = outerBox.pos() + outerBox.size() / 2.f;
+ pos = pos - placeholder.asset->texture.m_vSize / 2.f;
+ CBox textbox{pos, placeholder.asset->texture.m_vSize};
+ g_pRenderer->renderTexture(textbox, placeholder.asset->texture, data.opacity * fade.a, 0);
+ }
+ }
+
return dots.currentAmount != PASSLEN || data.opacity < 1.0 || fade.a < 1.0;
}
\ No newline at end of file
diff --git a/src/renderer/widgets/PasswordInputField.hpp b/src/renderer/widgets/PasswordInputField.hpp
index de7ad7a..77d1ff2 100644
--- a/src/renderer/widgets/PasswordInputField.hpp
+++ b/src/renderer/widgets/PasswordInputField.hpp
@@ -8,6 +8,8 @@
#include
#include
+struct SPreloadedAsset;
+
class CPasswordInputField : public IWidget {
public:
CPasswordInputField(const Vector2D& viewport, const std::unordered_map& props);
@@ -38,5 +40,10 @@ class CPasswordInputField : public IWidget {
bool animated = false;
} fade;
+ struct {
+ std::string resourceID = "";
+ SPreloadedAsset* asset = nullptr;
+ } placeholder;
+
bool fadeOnEmpty;
};
\ No newline at end of file