normalize gradients and denormalize in groupbar

This commit is contained in:
Vaxry 2022-12-31 17:31:33 +01:00
parent 228e630f40
commit ddcae74e09
2 changed files with 5 additions and 5 deletions

View File

@ -2,8 +2,7 @@
#include "../defines.hpp" #include "../defines.hpp"
#include <vector> #include <vector>
enum eConfigValueDataTypes enum eConfigValueDataTypes {
{
CVD_TYPE_INVALID = -1, CVD_TYPE_INVALID = -1,
CVD_TYPE_GRADIENT = 0 CVD_TYPE_GRADIENT = 0
}; };
@ -18,7 +17,7 @@ interface ICustomConfigValueData {
class CGradientValueData : public ICustomConfigValueData { class CGradientValueData : public ICustomConfigValueData {
public: public:
CGradientValueData(CColor col) { CGradientValueData(CColor col) {
m_vColors.push_back(col); m_vColors.push_back(col * (1.f / 255.f));
}; };
virtual ~CGradientValueData(){}; virtual ~CGradientValueData(){};
@ -28,7 +27,7 @@ class CGradientValueData : public ICustomConfigValueData {
void reset(CColor col) { void reset(CColor col) {
m_vColors.clear(); m_vColors.clear();
m_vColors.emplace_back(col); m_vColors.emplace_back(col * (1.f / 255.f));
m_fAngle = 0; m_fAngle = 0;
} }
@ -39,7 +38,7 @@ class CGradientValueData : public ICustomConfigValueData {
float m_fAngle = 0; float m_fAngle = 0;
bool operator==(const CGradientValueData& other) { bool operator==(const CGradientValueData& other) {
if (other.m_vColors.size() != m_vColors.size() || m_fAngle != other.m_fAngle) if (other.m_vColors.size() != m_vColors.size() || m_fAngle != other.m_fAngle)
return false; return false;
for (size_t i = 0; i < m_vColors.size(); ++i) for (size_t i = 0; i < m_vColors.size(); ++i)

View File

@ -92,6 +92,7 @@ void CHyprGroupBarDecoration::draw(CMonitor* pMonitor, float a, const Vector2D&
CColor color = m_dwGroupMembers[i] == g_pCompositor->m_pLastWindow ? ((CGradientValueData*)PGROUPCOLACTIVE->get())->m_vColors[0] : CColor color = m_dwGroupMembers[i] == g_pCompositor->m_pLastWindow ? ((CGradientValueData*)PGROUPCOLACTIVE->get())->m_vColors[0] :
((CGradientValueData*)PGROUPCOLINACTIVE->get())->m_vColors[0]; ((CGradientValueData*)PGROUPCOLINACTIVE->get())->m_vColors[0];
color.a *= a; color.a *= a;
color = color * 255.f; // gradient has 0 - 1
g_pHyprOpenGL->renderRect(&rect, color); g_pHyprOpenGL->renderRect(&rect, color);
xoff += PAD + BARW; xoff += PAD + BARW;