Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

input-field: fix colorConfig caps, num and both when they are empty #559

Merged
merged 1 commit into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/config/ConfigDataValues.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ class CGradientValueData : public ICustomConfigValueData {
/* Float corresponding to the angle (rad) */
float m_fAngle = 0;

//
/* Whether this gradient stores a fallback value (not exlicitly set) */
bool m_bIsFallback = false;

bool operator==(const CGradientValueData& other) const {
if (other.m_vColors.size() != m_vColors.size() || m_fAngle != other.m_fAngle)
return false;
Expand Down
6 changes: 6 additions & 0 deletions src/config/ConfigManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ static Hyprlang::CParseResult configHandleGradientSet(const char* VALUE, void**

CVarList varlist(V, 0, ' ');
DATA->m_vColors.clear();
DATA->m_bIsFallback = false;

std::string parseError = "";

Expand Down Expand Up @@ -110,6 +111,11 @@ static Hyprlang::CParseResult configHandleGradientSet(const char* VALUE, void**
}
}

if (V.empty()) {
DATA->m_bIsFallback = true;
DATA->m_vColors.push_back(0); // transparent
}

if (DATA->m_vColors.size() == 0) {
Debug::log(WARN, "Error parsing gradient {}", V);
parseError = "Error parsing gradient " + V + ": No colors?";
Expand Down
7 changes: 3 additions & 4 deletions src/renderer/widgets/PasswordInputField.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,9 @@ CPasswordInputField::CPasswordInputField(const Vector2D& viewport_, const std::u
dots.size = std::clamp(dots.size, 0.2f, 0.8f);
dots.spacing = std::clamp(dots.spacing, -1.f, 1.f);
colorConfig.transitionMs = std::clamp(colorConfig.transitionMs, 0, 1000);

colorConfig.both = colorConfig.both->m_vColors.empty() ? colorConfig.outer : colorConfig.both;
colorConfig.caps = colorConfig.caps->m_vColors.empty() ? colorConfig.outer : colorConfig.caps;
colorConfig.num = colorConfig.num->m_vColors.empty() ? colorConfig.outer : colorConfig.num;
colorConfig.both = colorConfig.both->m_bIsFallback ? colorConfig.outer : colorConfig.both;
colorConfig.caps = colorConfig.caps->m_bIsFallback ? colorConfig.outer : colorConfig.caps;
colorConfig.num = colorConfig.num->m_bIsFallback ? colorConfig.outer : colorConfig.num;

colorState.inner = colorConfig.inner;
colorState.outer = *colorConfig.outer;
Expand Down