mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-26 08:05:58 +01:00
groupbar: separate gradients from title (#4444)
* separate gradients from title logic modified: src/config/ConfigManager.cpp modified: src/render/decorations/CHyprGroupBarDecoration.cpp * fix disabled extents modified: src/render/decorations/CHyprGroupBarDecoration.cpp * fix disabled height modified: src/render/decorations/CHyprGroupBarDecoration.cpp
This commit is contained in:
parent
dcd7a92b01
commit
f14c5ea5c5
2 changed files with 19 additions and 16 deletions
|
@ -138,6 +138,7 @@ void CConfigManager::setDefaultVars() {
|
||||||
configValues["group:groupbar:font_family"].strValue = "Sans";
|
configValues["group:groupbar:font_family"].strValue = "Sans";
|
||||||
configValues["group:groupbar:font_size"].intValue = 8;
|
configValues["group:groupbar:font_size"].intValue = 8;
|
||||||
configValues["group:groupbar:gradients"].intValue = 1;
|
configValues["group:groupbar:gradients"].intValue = 1;
|
||||||
|
configValues["group:groupbar:height"].intValue = 14;
|
||||||
configValues["group:groupbar:priority"].intValue = 3;
|
configValues["group:groupbar:priority"].intValue = 3;
|
||||||
configValues["group:groupbar:render_titles"].intValue = 1;
|
configValues["group:groupbar:render_titles"].intValue = 1;
|
||||||
configValues["group:groupbar:scrolling"].intValue = 1;
|
configValues["group:groupbar:scrolling"].intValue = 1;
|
||||||
|
|
|
@ -26,9 +26,10 @@ CHyprGroupBarDecoration::CHyprGroupBarDecoration(CWindow* pWindow) : IHyprWindow
|
||||||
CHyprGroupBarDecoration::~CHyprGroupBarDecoration() {}
|
CHyprGroupBarDecoration::~CHyprGroupBarDecoration() {}
|
||||||
|
|
||||||
SDecorationPositioningInfo CHyprGroupBarDecoration::getPositioningInfo() {
|
SDecorationPositioningInfo CHyprGroupBarDecoration::getPositioningInfo() {
|
||||||
static auto* const PRENDERTITLES = &g_pConfigManager->getConfigValuePtr("group:groupbar:render_titles")->intValue;
|
static auto* const PHEIGHT = &g_pConfigManager->getConfigValuePtr("group:groupbar:height")->intValue;
|
||||||
static auto* const PTITLEFONTSIZE = &g_pConfigManager->getConfigValuePtr("group:groupbar:font_size")->intValue;
|
static auto* const PENABLED = &g_pConfigManager->getConfigValuePtr("group:groupbar:enabled")->intValue;
|
||||||
static auto* const PENABLED = &g_pConfigManager->getConfigValuePtr("group:groupbar:enabled")->intValue;
|
static auto* const PRENDERTITLES = &g_pConfigManager->getConfigValuePtr("group:groupbar:render_titles")->intValue;
|
||||||
|
static auto* const PGRADIENTS = &g_pConfigManager->getConfigValuePtr("group:groupbar:gradients")->intValue;
|
||||||
|
|
||||||
SDecorationPositioningInfo info;
|
SDecorationPositioningInfo info;
|
||||||
info.policy = DECORATION_POSITION_STICKY;
|
info.policy = DECORATION_POSITION_STICKY;
|
||||||
|
@ -37,7 +38,7 @@ SDecorationPositioningInfo CHyprGroupBarDecoration::getPositioningInfo() {
|
||||||
info.reserved = true;
|
info.reserved = true;
|
||||||
|
|
||||||
if (*PENABLED && m_pWindow->m_sSpecialRenderData.decorate)
|
if (*PENABLED && m_pWindow->m_sSpecialRenderData.decorate)
|
||||||
info.desiredExtents = {{0, BAR_PADDING_OUTER_VERT * 2 + BAR_INDICATOR_HEIGHT + (*PRENDERTITLES ? *PTITLEFONTSIZE : 0) + 2}, {0, 0}};
|
info.desiredExtents = {{0, BAR_PADDING_OUTER_VERT * 2 + BAR_INDICATOR_HEIGHT + (*PGRADIENTS || *PRENDERTITLES ? *PHEIGHT : 0) + 2}, {0, 0}};
|
||||||
else
|
else
|
||||||
info.desiredExtents = {{0, 0}, {0, 0}};
|
info.desiredExtents = {{0, 0}, {0, 0}};
|
||||||
|
|
||||||
|
@ -90,6 +91,7 @@ void CHyprGroupBarDecoration::draw(CMonitor* pMonitor, float a, const Vector2D&
|
||||||
static auto* const PENABLED = &g_pConfigManager->getConfigValuePtr("group:groupbar:enabled")->intValue;
|
static auto* const PENABLED = &g_pConfigManager->getConfigValuePtr("group:groupbar:enabled")->intValue;
|
||||||
static auto* const PRENDERTITLES = &g_pConfigManager->getConfigValuePtr("group:groupbar:render_titles")->intValue;
|
static auto* const PRENDERTITLES = &g_pConfigManager->getConfigValuePtr("group:groupbar:render_titles")->intValue;
|
||||||
static auto* const PTITLEFONTSIZE = &g_pConfigManager->getConfigValuePtr("group:groupbar:font_size")->intValue;
|
static auto* const PTITLEFONTSIZE = &g_pConfigManager->getConfigValuePtr("group:groupbar:font_size")->intValue;
|
||||||
|
static auto* const PHEIGHT = &g_pConfigManager->getConfigValuePtr("group:groupbar:height")->intValue;
|
||||||
static auto* const PGRADIENTS = &g_pConfigManager->getConfigValuePtr("group:groupbar:gradients")->intValue;
|
static auto* const PGRADIENTS = &g_pConfigManager->getConfigValuePtr("group:groupbar:gradients")->intValue;
|
||||||
|
|
||||||
if (!*PENABLED || !m_pWindow->m_sSpecialRenderData.decorate)
|
if (!*PENABLED || !m_pWindow->m_sSpecialRenderData.decorate)
|
||||||
|
@ -99,7 +101,7 @@ void CHyprGroupBarDecoration::draw(CMonitor* pMonitor, float a, const Vector2D&
|
||||||
|
|
||||||
m_fBarWidth = (ASSIGNEDBOX.w - BAR_HORIZONTAL_PADDING * (barsToDraw - 1)) / barsToDraw;
|
m_fBarWidth = (ASSIGNEDBOX.w - BAR_HORIZONTAL_PADDING * (barsToDraw - 1)) / barsToDraw;
|
||||||
|
|
||||||
const auto DESIREDHEIGHT = BAR_PADDING_OUTER_VERT * 2 + BAR_INDICATOR_HEIGHT + (*PRENDERTITLES ? *PTITLEFONTSIZE : 0) + 2;
|
const auto DESIREDHEIGHT = BAR_PADDING_OUTER_VERT * 2 + BAR_INDICATOR_HEIGHT + (*PGRADIENTS || *PRENDERTITLES ? *PHEIGHT : 0) + 2;
|
||||||
if (DESIREDHEIGHT != ASSIGNEDBOX.h)
|
if (DESIREDHEIGHT != ASSIGNEDBOX.h)
|
||||||
g_pDecorationPositioner->repositionDeco(this);
|
g_pDecorationPositioner->repositionDeco(this);
|
||||||
|
|
||||||
|
@ -128,12 +130,18 @@ void CHyprGroupBarDecoration::draw(CMonitor* pMonitor, float a, const Vector2D&
|
||||||
color.a *= a;
|
color.a *= a;
|
||||||
g_pHyprOpenGL->renderRect(&rect, color);
|
g_pHyprOpenGL->renderRect(&rect, color);
|
||||||
|
|
||||||
// render title if necessary
|
rect = {ASSIGNEDBOX.x + xoff - pMonitor->vecPosition.x + offset.x, ASSIGNEDBOX.y - pMonitor->vecPosition.y + offset.y + BAR_PADDING_OUTER_VERT, m_fBarWidth,
|
||||||
if (*PRENDERTITLES) {
|
ASSIGNEDBOX.h - BAR_INDICATOR_HEIGHT - BAR_PADDING_OUTER_VERT * 2};
|
||||||
CBox rect = {ASSIGNEDBOX.x + xoff - pMonitor->vecPosition.x + offset.x, ASSIGNEDBOX.y - pMonitor->vecPosition.y + offset.y + BAR_PADDING_OUTER_VERT, m_fBarWidth,
|
rect.scale(pMonitor->scale);
|
||||||
ASSIGNEDBOX.h - BAR_INDICATOR_HEIGHT - BAR_PADDING_OUTER_VERT * 2};
|
|
||||||
rect.scale(pMonitor->scale);
|
|
||||||
|
|
||||||
|
if (*PGRADIENTS) {
|
||||||
|
const auto& GRADIENTTEX = (m_dwGroupMembers[i] == g_pCompositor->m_pLastWindow ? (GROUPLOCKED ? m_tGradientLockedActive : m_tGradientActive) :
|
||||||
|
(GROUPLOCKED ? m_tGradientLockedInactive : m_tGradientInactive));
|
||||||
|
if (GRADIENTTEX.m_iTexID != 0)
|
||||||
|
g_pHyprOpenGL->renderTexture(GRADIENTTEX, &rect, 1.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (*PRENDERTITLES) {
|
||||||
CTitleTex* pTitleTex = textureFromTitle(m_dwGroupMembers[i]->m_szTitle);
|
CTitleTex* pTitleTex = textureFromTitle(m_dwGroupMembers[i]->m_szTitle);
|
||||||
|
|
||||||
if (!pTitleTex)
|
if (!pTitleTex)
|
||||||
|
@ -142,12 +150,6 @@ void CHyprGroupBarDecoration::draw(CMonitor* pMonitor, float a, const Vector2D&
|
||||||
Vector2D{m_fBarWidth * pMonitor->scale, (*PTITLEFONTSIZE + 2 * BAR_TEXT_PAD) * pMonitor->scale}))
|
Vector2D{m_fBarWidth * pMonitor->scale, (*PTITLEFONTSIZE + 2 * BAR_TEXT_PAD) * pMonitor->scale}))
|
||||||
.get();
|
.get();
|
||||||
|
|
||||||
const auto& GRADIENTTEX = (m_dwGroupMembers[i] == g_pCompositor->m_pLastWindow ? (GROUPLOCKED ? m_tGradientLockedActive : m_tGradientActive) :
|
|
||||||
(GROUPLOCKED ? m_tGradientLockedInactive : m_tGradientInactive));
|
|
||||||
|
|
||||||
if (*PGRADIENTS && GRADIENTTEX.m_iTexID != 0)
|
|
||||||
g_pHyprOpenGL->renderTexture(GRADIENTTEX, &rect, 1.0);
|
|
||||||
|
|
||||||
rect.y += (ASSIGNEDBOX.h / 2.0 - (*PTITLEFONTSIZE + 2 * BAR_TEXT_PAD) / 2.0) * pMonitor->scale;
|
rect.y += (ASSIGNEDBOX.h / 2.0 - (*PTITLEFONTSIZE + 2 * BAR_TEXT_PAD) / 2.0) * pMonitor->scale;
|
||||||
rect.height = (*PTITLEFONTSIZE + 2 * BAR_TEXT_PAD) * pMonitor->scale;
|
rect.height = (*PTITLEFONTSIZE + 2 * BAR_TEXT_PAD) * pMonitor->scale;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue