mirror of
https://github.com/hyprwm/Hyprland.git
synced 2025-07-25 17:21:54 -07:00
groupbar: various visual improvements
added rounding, round at edges, and indicator height
This commit is contained in:
@@ -883,7 +883,7 @@ inline static const std::vector<SConfigOptionDescription> CONFIG_OPTIONS = {
|
||||
.value = "group:groupbar:gradients",
|
||||
.description = "enables gradients",
|
||||
.type = CONFIG_OPTION_BOOL,
|
||||
.data = SConfigOptionDescription::SBoolData{true},
|
||||
.data = SConfigOptionDescription::SBoolData{false},
|
||||
},
|
||||
SConfigOptionDescription{
|
||||
.value = "group:groupbar:height",
|
||||
@@ -891,6 +891,12 @@ inline static const std::vector<SConfigOptionDescription> CONFIG_OPTIONS = {
|
||||
.type = CONFIG_OPTION_INT,
|
||||
.data = SConfigOptionDescription::SRangeData{14, 1, 64},
|
||||
},
|
||||
SConfigOptionDescription{
|
||||
.value = "group:groupbar:indicator_height",
|
||||
.description = "height of the groupbar indicator",
|
||||
.type = CONFIG_OPTION_INT,
|
||||
.data = SConfigOptionDescription::SRangeData{3, 1, 64},
|
||||
},
|
||||
SConfigOptionDescription{
|
||||
.value = "group:groupbar:stacked",
|
||||
.description = "render the groupbar as a vertical stack",
|
||||
@@ -915,6 +921,30 @@ inline static const std::vector<SConfigOptionDescription> CONFIG_OPTIONS = {
|
||||
.type = CONFIG_OPTION_BOOL,
|
||||
.data = SConfigOptionDescription::SBoolData{true},
|
||||
},
|
||||
SConfigOptionDescription{
|
||||
.value = "group:groupbar:rounding",
|
||||
.description = "how much to round the groupbar",
|
||||
.type = CONFIG_OPTION_INT,
|
||||
.data = SConfigOptionDescription::SRangeData{1, 0, 20},
|
||||
},
|
||||
SConfigOptionDescription{
|
||||
.value = "group:groupbar:gradient_rounding",
|
||||
.description = "how much to round the groupbar gradient",
|
||||
.type = CONFIG_OPTION_INT,
|
||||
.data = SConfigOptionDescription::SRangeData{1, 0, 20},
|
||||
},
|
||||
SConfigOptionDescription{
|
||||
.value = "group:groupbar:round_only_edges",
|
||||
.description = "if yes, will only round at the groupbar edges",
|
||||
.type = CONFIG_OPTION_BOOL,
|
||||
.data = SConfigOptionDescription::SBoolData{true},
|
||||
},
|
||||
SConfigOptionDescription{
|
||||
.value = "group:groupbar:groupbar_round_only_edges",
|
||||
.description = "if yes, will only round at the groupbar gradient edges",
|
||||
.type = CONFIG_OPTION_BOOL,
|
||||
.data = SConfigOptionDescription::SBoolData{true},
|
||||
},
|
||||
SConfigOptionDescription{
|
||||
.value = "group:groupbar:text_color",
|
||||
.description = "controls the group bar text color",
|
||||
|
@@ -441,13 +441,18 @@ 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:gradients", Hyprlang::INT{1});
|
||||
m_pConfig->addConfigValue("group:groupbar:gradients", Hyprlang::INT{0});
|
||||
m_pConfig->addConfigValue("group:groupbar:height", Hyprlang::INT{14});
|
||||
m_pConfig->addConfigValue("group:groupbar:indicator_height", Hyprlang::INT{3});
|
||||
m_pConfig->addConfigValue("group:groupbar:priority", Hyprlang::INT{3});
|
||||
m_pConfig->addConfigValue("group:groupbar:render_titles", Hyprlang::INT{1});
|
||||
m_pConfig->addConfigValue("group:groupbar:scrolling", Hyprlang::INT{1});
|
||||
m_pConfig->addConfigValue("group:groupbar:text_color", Hyprlang::INT{0xffffffff});
|
||||
m_pConfig->addConfigValue("group:groupbar:stacked", Hyprlang::INT{0});
|
||||
m_pConfig->addConfigValue("group:groupbar:rounding", Hyprlang::INT{1});
|
||||
m_pConfig->addConfigValue("group:groupbar:gradient_rounding", Hyprlang::INT{2});
|
||||
m_pConfig->addConfigValue("group:groupbar:round_only_edges", Hyprlang::INT{1});
|
||||
m_pConfig->addConfigValue("group:groupbar:gradient_round_only_edges", Hyprlang::INT{1});
|
||||
|
||||
m_pConfig->addConfigValue("debug:int", Hyprlang::INT{0});
|
||||
m_pConfig->addConfigValue("debug:log_damage", Hyprlang::INT{0});
|
||||
|
@@ -15,7 +15,6 @@ static SP<CTexture> m_tGradientInactive = makeShared<CTexture>();
|
||||
static SP<CTexture> m_tGradientLockedActive = makeShared<CTexture>();
|
||||
static SP<CTexture> m_tGradientLockedInactive = makeShared<CTexture>();
|
||||
|
||||
constexpr int BAR_INDICATOR_HEIGHT = 3;
|
||||
constexpr int BAR_PADDING_OUTER_VERT = 2;
|
||||
constexpr int BAR_PADDING_OUTER_HORZ = 2;
|
||||
constexpr int BAR_TEXT_PAD = 2;
|
||||
@@ -30,12 +29,13 @@ CHyprGroupBarDecoration::CHyprGroupBarDecoration(PHLWINDOW pWindow) : IHyprWindo
|
||||
}
|
||||
|
||||
SDecorationPositioningInfo CHyprGroupBarDecoration::getPositioningInfo() {
|
||||
static auto PHEIGHT = CConfigValue<Hyprlang::INT>("group:groupbar:height");
|
||||
static auto PENABLED = CConfigValue<Hyprlang::INT>("group:groupbar:enabled");
|
||||
static auto PRENDERTITLES = CConfigValue<Hyprlang::INT>("group:groupbar:render_titles");
|
||||
static auto PGRADIENTS = CConfigValue<Hyprlang::INT>("group:groupbar:gradients");
|
||||
static auto PPRIORITY = CConfigValue<Hyprlang::INT>("group:groupbar:priority");
|
||||
static auto PSTACKED = CConfigValue<Hyprlang::INT>("group:groupbar:stacked");
|
||||
static auto PHEIGHT = CConfigValue<Hyprlang::INT>("group:groupbar:height");
|
||||
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");
|
||||
static auto PGRADIENTS = CConfigValue<Hyprlang::INT>("group:groupbar:gradients");
|
||||
static auto PPRIORITY = CConfigValue<Hyprlang::INT>("group:groupbar:priority");
|
||||
static auto PSTACKED = CConfigValue<Hyprlang::INT>("group:groupbar:stacked");
|
||||
|
||||
SDecorationPositioningInfo info;
|
||||
info.policy = DECORATION_POSITION_STICKY;
|
||||
@@ -45,10 +45,10 @@ SDecorationPositioningInfo CHyprGroupBarDecoration::getPositioningInfo() {
|
||||
|
||||
if (*PENABLED && m_pWindow->m_sWindowData.decorate.valueOrDefault()) {
|
||||
if (*PSTACKED) {
|
||||
const auto ONEBARHEIGHT = BAR_PADDING_OUTER_VERT + BAR_INDICATOR_HEIGHT + (*PGRADIENTS || *PRENDERTITLES ? *PHEIGHT : 0);
|
||||
const auto ONEBARHEIGHT = BAR_PADDING_OUTER_VERT + *PINDICATORHEIGHT + (*PGRADIENTS || *PRENDERTITLES ? *PHEIGHT : 0);
|
||||
info.desiredExtents = {{0, (ONEBARHEIGHT * m_dwGroupMembers.size()) + 2 + BAR_PADDING_OUTER_VERT}, {0, 0}};
|
||||
} else
|
||||
info.desiredExtents = {{0, BAR_PADDING_OUTER_VERT * 2 + BAR_INDICATOR_HEIGHT + (*PGRADIENTS || *PRENDERTITLES ? *PHEIGHT : 0) + 2}, {0, 0}};
|
||||
info.desiredExtents = {{0, BAR_PADDING_OUTER_VERT * 2 + *PINDICATORHEIGHT + (*PGRADIENTS || *PRENDERTITLES ? *PHEIGHT : 0) + 2}, {0, 0}};
|
||||
} else
|
||||
info.desiredExtents = {{0, 0}, {0, 0}};
|
||||
return info;
|
||||
@@ -99,19 +99,24 @@ void CHyprGroupBarDecoration::draw(PHLMONITOR pMonitor, float const& a) {
|
||||
// get how many bars we will draw
|
||||
int barsToDraw = m_dwGroupMembers.size();
|
||||
|
||||
static auto PENABLED = CConfigValue<Hyprlang::INT>("group:groupbar:enabled");
|
||||
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 PGRADIENTS = CConfigValue<Hyprlang::INT>("group:groupbar:gradients");
|
||||
static auto PSTACKED = CConfigValue<Hyprlang::INT>("group:groupbar:stacked");
|
||||
static auto PENABLED = CConfigValue<Hyprlang::INT>("group:groupbar:enabled");
|
||||
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 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");
|
||||
static auto PROUNDING = CConfigValue<Hyprlang::INT>("group:groupbar:rounding");
|
||||
static auto PGRADIENTROUNDING = CConfigValue<Hyprlang::INT>("group:groupbar:gradient_rounding");
|
||||
static auto PGRADIENTROUNDINGONLYEDGES = CConfigValue<Hyprlang::INT>("group:groupbar:gradient_round_only_edges");
|
||||
static auto PROUNDONLYEDGES = CConfigValue<Hyprlang::INT>("group:groupbar:round_only_edges");
|
||||
|
||||
if (!*PENABLED || !m_pWindow->m_sWindowData.decorate.valueOrDefault())
|
||||
return;
|
||||
|
||||
const auto ASSIGNEDBOX = assignedBoxGlobal();
|
||||
|
||||
const auto ONEBARHEIGHT = BAR_PADDING_OUTER_VERT + BAR_INDICATOR_HEIGHT + (*PGRADIENTS || *PRENDERTITLES ? *PHEIGHT : 0);
|
||||
const auto ONEBARHEIGHT = BAR_PADDING_OUTER_VERT + *PINDICATORHEIGHT + (*PGRADIENTS || *PRENDERTITLES ? *PHEIGHT : 0);
|
||||
m_fBarWidth = *PSTACKED ? ASSIGNEDBOX.w : (ASSIGNEDBOX.w - BAR_HORIZONTAL_PADDING * (barsToDraw - 1)) / barsToDraw;
|
||||
m_fBarHeight = *PSTACKED ? ((ASSIGNEDBOX.h - 2 - BAR_PADDING_OUTER_VERT) - BAR_PADDING_OUTER_VERT * (barsToDraw)) / barsToDraw : ASSIGNEDBOX.h - BAR_PADDING_OUTER_VERT;
|
||||
|
||||
@@ -126,8 +131,8 @@ void CHyprGroupBarDecoration::draw(PHLMONITOR pMonitor, float const& a) {
|
||||
const auto WINDOWINDEX = *PSTACKED ? m_dwGroupMembers.size() - i - 1 : i;
|
||||
|
||||
CBox rect = {ASSIGNEDBOX.x + floor(xoff) - pMonitor->vecPosition.x + m_pWindow->m_vFloatingOffset.x,
|
||||
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};
|
||||
ASSIGNEDBOX.y + ASSIGNEDBOX.h - floor(yoff) - *PINDICATORHEIGHT - BAR_PADDING_OUTER_VERT - pMonitor->vecPosition.y + m_pWindow->m_vFloatingOffset.y,
|
||||
m_fBarWidth, *PINDICATORHEIGHT};
|
||||
|
||||
if (rect.width <= 0 || rect.height <= 0)
|
||||
break;
|
||||
@@ -152,6 +157,30 @@ void CHyprGroupBarDecoration::draw(PHLMONITOR pMonitor, float const& a) {
|
||||
CRectPassElement::SRectData rectdata;
|
||||
rectdata.color = color;
|
||||
rectdata.box = rect;
|
||||
if (*PROUNDING) {
|
||||
if (*PROUNDONLYEDGES) {
|
||||
static constexpr double PADDING = 20;
|
||||
|
||||
if (i == 0 && barsToDraw == 1)
|
||||
rectdata.round = *PROUNDING;
|
||||
else if (i == 0) {
|
||||
double first = rect.w - (*PROUNDING * 2);
|
||||
rectdata.round = *PROUNDING;
|
||||
rectdata.clipBox = CBox{rect.pos() - Vector2D{PADDING, 0.F}, Vector2D{first + PADDING, rect.h}};
|
||||
g_pHyprRenderer->m_sRenderPass.add(makeShared<CRectPassElement>(rectdata));
|
||||
rectdata.round = 0;
|
||||
rectdata.clipBox = CBox{rect.pos() + Vector2D{first, 0.F}, Vector2D{rect.w - first + PADDING, rect.h}};
|
||||
} else if (i == barsToDraw - 1) {
|
||||
double first = *PROUNDING * 2;
|
||||
rectdata.round = 0;
|
||||
rectdata.clipBox = CBox{rect.pos() - Vector2D{PADDING, 0.F}, Vector2D{first + PADDING, rect.h}};
|
||||
g_pHyprRenderer->m_sRenderPass.add(makeShared<CRectPassElement>(rectdata));
|
||||
rectdata.round = *PROUNDING;
|
||||
rectdata.clipBox = CBox{rect.pos() + Vector2D{first, 0.F}, Vector2D{rect.w - first + PADDING, rect.h}};
|
||||
}
|
||||
} else
|
||||
rectdata.round = *PROUNDING;
|
||||
}
|
||||
g_pHyprRenderer->m_sRenderPass.add(makeShared<CRectPassElement>(rectdata));
|
||||
|
||||
rect = {ASSIGNEDBOX.x + floor(xoff) - pMonitor->vecPosition.x + m_pWindow->m_vFloatingOffset.x,
|
||||
@@ -166,6 +195,30 @@ void CHyprGroupBarDecoration::draw(PHLMONITOR pMonitor, float const& a) {
|
||||
CTexPassElement::SRenderData data;
|
||||
data.tex = GRADIENTTEX;
|
||||
data.box = rect;
|
||||
if (*PGRADIENTROUNDING) {
|
||||
if (*PGRADIENTROUNDINGONLYEDGES) {
|
||||
static constexpr double PADDING = 20;
|
||||
|
||||
if (i == 0 && barsToDraw == 1)
|
||||
data.round = *PGRADIENTROUNDING;
|
||||
else if (i == 0) {
|
||||
double first = rect.w - (*PGRADIENTROUNDING * 2);
|
||||
data.round = *PGRADIENTROUNDING;
|
||||
data.clipBox = CBox{rect.pos() - Vector2D{PADDING, 0.F}, Vector2D{first + PADDING, rect.h}};
|
||||
g_pHyprRenderer->m_sRenderPass.add(makeShared<CTexPassElement>(data));
|
||||
data.round = 0;
|
||||
data.clipBox = CBox{rect.pos() + Vector2D{first, 0.F}, Vector2D{rect.w - first + PADDING, rect.h}};
|
||||
} else if (i == barsToDraw - 1) {
|
||||
double first = *PGRADIENTROUNDING * 2;
|
||||
data.round = 0;
|
||||
data.clipBox = CBox{rect.pos() - Vector2D{PADDING, 0.F}, Vector2D{first + PADDING, rect.h}};
|
||||
g_pHyprRenderer->m_sRenderPass.add(makeShared<CTexPassElement>(data));
|
||||
data.round = *PGRADIENTROUNDING;
|
||||
data.clipBox = CBox{rect.pos() + Vector2D{first, 0.F}, Vector2D{rect.w - first + PADDING, rect.h}};
|
||||
}
|
||||
} else
|
||||
rectdata.round = *PGRADIENTROUNDING;
|
||||
}
|
||||
g_pHyprRenderer->m_sRenderPass.add(makeShared<CTexPassElement>(data));
|
||||
}
|
||||
}
|
||||
@@ -229,7 +282,7 @@ CTitleTex::CTitleTex(PHLWINDOW pWindow, const Vector2D& bufferSize, const float
|
||||
texSize = tex->m_vSize;
|
||||
}
|
||||
|
||||
void renderGradientTo(SP<CTexture> tex, CGradientValueData* grad) {
|
||||
static void renderGradientTo(SP<CTexture> tex, CGradientValueData* grad) {
|
||||
|
||||
if (!g_pCompositor->m_pLastMonitor)
|
||||
return;
|
||||
|
@@ -9,10 +9,15 @@ void CRectPassElement::draw(const CRegion& damage) {
|
||||
if (data.box.w <= 0 || data.box.h <= 0)
|
||||
return;
|
||||
|
||||
if (!data.clipBox.empty())
|
||||
g_pHyprOpenGL->m_RenderData.clipBox = data.clipBox;
|
||||
|
||||
if (data.color.a == 1.F || !data.blur)
|
||||
g_pHyprOpenGL->renderRectWithDamage(data.box, data.color, damage, data.round, data.roundingPower);
|
||||
else
|
||||
g_pHyprOpenGL->renderRectWithBlur(data.box, data.color, data.round, data.roundingPower, data.blurA, data.xray);
|
||||
|
||||
g_pHyprOpenGL->m_RenderData.clipBox = {};
|
||||
}
|
||||
|
||||
bool CRectPassElement::needsLiveBlur() {
|
||||
|
@@ -10,6 +10,7 @@ class CRectPassElement : public IPassElement {
|
||||
float roundingPower = 2.0f;
|
||||
bool blur = false, xray = false;
|
||||
float blurA = 1.F;
|
||||
CBox clipBox;
|
||||
};
|
||||
|
||||
CRectPassElement(const SRectData& data);
|
||||
|
@@ -13,9 +13,13 @@ void CTexPassElement::draw(const CRegion& damage) {
|
||||
|
||||
CScopeGuard x = {[]() {
|
||||
//
|
||||
g_pHyprOpenGL->m_bEndFrame = false;
|
||||
g_pHyprOpenGL->m_bEndFrame = false;
|
||||
g_pHyprOpenGL->m_RenderData.clipBox = {};
|
||||
}};
|
||||
|
||||
if (!data.clipBox.empty())
|
||||
g_pHyprOpenGL->m_RenderData.clipBox = data.clipBox;
|
||||
|
||||
if (data.replaceProjection)
|
||||
g_pHyprOpenGL->m_RenderData.monitorProjection = *data.replaceProjection;
|
||||
g_pHyprOpenGL->renderTextureInternalWithDamage(data.tex, data.box, data.a, data.damage.empty() ? damage : data.damage, data.round, data.roundingPower, data.syncTimeline,
|
||||
|
@@ -19,6 +19,7 @@ class CTexPassElement : public IPassElement {
|
||||
SP<CSyncTimeline> syncTimeline;
|
||||
int64_t syncPoint = 0;
|
||||
std::optional<Mat3x3> replaceProjection;
|
||||
CBox clipBox;
|
||||
};
|
||||
|
||||
CTexPassElement(const SRenderData& data);
|
||||
|
Reference in New Issue
Block a user