diff --git a/hyprbars/BarPassElement.cpp b/hyprbars/BarPassElement.cpp index c353a30..64ebabd 100644 --- a/hyprbars/BarPassElement.cpp +++ b/hyprbars/BarPassElement.cpp @@ -11,7 +11,19 @@ void CBarPassElement::draw(const CRegion& damage) { } bool CBarPassElement::needsLiveBlur() { - return false; + static auto* const PCOLOR = (Hyprlang::INT* const*)HyprlandAPI::getConfigValue(PHANDLE, "plugin:hyprbars:bar_color")->getDataStaticPtr(); + static auto* const PENABLEBLUR = (Hyprlang::INT* const*)HyprlandAPI::getConfigValue(PHANDLE, "plugin:hyprbars:bar_blur")->getDataStaticPtr(); + static auto* const PENABLEBLURGLOBAL = (Hyprlang::INT* const*)HyprlandAPI::getConfigValue(PHANDLE, "decoration:blur:enabled")->getDataStaticPtr(); + + CHyprColor color = data.deco->m_bForcedBarColor.value_or(**PCOLOR); + color.a *= data.a; + const bool SHOULDBLUR = **PENABLEBLUR && **PENABLEBLURGLOBAL && color.a < 1.F; + + return SHOULDBLUR; +} + +std::optional CBarPassElement::boundingBox() { + return data.deco->assignedBoxGlobal().translate(-g_pHyprOpenGL->m_RenderData.pMonitor->vecPosition); } bool CBarPassElement::needsPrecomputeBlur() { diff --git a/hyprbars/BarPassElement.hpp b/hyprbars/BarPassElement.hpp index eb72508..7998c3e 100644 --- a/hyprbars/BarPassElement.hpp +++ b/hyprbars/BarPassElement.hpp @@ -13,11 +13,12 @@ class CBarPassElement : public IPassElement { CBarPassElement(const SBarData& data_); virtual ~CBarPassElement() = default; - virtual void draw(const CRegion& damage); - virtual bool needsLiveBlur(); - virtual bool needsPrecomputeBlur(); + virtual void draw(const CRegion& damage); + virtual bool needsLiveBlur(); + virtual bool needsPrecomputeBlur(); + virtual std::optional boundingBox(); - virtual const char* passName() { + virtual const char* passName() { return "CBarPassElement"; } diff --git a/hyprbars/README.md b/hyprbars/README.md index 7c7d4c4..ba92424 100644 --- a/hyprbars/README.md +++ b/hyprbars/README.md @@ -26,6 +26,8 @@ plugin { `bar_height` -> (int) bar's height (default `15`) +`bar_blur` -> (bool) whether to blur the bar. Also requires the global blur to be enabled. + `col.text` -> (col) bar's title text color `bar_title_enabled` -> (bool) whether to render the title (default `true`) diff --git a/hyprbars/barDeco.cpp b/hyprbars/barDeco.cpp index 099b061..f285534 100644 --- a/hyprbars/barDeco.cpp +++ b/hyprbars/barDeco.cpp @@ -409,13 +409,18 @@ void CHyprBar::draw(PHLMONITOR pMonitor, const float& a) { void CHyprBar::renderPass(PHLMONITOR pMonitor, const float& a) { const auto PWINDOW = m_pWindow.lock(); - static auto* const PCOLOR = (Hyprlang::INT* const*)HyprlandAPI::getConfigValue(PHANDLE, "plugin:hyprbars:bar_color")->getDataStaticPtr(); - static auto* const PHEIGHT = (Hyprlang::INT* const*)HyprlandAPI::getConfigValue(PHANDLE, "plugin:hyprbars:bar_height")->getDataStaticPtr(); - static auto* const PPRECEDENCE = (Hyprlang::INT* const*)HyprlandAPI::getConfigValue(PHANDLE, "plugin:hyprbars:bar_precedence_over_border")->getDataStaticPtr(); - static auto* const PALIGNBUTTONS = (Hyprlang::STRING const*)HyprlandAPI::getConfigValue(PHANDLE, "plugin:hyprbars:bar_buttons_alignment")->getDataStaticPtr(); - static auto* const PENABLETITLE = (Hyprlang::INT* const*)HyprlandAPI::getConfigValue(PHANDLE, "plugin:hyprbars:bar_title_enabled")->getDataStaticPtr(); + static auto* const PCOLOR = (Hyprlang::INT* const*)HyprlandAPI::getConfigValue(PHANDLE, "plugin:hyprbars:bar_color")->getDataStaticPtr(); + static auto* const PHEIGHT = (Hyprlang::INT* const*)HyprlandAPI::getConfigValue(PHANDLE, "plugin:hyprbars:bar_height")->getDataStaticPtr(); + static auto* const PPRECEDENCE = (Hyprlang::INT* const*)HyprlandAPI::getConfigValue(PHANDLE, "plugin:hyprbars:bar_precedence_over_border")->getDataStaticPtr(); + static auto* const PALIGNBUTTONS = (Hyprlang::STRING const*)HyprlandAPI::getConfigValue(PHANDLE, "plugin:hyprbars:bar_buttons_alignment")->getDataStaticPtr(); + static auto* const PENABLETITLE = (Hyprlang::INT* const*)HyprlandAPI::getConfigValue(PHANDLE, "plugin:hyprbars:bar_title_enabled")->getDataStaticPtr(); + static auto* const PENABLEBLUR = (Hyprlang::INT* const*)HyprlandAPI::getConfigValue(PHANDLE, "plugin:hyprbars:bar_blur")->getDataStaticPtr(); + static auto* const PENABLEBLURGLOBAL = (Hyprlang::INT* const*)HyprlandAPI::getConfigValue(PHANDLE, "decoration:blur:enabled")->getDataStaticPtr(); - const bool BUTTONSRIGHT = std::string{*PALIGNBUTTONS} != "left"; + CHyprColor color = m_bForcedBarColor.value_or(**PCOLOR); + color.a *= a; + const bool BUTTONSRIGHT = std::string{*PALIGNBUTTONS} != "left"; + const bool SHOULDBLUR = **PENABLEBLUR && **PENABLEBLURGLOBAL && color.a < 1.F; if (**PHEIGHT < 1) { m_iLastHeight = **PHEIGHT; @@ -429,9 +434,6 @@ void CHyprBar::renderPass(PHLMONITOR pMonitor, const float& a) { const auto scaledRounding = ROUNDING > 0 ? ROUNDING * pMonitor->scale - 2 /* idk why but otherwise it looks bad due to the gaps */ : 0; - CHyprColor color = m_bForcedBarColor.value_or(**PCOLOR); - color.a *= a; - m_seExtents = {{0, **PHEIGHT}, {}}; const auto DECOBOX = assignedBoxGlobal(); @@ -475,7 +477,10 @@ void CHyprBar::renderPass(PHLMONITOR pMonitor, const float& a) { glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE); } - g_pHyprOpenGL->renderRect(&titleBarBox, color, scaledRounding); + if (SHOULDBLUR) + g_pHyprOpenGL->renderRectWithBlur(&titleBarBox, color, scaledRounding, a); + else + g_pHyprOpenGL->renderRect(&titleBarBox, color, scaledRounding); // render title if (**PENABLETITLE && (m_szLastTitle != PWINDOW->m_szTitle || m_bWindowSizeChanged || m_pTextTex->m_iTexID == 0 || m_bTitleColorChanged)) { diff --git a/hyprbars/main.cpp b/hyprbars/main.cpp index f7d8c59..caecb8d 100644 --- a/hyprbars/main.cpp +++ b/hyprbars/main.cpp @@ -111,6 +111,7 @@ APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) { HyprlandAPI::addConfigValue(PHANDLE, "plugin:hyprbars:col.text", Hyprlang::INT{*configStringToInt("rgba(ffffffff)")}); HyprlandAPI::addConfigValue(PHANDLE, "plugin:hyprbars:bar_text_size", Hyprlang::INT{10}); HyprlandAPI::addConfigValue(PHANDLE, "plugin:hyprbars:bar_title_enabled", Hyprlang::INT{1}); + HyprlandAPI::addConfigValue(PHANDLE, "plugin:hyprbars:bar_blur", Hyprlang::INT{0}); HyprlandAPI::addConfigValue(PHANDLE, "plugin:hyprbars:bar_text_font", Hyprlang::STRING{"Sans"}); HyprlandAPI::addConfigValue(PHANDLE, "plugin:hyprbars:bar_text_align", Hyprlang::STRING{"center"}); HyprlandAPI::addConfigValue(PHANDLE, "plugin:hyprbars:bar_part_of_window", Hyprlang::INT{1});