summaryrefslogtreecommitdiff
path: root/src/render/decorations/CHyprGroupBarDecoration.cpp
diff options
context:
space:
mode:
authorM Matthew Hydock <mhydock@yahoo.com>2025-04-24 14:48:08 -0400
committerGitHub <noreply@github.com>2025-04-24 20:48:08 +0200
commitbe6268a7ecea2ad50cdb78fb661884811a8a28e8 (patch)
treeac5846bc109796f84c1d0abe095286de96a5967d /src/render/decorations/CHyprGroupBarDecoration.cpp
parenta9549dbca060b65ae6ec50f9bc68cdf1823d6cbe (diff)
groupbar: Add options for setting group bar title font weight (and indicator gap) (#9617)
Diffstat (limited to 'src/render/decorations/CHyprGroupBarDecoration.cpp')
-rw-r--r--src/render/decorations/CHyprGroupBarDecoration.cpp36
1 files changed, 22 insertions, 14 deletions
diff --git a/src/render/decorations/CHyprGroupBarDecoration.cpp b/src/render/decorations/CHyprGroupBarDecoration.cpp
index 50726514..7eca6d69 100644
--- a/src/render/decorations/CHyprGroupBarDecoration.cpp
+++ b/src/render/decorations/CHyprGroupBarDecoration.cpp
@@ -27,6 +27,7 @@ CHyprGroupBarDecoration::CHyprGroupBarDecoration(PHLWINDOW pWindow) : IHyprWindo
SDecorationPositioningInfo CHyprGroupBarDecoration::getPositioningInfo() {
static auto PHEIGHT = CConfigValue<Hyprlang::INT>("group:groupbar:height");
+ static auto PINDICATORGAP = CConfigValue<Hyprlang::INT>("group:groupbar:indicator_gap");
static auto PINDICATORHEIGHT = CConfigValue<Hyprlang::INT>("group:groupbar:indicator_height");
static auto PENABLED = CConfigValue<Hyprlang::INT>("group:groupbar:enabled");
static auto PRENDERTITLES = CConfigValue<Hyprlang::INT>("group:groupbar:render_titles");
@@ -44,10 +45,10 @@ SDecorationPositioningInfo CHyprGroupBarDecoration::getPositioningInfo() {
if (*PENABLED && m_pWindow->m_sWindowData.decorate.valueOrDefault()) {
if (*PSTACKED) {
- const auto ONEBARHEIGHT = *POUTERGAP + *PINDICATORHEIGHT + (*PGRADIENTS || *PRENDERTITLES ? *PHEIGHT : 0);
+ const auto ONEBARHEIGHT = *POUTERGAP + *PINDICATORHEIGHT + *PINDICATORGAP + (*PGRADIENTS || *PRENDERTITLES ? *PHEIGHT : 0);
info.desiredExtents = {{0, (ONEBARHEIGHT * m_dwGroupMembers.size()) + (*PKEEPUPPERGAP * *POUTERGAP)}, {0, 0}};
} else
- info.desiredExtents = {{0, *POUTERGAP * (1 + *PKEEPUPPERGAP) + *PINDICATORHEIGHT + (*PGRADIENTS || *PRENDERTITLES ? *PHEIGHT : 0)}, {0, 0}};
+ info.desiredExtents = {{0, *POUTERGAP * (1 + *PKEEPUPPERGAP) + *PINDICATORHEIGHT + *PINDICATORGAP + (*PGRADIENTS || *PRENDERTITLES ? *PHEIGHT : 0)}, {0, 0}};
} else
info.desiredExtents = {{0, 0}, {0, 0}};
return info;
@@ -105,6 +106,7 @@ void CHyprGroupBarDecoration::draw(PHLMONITOR pMonitor, float const& a) {
static auto PRENDERTITLES = CConfigValue<Hyprlang::INT>("group:groupbar:render_titles");
static auto PTITLEFONTSIZE = CConfigValue<Hyprlang::INT>("group:groupbar:font_size");
static auto PHEIGHT = CConfigValue<Hyprlang::INT>("group:groupbar:height");
+ static auto PINDICATORGAP = CConfigValue<Hyprlang::INT>("group:groupbar:indicator_gap");
static auto PINDICATORHEIGHT = CConfigValue<Hyprlang::INT>("group:groupbar:indicator_height");
static auto PGRADIENTS = CConfigValue<Hyprlang::INT>("group:groupbar:gradients");
static auto PSTACKED = CConfigValue<Hyprlang::INT>("group:groupbar:stacked");
@@ -127,7 +129,7 @@ void CHyprGroupBarDecoration::draw(PHLMONITOR pMonitor, float const& a) {
const auto ASSIGNEDBOX = assignedBoxGlobal();
- const auto ONEBARHEIGHT = *POUTERGAP + *PINDICATORHEIGHT + (*PGRADIENTS || *PRENDERTITLES ? *PHEIGHT : 0);
+ const auto ONEBARHEIGHT = *POUTERGAP + *PINDICATORHEIGHT + *PINDICATORGAP + (*PGRADIENTS || *PRENDERTITLES ? *PHEIGHT : 0);
m_fBarWidth = *PSTACKED ? ASSIGNEDBOX.w : (ASSIGNEDBOX.w - *PINNERGAP * (barsToDraw - 1)) / barsToDraw;
m_fBarHeight = *PSTACKED ? ((ASSIGNEDBOX.h - *POUTERGAP * *PKEEPUPPERGAP) - *POUTERGAP * (barsToDraw)) / barsToDraw : ASSIGNEDBOX.h - *POUTERGAP * *PKEEPUPPERGAP;
@@ -141,7 +143,7 @@ void CHyprGroupBarDecoration::draw(PHLMONITOR pMonitor, float const& a) {
for (int i = 0; i < barsToDraw; ++i) {
const auto WINDOWINDEX = *PSTACKED ? m_dwGroupMembers.size() - i - 1 : i;
- CBox rect = {ASSIGNEDBOX.x + floor(xoff) - pMonitor->vecPosition.x + m_pWindow->m_vFloatingOffset.x,
+ CBox rect = {ASSIGNEDBOX.x + xoff - pMonitor->vecPosition.x + m_pWindow->m_vFloatingOffset.x,
ASSIGNEDBOX.y + ASSIGNEDBOX.h - floor(yoff) - *PINDICATORHEIGHT - *POUTERGAP - pMonitor->vecPosition.y + m_pWindow->m_vFloatingOffset.y, m_fBarWidth,
*PINDICATORHEIGHT};
@@ -185,7 +187,7 @@ void CHyprGroupBarDecoration::draw(PHLMONITOR pMonitor, float const& a) {
g_pHyprRenderer->m_sRenderPass.add(makeShared<CRectPassElement>(rectdata));
}
- rect = {ASSIGNEDBOX.x + floor(xoff) - pMonitor->vecPosition.x + m_pWindow->m_vFloatingOffset.x,
+ rect = {ASSIGNEDBOX.x + xoff - pMonitor->vecPosition.x + m_pWindow->m_vFloatingOffset.x,
ASSIGNEDBOX.y + ASSIGNEDBOX.h - floor(yoff) - ONEBARHEIGHT - pMonitor->vecPosition.y + m_pWindow->m_vFloatingOffset.y, m_fBarWidth,
(*PGRADIENTS || *PRENDERTITLES ? *PHEIGHT : 0)};
rect.scale(pMonitor->scale);
@@ -235,14 +237,16 @@ void CHyprGroupBarDecoration::draw(PHLMONITOR pMonitor, float const& a) {
.emplace_back(makeUnique<CTitleTex>(m_dwGroupMembers[WINDOWINDEX].lock(),
Vector2D{m_fBarWidth * pMonitor->scale, (*PTITLEFONTSIZE + 2L * BAR_TEXT_PAD) * pMonitor->scale}, pMonitor->scale))
.get();
- rect.y += std::ceil(((rect.height - pTitleTex->texSize.y) / 2.0) - (*PTEXTOFFSET * pMonitor->scale));
- rect.height = pTitleTex->texSize.y;
- rect.width = pTitleTex->texSize.x;
- rect.x += std::round(((m_fBarWidth * pMonitor->scale) / 2.0) - (pTitleTex->texSize.x / 2.0));
+
+ const auto titleTex = m_dwGroupMembers[WINDOWINDEX] == g_pCompositor->m_lastWindow ? pTitleTex->texActive : pTitleTex->texInactive;
+ rect.y += std::ceil(((rect.height - titleTex->m_vSize.y) / 2.0) - (*PTEXTOFFSET * pMonitor->scale));
+ rect.height = titleTex->m_vSize.y;
+ rect.width = titleTex->m_vSize.x;
+ rect.x += std::round(((m_fBarWidth * pMonitor->scale) / 2.0) - (titleTex->m_vSize.x / 2.0));
rect.round();
CTexPassElement::SRenderData data;
- data.tex = pTitleTex->tex;
+ data.tex = titleTex;
data.box = rect;
data.a = a;
g_pHyprRenderer->m_sRenderPass.add(makeShared<CTexPassElement>(data));
@@ -278,13 +282,17 @@ CTitleTex::CTitleTex(PHLWINDOW pWindow, const Vector2D& bufferSize, const float
static auto PTITLEFONTSIZE = CConfigValue<Hyprlang::INT>("group:groupbar:font_size");
static auto PTEXTCOLOR = CConfigValue<Hyprlang::INT>("group:groupbar:text_color");
+ static auto PTITLEFONTWEIGHTACTIVE = CConfigValue<Hyprlang::CUSTOMTYPE>("group:groupbar:font_weight_active");
+ static auto PTITLEFONTWEIGHTINACTIVE = CConfigValue<Hyprlang::CUSTOMTYPE>("group:groupbar:font_weight_inactive");
+
+ const auto FONTWEIGHTACTIVE = (CFontWeightConfigValueData*)(PTITLEFONTWEIGHTACTIVE.ptr())->getData();
+ const auto FONTWEIGHTINACTIVE = (CFontWeightConfigValueData*)(PTITLEFONTWEIGHTINACTIVE.ptr())->getData();
+
const CHyprColor COLOR = CHyprColor(*PTEXTCOLOR);
const auto FONTFAMILY = *PTITLEFONTFAMILY != STRVAL_EMPTY ? *PTITLEFONTFAMILY : *FALLBACKFONT;
- tex = g_pHyprOpenGL->renderText(pWindow->m_szTitle, COLOR, *PTITLEFONTSIZE * monitorScale, false, FONTFAMILY, bufferSize.x - 2 /* some padding yk */);
-
- if (tex)
- texSize = tex->m_vSize;
+ texActive = g_pHyprOpenGL->renderText(pWindow->m_szTitle, COLOR, *PTITLEFONTSIZE * monitorScale, false, FONTFAMILY, bufferSize.x - 2, FONTWEIGHTACTIVE->m_value);
+ texInactive = g_pHyprOpenGL->renderText(pWindow->m_szTitle, COLOR, *PTITLEFONTSIZE * monitorScale, false, FONTFAMILY, bufferSize.x - 2, FONTWEIGHTINACTIVE->m_value);
}
static void renderGradientTo(SP<CTexture> tex, CGradientValueData* grad) {