Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added rounded corners to group bar #6839

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/config/ConfigManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,8 @@ CConfigManager::CConfigManager() {
m_pConfig->addConfigValue("group:groupbar:enabled", Hyprlang::INT{1});
m_pConfig->addConfigValue("group:groupbar:font_family", {STRVAL_EMPTY});
m_pConfig->addConfigValue("group:groupbar:font_size", Hyprlang::INT{8});
m_pConfig->addConfigValue("group:groupbar:group_rounding", Hyprlang::INT{0});
m_pConfig->addConfigValue("group:groupbar:rounding", Hyprlang::INT{0});
m_pConfig->addConfigValue("group:groupbar:bottom_bar", Hyprlang::INT{1});
m_pConfig->addConfigValue("group:groupbar:gradients", Hyprlang::INT{1});
m_pConfig->addConfigValue("group:groupbar:height", Hyprlang::INT{14});
m_pConfig->addConfigValue("group:groupbar:priority", Hyprlang::INT{3});
Expand Down
18 changes: 10 additions & 8 deletions src/render/decorations/CHyprGroupBarDecoration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ void CHyprGroupBarDecoration::draw(CMonitor* pMonitor, float a) {

static auto PENABLED = CConfigValue<Hyprlang::INT>("group:groupbar:enabled");
static auto PRENDERTITLES = CConfigValue<Hyprlang::INT>("group:groupbar:render_titles");
static auto PGROUPROUNDING = CConfigValue<Hyprlang::INT>("group:groupbar:group_rounding");
static auto PROUNDING = CConfigValue<Hyprlang::INT>("group:groupbar:rounding");
static auto PBOTTOMBAR = CConfigValue<Hyprlang::INT>("group:groupbar:bottom_bar");
static auto PTITLEFONTSIZE = CConfigValue<Hyprlang::INT>("group:groupbar:font_size");
static auto PHEIGHT = CConfigValue<Hyprlang::INT>("group:groupbar:height");
static auto PGRADIENTS = CConfigValue<Hyprlang::INT>("group:groupbar:gradients");
Expand All @@ -126,9 +127,9 @@ void CHyprGroupBarDecoration::draw(CMonitor* pMonitor, float 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 + floor(xoff) - pMonitor->vecPosition.x + m_pWindow->m_vFloatingOffset.x + *PROUNDING,
Copy link
Author

@Swefton Swefton Jul 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This rect is responsible for the thin bottom bar, I offset its x and width values to reflect the rounding so that it's consistent.

ASSIGNEDBOX.y + ASSIGNEDBOX.h - floor(yoff) - BAR_INDICATOR_HEIGHT - BAR_PADDING_OUTER_VERT - pMonitor->vecPosition.y + m_pWindow->m_vFloatingOffset.y,
m_fBarWidth, BAR_INDICATOR_HEIGHT};
m_fBarWidth - (*PROUNDING * 2), BAR_INDICATOR_HEIGHT};

if (rect.width <= 0 || rect.height <= 0)
break;
Expand All @@ -151,19 +152,20 @@ void CHyprGroupBarDecoration::draw(CMonitor* pMonitor, float a) {
CColor color = m_dwGroupMembers[WINDOWINDEX].lock() == g_pCompositor->m_pLastWindow.lock() ? PCOLACTIVE->m_vColors[0] : PCOLINACTIVE->m_vColors[0];
color.a *= a;

if (*PBOTTOMBAR)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the thin bottom bar looks bad with rounding, I added an option to disable the thin bottom bar, rounding the thin bar is tricky because the height is very small and sometimes opengl throws an error for rendering a negative height.

A problem that arises because of this is that the gap between the main group bar and the window is kinda awkward without the thin bar, I want the extra space to be taken up by the application open and am open to suggestions on how to implement this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

like I said before rounding has to be less or equal to max(width/2, height/2)

to remove the space from the indicator set BAR_INDICATOR_HEIGHT to zero wherever it appears)
specially in const auto ONEBARHEIGHT = BAR_PADDING_OUTER_VERT + BAR_INDICATOR_HEIGHT + (*PGRADIENTS || *PRENDERTITLES ? *PHEIGHT : 0);

I am not sure there is a point to the thin bar anymore maybe it can be removed altogether, but ask vaxry

g_pHyprOpenGL->renderRect(&rect, color);

rect = {ASSIGNEDBOX.x + floor(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)};

g_pHyprOpenGL->renderRect(&rect, color, *PGROUPROUNDING);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found out its cleaner to leave this where it originally was, the first renderRect is to render the thin bar, the rect is then recalculated as the main bar and gets rendered under the if (*PGRADIENTS) conditional, its better to keep them separated.



rect.scale(pMonitor->scale);

if (*PGRADIENTS) {
const auto GRADIENTTEX = (m_dwGroupMembers[WINDOWINDEX] == 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, *PGROUPROUNDING);
g_pHyprOpenGL->renderTexture(GRADIENTTEX, &rect, 1.0, *PROUNDING);
}

if (*PRENDERTITLES) {
Expand All @@ -181,7 +183,7 @@ void CHyprGroupBarDecoration::draw(CMonitor* pMonitor, float a) {
rect.x += (m_fBarWidth * pMonitor->scale) / 2.0 - (pTitleTex->textWidth / 2.0);
rect.round();

g_pHyprOpenGL->renderTexture(pTitleTex->tex, &rect, 1.f, *PGROUPROUNDING);
g_pHyprOpenGL->renderTexture(pTitleTex->tex, &rect, 1.f);
}

if (*PSTACKED)
Expand Down