summaryrefslogtreecommitdiff
path: root/src/render/decorations/CHyprDropShadowDecoration.cpp
diff options
context:
space:
mode:
authorVaxry <vaxry@vaxry.net>2024-03-03 18:39:20 +0000
committerVaxry <vaxry@vaxry.net>2024-03-03 18:41:38 +0000
commit063708df26e8b930f492200e1907eb47950f50e6 (patch)
tree31648b7148213ecb9c6d469148ac1c5061835d5a /src/render/decorations/CHyprDropShadowDecoration.cpp
parent8ccbd272cc5f3a98280d4e050f456d25aee47ee5 (diff)
config: improve config value infrastructure
Diffstat (limited to 'src/render/decorations/CHyprDropShadowDecoration.cpp')
-rw-r--r--src/render/decorations/CHyprDropShadowDecoration.cpp35
1 files changed, 18 insertions, 17 deletions
diff --git a/src/render/decorations/CHyprDropShadowDecoration.cpp b/src/render/decorations/CHyprDropShadowDecoration.cpp
index 8541e06e..588b23a4 100644
--- a/src/render/decorations/CHyprDropShadowDecoration.cpp
+++ b/src/render/decorations/CHyprDropShadowDecoration.cpp
@@ -1,6 +1,7 @@
#include "CHyprDropShadowDecoration.hpp"
#include "../../Compositor.hpp"
+#include "../../config/ConfigValue.hpp"
CHyprDropShadowDecoration::CHyprDropShadowDecoration(CWindow* pWindow) : IHyprWindowDecoration(pWindow) {
m_pWindow = pWindow;
@@ -35,9 +36,9 @@ std::string CHyprDropShadowDecoration::getDisplayName() {
}
void CHyprDropShadowDecoration::damageEntire() {
- static auto* const PSHADOWS = (Hyprlang::INT* const*)g_pConfigManager->getConfigValuePtr("decoration:drop_shadow");
+ static auto PSHADOWS = CConfigValue<Hyprlang::INT>("decoration:drop_shadow");
- if (**PSHADOWS != 1)
+ if (*PSHADOWS != 1)
return; // disabled
CBox dm = {m_vLastWindowPos.x - m_seExtents.topLeft.x, m_vLastWindowPos.y - m_seExtents.topLeft.y, m_vLastWindowSize.x + m_seExtents.topLeft.x + m_seExtents.bottomRight.x,
@@ -70,13 +71,13 @@ void CHyprDropShadowDecoration::draw(CMonitor* pMonitor, float a, const Vector2D
if (m_pWindow->m_sAdditionalConfigData.forceNoShadow)
return;
- static auto* const PSHADOWS = (Hyprlang::INT* const*)g_pConfigManager->getConfigValuePtr("decoration:drop_shadow");
- static auto* const PSHADOWSIZE = (Hyprlang::INT* const*)g_pConfigManager->getConfigValuePtr("decoration:shadow_range");
- static auto* const PSHADOWIGNOREWINDOW = (Hyprlang::INT* const*)g_pConfigManager->getConfigValuePtr("decoration:shadow_ignore_window");
- static auto* const PSHADOWSCALE = (Hyprlang::FLOAT* const*)g_pConfigManager->getConfigValuePtr("decoration:shadow_scale");
- static auto* const PSHADOWOFFSET = (Hyprlang::VEC2* const*)g_pConfigManager->getConfigValuePtr("decoration:shadow_offset");
+ static auto PSHADOWS = CConfigValue<Hyprlang::INT>("decoration:drop_shadow");
+ static auto PSHADOWSIZE = CConfigValue<Hyprlang::INT>("decoration:shadow_range");
+ static auto PSHADOWIGNOREWINDOW = CConfigValue<Hyprlang::INT>("decoration:shadow_ignore_window");
+ static auto PSHADOWSCALE = CConfigValue<Hyprlang::FLOAT>("decoration:shadow_scale");
+ static auto PSHADOWOFFSET = CConfigValue<Hyprlang::VEC2>("decoration:shadow_offset");
- if (**PSHADOWS != 1)
+ if (*PSHADOWS != 1)
return; // disabled
const auto ROUNDINGBASE = m_pWindow->rounding();
@@ -87,15 +88,15 @@ void CHyprDropShadowDecoration::draw(CMonitor* pMonitor, float a, const Vector2D
// draw the shadow
CBox fullBox = m_bLastWindowBoxWithDecos;
fullBox.translate(-pMonitor->vecPosition + WORKSPACEOFFSET);
- fullBox.x -= **PSHADOWSIZE;
- fullBox.y -= **PSHADOWSIZE;
- fullBox.w += 2 * **PSHADOWSIZE;
- fullBox.h += 2 * **PSHADOWSIZE;
+ fullBox.x -= *PSHADOWSIZE;
+ fullBox.y -= *PSHADOWSIZE;
+ fullBox.w += 2 * *PSHADOWSIZE;
+ fullBox.h += 2 * *PSHADOWSIZE;
- const float SHADOWSCALE = std::clamp(**PSHADOWSCALE, 0.f, 1.f);
+ const float SHADOWSCALE = std::clamp(*PSHADOWSCALE, 0.f, 1.f);
// scale the box in relation to the center of the box
- fullBox.scaleFromCenter(SHADOWSCALE).translate(**PSHADOWOFFSET);
+ fullBox.scaleFromCenter(SHADOWSCALE).translate(*PSHADOWOFFSET);
m_vLastWindowPos += WORKSPACEOFFSET;
m_seExtents = {{m_vLastWindowPos.x - fullBox.x - pMonitor->vecPosition.x + 2, m_vLastWindowPos.y - fullBox.y - pMonitor->vecPosition.y + 2},
@@ -116,7 +117,7 @@ void CHyprDropShadowDecoration::draw(CMonitor* pMonitor, float a, const Vector2D
fullBox.scale(pMonitor->scale).round();
- if (**PSHADOWIGNOREWINDOW) {
+ if (*PSHADOWIGNOREWINDOW) {
CBox windowBox = m_bLastWindowBox;
CBox withDecos = m_bLastWindowBoxWithDecos;
@@ -147,7 +148,7 @@ void CHyprDropShadowDecoration::draw(CMonitor* pMonitor, float a, const Vector2D
g_pHyprOpenGL->renderRect(&fullBox, CColor(0, 0, 0, 1), 0);
// render white shadow with the alpha of the shadow color (otherwise we clear with alpha later and shit it to 2 bit)
- g_pHyprOpenGL->renderRoundedShadow(&fullBox, ROUNDING * pMonitor->scale, **PSHADOWSIZE * pMonitor->scale, CColor(1, 1, 1, m_pWindow->m_cRealShadowColor.value().a), a);
+ g_pHyprOpenGL->renderRoundedShadow(&fullBox, ROUNDING * pMonitor->scale, *PSHADOWSIZE * pMonitor->scale, CColor(1, 1, 1, m_pWindow->m_cRealShadowColor.value().a), a);
// render black window box ("clip")
g_pHyprOpenGL->renderRect(&windowBox, CColor(0, 0, 0, 1.0), ROUNDING * pMonitor->scale);
@@ -166,7 +167,7 @@ void CHyprDropShadowDecoration::draw(CMonitor* pMonitor, float a, const Vector2D
g_pHyprOpenGL->m_RenderData.damage = saveDamage;
} else {
- g_pHyprOpenGL->renderRoundedShadow(&fullBox, ROUNDING * pMonitor->scale, **PSHADOWSIZE * pMonitor->scale, m_pWindow->m_cRealShadowColor.value(), a);
+ g_pHyprOpenGL->renderRoundedShadow(&fullBox, ROUNDING * pMonitor->scale, *PSHADOWSIZE * pMonitor->scale, m_pWindow->m_cRealShadowColor.value(), a);
}
if (m_seExtents != m_seReportedExtents)