mirror of
https://github.com/hyprwm/hyprlock.git
synced 2024-11-16 23:05:58 +01:00
input-field: Add rounding option (#127)
* input-field: add rounding option * add rounding option to nix home manager module
This commit is contained in:
parent
6a085d7f8e
commit
49ef1d306c
4 changed files with 13 additions and 3 deletions
|
@ -217,6 +217,12 @@ in {
|
|||
default = false;
|
||||
};
|
||||
|
||||
rounding = mkOption {
|
||||
description = "The rounding of the input field";
|
||||
type = int;
|
||||
default = -1;
|
||||
};
|
||||
|
||||
position = {
|
||||
x = mkOption {
|
||||
description = "X position of the label";
|
||||
|
|
|
@ -68,6 +68,7 @@ void CConfigManager::init() {
|
|||
m_config.addSpecialConfigValue("input-field", "position", Hyprlang::VEC2{0, -20});
|
||||
m_config.addSpecialConfigValue("input-field", "placeholder_text", Hyprlang::STRING{"<i>Input Password</i>"});
|
||||
m_config.addSpecialConfigValue("input-field", "hide_input", Hyprlang::INT{0});
|
||||
m_config.addSpecialConfigValue("input-field", "rounding", Hyprlang::INT{-1});
|
||||
|
||||
m_config.addSpecialCategory("label", Hyprlang::SSpecialCategoryOptions{.key = nullptr, .anonymousKeyBased = true});
|
||||
m_config.addSpecialConfigValue("label", "monitor", Hyprlang::STRING{""});
|
||||
|
@ -142,6 +143,7 @@ std::vector<CConfigManager::SWidgetConfig> CConfigManager::getWidgetConfigs() {
|
|||
{"position", m_config.getSpecialConfigValue("input-field", "position", k.c_str())},
|
||||
{"placeholder_text", m_config.getSpecialConfigValue("input-field", "placeholder_text", k.c_str())},
|
||||
{"hide_input", m_config.getSpecialConfigValue("input-field", "hide_input", k.c_str())},
|
||||
{"rounding", m_config.getSpecialConfigValue("input-field", "rounding", k.c_str())},
|
||||
}
|
||||
});
|
||||
// clang-format on
|
||||
|
|
|
@ -15,6 +15,7 @@ CPasswordInputField::CPasswordInputField(const Vector2D& viewport_, const std::u
|
|||
font = std::any_cast<Hyprlang::INT>(props.at("font_color"));
|
||||
pos = std::any_cast<Hyprlang::VEC2>(props.at("position"));
|
||||
hiddenInputState.enabled = std::any_cast<Hyprlang::INT>(props.at("hide_input"));
|
||||
rounding = std::any_cast<Hyprlang::INT>(props.at("rounding"));
|
||||
viewport = viewport_;
|
||||
|
||||
pos = posFromHVAlign(viewport, size, pos, std::any_cast<Hyprlang::STRING>(props.at("halign")), std::any_cast<Hyprlang::STRING>(props.at("valign")));
|
||||
|
@ -119,7 +120,7 @@ bool CPasswordInputField::draw(const SRenderData& data) {
|
|||
CColor fontCol = font;
|
||||
fontCol.a *= fade.a * data.opacity * passAlpha;
|
||||
|
||||
g_pRenderer->renderRect(outerBox, outerCol, outerBox.h / 2.0);
|
||||
g_pRenderer->renderRect(outerBox, outerCol, rounding == -1 ? outerBox.h / 2.0 : rounding);
|
||||
|
||||
const auto PASSLEN = g_pHyprlock->getPasswordBufferLen();
|
||||
|
||||
|
@ -133,12 +134,12 @@ bool CPasswordInputField::draw(const SRenderData& data) {
|
|||
outerBoxScaled.x += outerBoxScaled.w;
|
||||
glEnable(GL_SCISSOR_TEST);
|
||||
glScissor(outerBoxScaled.x, outerBoxScaled.y, outerBoxScaled.w, outerBoxScaled.h);
|
||||
g_pRenderer->renderRect(outerBox, hiddenInputState.lastColor, outerBox.h / 2.0);
|
||||
g_pRenderer->renderRect(outerBox, hiddenInputState.lastColor, rounding == -1 ? outerBox.h / 2.0 : rounding);
|
||||
glScissor(0, 0, viewport.x, viewport.y);
|
||||
glDisable(GL_SCISSOR_TEST);
|
||||
}
|
||||
|
||||
g_pRenderer->renderRect(inputFieldBox, innerCol, inputFieldBox.h / 2.0);
|
||||
g_pRenderer->renderRect(inputFieldBox, innerCol, rounding == -1 ? inputFieldBox.h / 2.0 : rounding - out_thick);
|
||||
|
||||
const int PASS_SIZE = std::nearbyint(inputFieldBox.h * dt_size * 0.5f) * 2.f;
|
||||
const int PASS_SPACING = std::floor(PASS_SIZE * dt_space);
|
||||
|
|
|
@ -63,4 +63,5 @@ class CPasswordInputField : public IWidget {
|
|||
} hiddenInputState;
|
||||
|
||||
bool fadeOnEmpty;
|
||||
int rounding;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue