hyprland-plugins/hyprbars/BarPassElement.cpp

35 lines
1.2 KiB
C++
Raw Normal View History

2024-12-22 16:33:07 +00:00
#include "BarPassElement.hpp"
#include <hyprland/src/render/OpenGL.hpp>
#include <hyprland/src/render/Renderer.hpp>
2024-12-22 16:33:07 +00:00
#include "barDeco.hpp"
using namespace Render::GL;
2024-12-22 16:33:07 +00:00
CBarPassElement::CBarPassElement(const CBarPassElement::SBarData& data_) : data(data_) {
;
}
std::vector<UP<IPassElement>> CBarPassElement::draw() {
data.deco->renderPass(g_pHyprRenderer->m_renderData.pMonitor.lock(), data.a);
return {};
2024-12-22 16:33:07 +00:00
}
bool CBarPassElement::needsLiveBlur() {
static auto* const PENABLEBLURGLOBAL = (Hyprlang::INT* const*)HyprlandAPI::getConfigValue(PHANDLE, "decoration:blur:enabled")->getDataStaticPtr();
CHyprColor color = data.deco->m_bForcedBarColor.value_or(CHyprColor{static_cast<uint64_t>(g_pGlobalState->config.barColor->value())});
color.a *= data.a;
const bool SHOULDBLUR = g_pGlobalState->config.barBlur->value() && **PENABLEBLURGLOBAL && color.a < 1.F;
return SHOULDBLUR;
}
std::optional<CBox> CBarPassElement::boundingBox() {
// Temporary fix: expand the bar bb a bit, otherwise occlusion gets too aggressive.
return data.deco->assignedBoxGlobal().translate(-g_pHyprRenderer->m_renderData.pMonitor->m_position).expand(10);
2024-12-22 16:33:07 +00:00
}
bool CBarPassElement::needsPrecomputeBlur() {
return false;
}