From 2775ab2868e6016e5f812a31c025c7eb57a88aeb Mon Sep 17 00:00:00 2001 From: Maximilian Seidler <78690852+PaideiaDilemma@users.noreply.github.com> Date: Tue, 12 Nov 2024 14:31:27 +0100 Subject: [PATCH] widgets: render frambuffers with alpha 1.0 (#554) * helpers: update CColor yoinked from Hyprland * image: fix border alpha * shape: fix border alpha --- src/helpers/Color.cpp | 4 ++-- src/helpers/Color.hpp | 5 +++-- src/renderer/widgets/Image.cpp | 2 +- src/renderer/widgets/Shape.cpp | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/helpers/Color.cpp b/src/helpers/Color.cpp index 77e0d53..f9a207b 100644 --- a/src/helpers/Color.cpp +++ b/src/helpers/Color.cpp @@ -21,6 +21,6 @@ CColor::CColor(uint64_t hex) { this->a = ALPHA(hex); } -uint64_t CColor::getAsHex() { - return ((int)a) * 0x1000000 + ((int)r) * 0x10000 + ((int)g) * 0x100 + ((int)b) * 0x1; +uint32_t CColor::getAsHex() const { + return (uint32_t)(a * 255.f) * 0x1000000 + (uint32_t)(r * 255.f) * 0x10000 + (uint32_t)(g * 255.f) * 0x100 + (uint32_t)(b * 255.f) * 0x1; } \ No newline at end of file diff --git a/src/helpers/Color.hpp b/src/helpers/Color.hpp index 98ffa47..32ed39e 100644 --- a/src/helpers/Color.hpp +++ b/src/helpers/Color.hpp @@ -8,9 +8,10 @@ class CColor { CColor(float r, float g, float b, float a); CColor(uint64_t); - float r = 0, g = 0, b = 0, a = 1.f; + float r = 0, g = 0, b = 0, a = 1.f; - uint64_t getAsHex(); + // AR32 + uint32_t getAsHex() const; CColor operator-(const CColor& c2) const { return CColor(r - c2.r, g - c2.g, b - c2.b, a - c2.a); diff --git a/src/renderer/widgets/Image.cpp b/src/renderer/widgets/Image.cpp index 8550826..db531d1 100644 --- a/src/renderer/widgets/Image.cpp +++ b/src/renderer/widgets/Image.cpp @@ -157,7 +157,7 @@ bool CImage::draw(const SRenderData& data) { if (border > 0) g_pRenderer->renderBorder(borderBox, color, border, ALLOWROUND ? (rounding == 0 ? 0 : rounding + std::round(border / M_PI)) : std::min(borderBox.w, borderBox.h) / 2.0, - data.opacity); + 1.0); texbox.round(); g_pRenderer->renderTexture(texbox, asset->texture, 1.0, ALLOWROUND ? rounding : std::min(texbox.w, texbox.h) / 2.0, HYPRUTILS_TRANSFORM_NORMAL); diff --git a/src/renderer/widgets/Shape.cpp b/src/renderer/widgets/Shape.cpp index c3773ea..48394d0 100644 --- a/src/renderer/widgets/Shape.cpp +++ b/src/renderer/widgets/Shape.cpp @@ -77,7 +77,7 @@ bool CShape::draw(const SRenderData& data) { glClear(GL_COLOR_BUFFER_BIT); if (border > 0) - g_pRenderer->renderBorder(borderBox, borderGrad, border, ALLOWROUND ? (rounding == 0 ? 0 : rounding + std::round(border / M_PI)) : MINHALFBORDER, data.opacity); + g_pRenderer->renderBorder(borderBox, borderGrad, border, ALLOWROUND ? (rounding == 0 ? 0 : rounding + std::round(border / M_PI)) : MINHALFBORDER, 1.0); g_pRenderer->renderRect(shapeBox, color, ALLOWROUND ? rounding : MINHALFSHAPE); g_pRenderer->popFb();