summaryrefslogtreecommitdiff
path: root/src/render/decorations
diff options
context:
space:
mode:
authorGartoxFR <ewan.chorynski@insa-lyon.fr>2024-03-02 01:35:17 +0100
committerGitHub <noreply@github.com>2024-03-02 00:35:17 +0000
commitb2c34404777ea0850f90f4c38f64484f03599d14 (patch)
tree60f42773d2d606ae2072884cb537c751a7ab4b0f /src/render/decorations
parentf115ba94d2ec6e093c94f425535b027bc570185e (diff)
animations: Refactor AnimatedVariable (#4911)
* animation: Refactor AnimatedVariable This commit decomposes the AnimatedVariable class into a base class with the common attribute to all variable types and a templated derived type containing strongly typed info on the type being animated. Access to the typed version is perfomed using the visitor pattern. A utility is provided to build a visitor on the fly using lambdas. Adding a new type to be animated should just be a matter of adding the typed in the list defined by the ANIMABLE_TYPES macro The size of the commit is justified by the API change in the AnimatedVariable class. No more vec(), fl() or col() method but a unified value() method. * animation: Remove visitor pattern * animation: Fix coding style * animation: Fix coding style
Diffstat (limited to 'src/render/decorations')
-rw-r--r--src/render/decorations/CHyprBorderDecoration.cpp8
-rw-r--r--src/render/decorations/CHyprDropShadowDecoration.cpp14
-rw-r--r--src/render/decorations/CHyprGroupBarDecoration.cpp2
-rw-r--r--src/render/decorations/DecorationPositioner.cpp4
4 files changed, 14 insertions, 14 deletions
diff --git a/src/render/decorations/CHyprBorderDecoration.cpp b/src/render/decorations/CHyprBorderDecoration.cpp
index 1ed6c144..93a1c34c 100644
--- a/src/render/decorations/CHyprBorderDecoration.cpp
+++ b/src/render/decorations/CHyprBorderDecoration.cpp
@@ -40,7 +40,7 @@ CBox CHyprBorderDecoration::assignedBoxGlobal() {
if (!PWORKSPACE)
return box;
- const auto WORKSPACEOFFSET = PWORKSPACE && !m_pWindow->m_bPinned ? PWORKSPACE->m_vRenderOffset.vec() : Vector2D();
+ const auto WORKSPACEOFFSET = PWORKSPACE && !m_pWindow->m_bPinned ? PWORKSPACE->m_vRenderOffset.value() : Vector2D();
return box.translate(WORKSPACEOFFSET);
}
@@ -58,10 +58,10 @@ void CHyprBorderDecoration::draw(CMonitor* pMonitor, float a, const Vector2D& of
auto grad = m_pWindow->m_cRealBorderColor;
const bool ANIMATED = m_pWindow->m_fBorderFadeAnimationProgress.isBeingAnimated();
- float a1 = a * (ANIMATED ? m_pWindow->m_fBorderFadeAnimationProgress.fl() : 1.f);
+ float a1 = a * (ANIMATED ? m_pWindow->m_fBorderFadeAnimationProgress.value() : 1.f);
if (m_pWindow->m_fBorderAngleAnimationProgress.getConfig()->pValues->internalEnabled) {
- grad.m_fAngle += m_pWindow->m_fBorderAngleAnimationProgress.fl() * M_PI * 2;
+ grad.m_fAngle += m_pWindow->m_fBorderAngleAnimationProgress.value() * M_PI * 2;
grad.m_fAngle = normalizeAngleRad(grad.m_fAngle);
}
@@ -71,7 +71,7 @@ void CHyprBorderDecoration::draw(CMonitor* pMonitor, float a, const Vector2D& of
g_pHyprOpenGL->renderBorder(&windowBox, grad, ROUNDING, borderSize, a1);
if (ANIMATED) {
- float a2 = a * (1.f - m_pWindow->m_fBorderFadeAnimationProgress.fl());
+ float a2 = a * (1.f - m_pWindow->m_fBorderFadeAnimationProgress.value());
g_pHyprOpenGL->renderBorder(&windowBox, m_pWindow->m_cRealBorderColorPrevious, ROUNDING, borderSize, a2);
}
}
diff --git a/src/render/decorations/CHyprDropShadowDecoration.cpp b/src/render/decorations/CHyprDropShadowDecoration.cpp
index 4448ce9d..8ea96169 100644
--- a/src/render/decorations/CHyprDropShadowDecoration.cpp
+++ b/src/render/decorations/CHyprDropShadowDecoration.cpp
@@ -46,8 +46,8 @@ void CHyprDropShadowDecoration::damageEntire() {
}
void CHyprDropShadowDecoration::updateWindow(CWindow* pWindow) {
- m_vLastWindowPos = m_pWindow->m_vRealPosition.vec();
- m_vLastWindowSize = m_pWindow->m_vRealSize.vec();
+ m_vLastWindowPos = m_pWindow->m_vRealPosition.value();
+ m_vLastWindowSize = m_pWindow->m_vRealSize.value();
m_bLastWindowBox = {m_vLastWindowPos.x, m_vLastWindowPos.y, m_vLastWindowSize.x, m_vLastWindowSize.y};
m_bLastWindowBoxWithDecos = g_pDecorationPositioner->getBoxWithIncludedDecos(pWindow);
@@ -58,7 +58,7 @@ void CHyprDropShadowDecoration::draw(CMonitor* pMonitor, float a, const Vector2D
if (!g_pCompositor->windowValidMapped(m_pWindow))
return;
- if (m_pWindow->m_cRealShadowColor.col() == CColor(0, 0, 0, 0))
+ if (m_pWindow->m_cRealShadowColor.value() == CColor(0, 0, 0, 0))
return; // don't draw invisible shadows
if (!m_pWindow->m_sSpecialRenderData.decorate)
@@ -82,7 +82,7 @@ void CHyprDropShadowDecoration::draw(CMonitor* pMonitor, float a, const Vector2D
const auto ROUNDINGBASE = m_pWindow->rounding();
const auto ROUNDING = ROUNDINGBASE > 0 ? ROUNDINGBASE + m_pWindow->getRealBorderSize() : 0;
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(m_pWindow->m_iWorkspaceID);
- const auto WORKSPACEOFFSET = PWORKSPACE && !m_pWindow->m_bPinned ? PWORKSPACE->m_vRenderOffset.vec() : Vector2D();
+ const auto WORKSPACEOFFSET = PWORKSPACE && !m_pWindow->m_bPinned ? PWORKSPACE->m_vRenderOffset.value() : Vector2D();
// draw the shadow
CBox fullBox = m_bLastWindowBoxWithDecos;
@@ -147,7 +147,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.col().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);
@@ -155,7 +155,7 @@ void CHyprDropShadowDecoration::draw(CMonitor* pMonitor, float a, const Vector2D
alphaSwapFB.bind();
// alpha swap just has the shadow color. It will be the "texture" to render.
- g_pHyprOpenGL->renderRect(&fullBox, m_pWindow->m_cRealShadowColor.col().stripA(), 0);
+ g_pHyprOpenGL->renderRect(&fullBox, m_pWindow->m_cRealShadowColor.value().stripA(), 0);
LASTFB->bind();
@@ -166,7 +166,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.col(), a);
+ g_pHyprOpenGL->renderRoundedShadow(&fullBox, ROUNDING * pMonitor->scale, **PSHADOWSIZE * pMonitor->scale, m_pWindow->m_cRealShadowColor.value(), a);
}
if (m_seExtents != m_seReportedExtents)
diff --git a/src/render/decorations/CHyprGroupBarDecoration.cpp b/src/render/decorations/CHyprGroupBarDecoration.cpp
index 20c0240f..ee0a5ce4 100644
--- a/src/render/decorations/CHyprGroupBarDecoration.cpp
+++ b/src/render/decorations/CHyprGroupBarDecoration.cpp
@@ -504,6 +504,6 @@ CBox CHyprGroupBarDecoration::assignedBoxGlobal() {
if (!PWORKSPACE)
return box;
- const auto WORKSPACEOFFSET = PWORKSPACE && !m_pWindow->m_bPinned ? PWORKSPACE->m_vRenderOffset.vec() : Vector2D();
+ const auto WORKSPACEOFFSET = PWORKSPACE && !m_pWindow->m_bPinned ? PWORKSPACE->m_vRenderOffset.value() : Vector2D();
return box.translate(WORKSPACEOFFSET);
}
diff --git a/src/render/decorations/DecorationPositioner.cpp b/src/render/decorations/DecorationPositioner.cpp
index e19c361b..145a697b 100644
--- a/src/render/decorations/DecorationPositioner.cpp
+++ b/src/render/decorations/DecorationPositioner.cpp
@@ -124,7 +124,7 @@ void CDecorationPositioner::onWindowUpdate(CWindow* pWindow) {
datas.push_back(getDataFor(wd.get(), pWindow));
}
- if (WINDOWDATA->lastWindowSize == pWindow->m_vRealSize.vec() /* position not changed */
+ if (WINDOWDATA->lastWindowSize == pWindow->m_vRealSize.value() /* position not changed */
&&
std::all_of(m_vWindowPositioningDatas.begin(), m_vWindowPositioningDatas.end(), [pWindow](const auto& data) { return pWindow != data->pWindow || !data->needsReposition; })
/* all window datas are either not for this window or don't need a reposition */
@@ -132,7 +132,7 @@ void CDecorationPositioner::onWindowUpdate(CWindow* pWindow) {
)
return;
- WINDOWDATA->lastWindowSize = pWindow->m_vRealSize.vec();
+ WINDOWDATA->lastWindowSize = pWindow->m_vRealSize.value();
WINDOWDATA->needsRecalc = false;
const bool EPHEMERAL = pWindow->m_vRealSize.isBeingAnimated();