mirror of
https://github.com/hyprwm/Hyprland
synced 2025-04-06 23:51:50 +02:00
groupbar: add text offset and upper gap settings (#9733)
* Groupbar: add keep_upper_gap setting to apply/remove outer gap offset to the upper side of groupbar * Groupbar: add text_offset setting to adjust text vertical position in a group header
This commit is contained in:
parent
8654029f86
commit
a41b8d5e97
3 changed files with 22 additions and 5 deletions
src
|
@ -1011,6 +1011,18 @@ inline static const std::vector<SConfigOptionDescription> CONFIG_OPTIONS = {
|
|||
.type = CONFIG_OPTION_INT,
|
||||
.data = SConfigOptionDescription::SRangeData{2, 0, 20},
|
||||
},
|
||||
SConfigOptionDescription{
|
||||
.value = "group:groupbar:keep_upper_gap",
|
||||
.description = "keep an upper gap above gradient",
|
||||
.type = CONFIG_OPTION_BOOL,
|
||||
.data = SConfigOptionDescription::SBoolData{true},
|
||||
},
|
||||
SConfigOptionDescription{
|
||||
.value = "group:groupbar:text_offset",
|
||||
.description = "set an offset for a text",
|
||||
.type = CONFIG_OPTION_BOOL,
|
||||
.data = SConfigOptionDescription::SRangeData{0, -20, 20},
|
||||
},
|
||||
|
||||
/*
|
||||
* misc:
|
||||
|
|
|
@ -487,6 +487,8 @@ CConfigManager::CConfigManager() {
|
|||
registerConfigVar("group:groupbar:gradient_round_only_edges", Hyprlang::INT{1});
|
||||
registerConfigVar("group:groupbar:gaps_out", Hyprlang::INT{2});
|
||||
registerConfigVar("group:groupbar:gaps_in", Hyprlang::INT{2});
|
||||
registerConfigVar("group:groupbar:keep_upper_gap", Hyprlang::INT{1});
|
||||
registerConfigVar("group:groupbar:text_offset", Hyprlang::INT{0});
|
||||
|
||||
registerConfigVar("debug:log_damage", Hyprlang::INT{0});
|
||||
registerConfigVar("debug:overlay", Hyprlang::INT{0});
|
||||
|
|
|
@ -34,6 +34,7 @@ SDecorationPositioningInfo CHyprGroupBarDecoration::getPositioningInfo() {
|
|||
static auto PPRIORITY = CConfigValue<Hyprlang::INT>("group:groupbar:priority");
|
||||
static auto PSTACKED = CConfigValue<Hyprlang::INT>("group:groupbar:stacked");
|
||||
static auto POUTERGAP = CConfigValue<Hyprlang::INT>("group:groupbar:gaps_out");
|
||||
static auto PKEEPUPPERGAP = CConfigValue<Hyprlang::INT>("group:groupbar:keep_upper_gap");
|
||||
|
||||
SDecorationPositioningInfo info;
|
||||
info.policy = DECORATION_POSITION_STICKY;
|
||||
|
@ -44,9 +45,9 @@ SDecorationPositioningInfo CHyprGroupBarDecoration::getPositioningInfo() {
|
|||
if (*PENABLED && m_pWindow->m_sWindowData.decorate.valueOrDefault()) {
|
||||
if (*PSTACKED) {
|
||||
const auto ONEBARHEIGHT = *POUTERGAP + *PINDICATORHEIGHT + (*PGRADIENTS || *PRENDERTITLES ? *PHEIGHT : 0);
|
||||
info.desiredExtents = {{0, (ONEBARHEIGHT * m_dwGroupMembers.size()) + 2 + *POUTERGAP}, {0, 0}};
|
||||
info.desiredExtents = {{0, (ONEBARHEIGHT * m_dwGroupMembers.size()) + (*PKEEPUPPERGAP * *POUTERGAP)}, {0, 0}};
|
||||
} else
|
||||
info.desiredExtents = {{0, *POUTERGAP * 2 + *PINDICATORHEIGHT + (*PGRADIENTS || *PRENDERTITLES ? *PHEIGHT : 0)}, {0, 0}};
|
||||
info.desiredExtents = {{0, *POUTERGAP * (1 + *PKEEPUPPERGAP) + *PINDICATORHEIGHT + (*PGRADIENTS || *PRENDERTITLES ? *PHEIGHT : 0)}, {0, 0}};
|
||||
} else
|
||||
info.desiredExtents = {{0, 0}, {0, 0}};
|
||||
return info;
|
||||
|
@ -117,6 +118,8 @@ void CHyprGroupBarDecoration::draw(PHLMONITOR pMonitor, float const& a) {
|
|||
static auto PGROUPCOLINACTIVELOCKED = CConfigValue<Hyprlang::CUSTOMTYPE>("group:groupbar:col.locked_inactive");
|
||||
static auto POUTERGAP = CConfigValue<Hyprlang::INT>("group:groupbar:gaps_out");
|
||||
static auto PINNERGAP = CConfigValue<Hyprlang::INT>("group:groupbar:gaps_in");
|
||||
static auto PKEEPUPPERGAP = CConfigValue<Hyprlang::INT>("group:groupbar:keep_upper_gap");
|
||||
static auto PTEXTOFFSET = CConfigValue<Hyprlang::INT>("group:groupbar:text_offset");
|
||||
auto* const GROUPCOLACTIVE = (CGradientValueData*)(PGROUPCOLACTIVE.ptr())->getData();
|
||||
auto* const GROUPCOLINACTIVE = (CGradientValueData*)(PGROUPCOLINACTIVE.ptr())->getData();
|
||||
auto* const GROUPCOLACTIVELOCKED = (CGradientValueData*)(PGROUPCOLACTIVELOCKED.ptr())->getData();
|
||||
|
@ -126,9 +129,9 @@ void CHyprGroupBarDecoration::draw(PHLMONITOR pMonitor, float const& a) {
|
|||
|
||||
const auto ONEBARHEIGHT = *POUTERGAP + *PINDICATORHEIGHT + (*PGRADIENTS || *PRENDERTITLES ? *PHEIGHT : 0);
|
||||
m_fBarWidth = *PSTACKED ? ASSIGNEDBOX.w : (ASSIGNEDBOX.w - *PINNERGAP * (barsToDraw - 1)) / barsToDraw;
|
||||
m_fBarHeight = *PSTACKED ? ((ASSIGNEDBOX.h - 2 - *POUTERGAP) - *POUTERGAP * (barsToDraw)) / barsToDraw : ASSIGNEDBOX.h - *POUTERGAP;
|
||||
m_fBarHeight = *PSTACKED ? ((ASSIGNEDBOX.h - *POUTERGAP * *PKEEPUPPERGAP) - *POUTERGAP * (barsToDraw)) / barsToDraw : ASSIGNEDBOX.h - *POUTERGAP * *PKEEPUPPERGAP;
|
||||
|
||||
const auto DESIREDHEIGHT = *PSTACKED ? (ONEBARHEIGHT * m_dwGroupMembers.size()) + 2 + *POUTERGAP : *POUTERGAP * 2L + ONEBARHEIGHT;
|
||||
const auto DESIREDHEIGHT = *PSTACKED ? (ONEBARHEIGHT * m_dwGroupMembers.size()) + *POUTERGAP * *PKEEPUPPERGAP : *POUTERGAP * (1 + *PKEEPUPPERGAP) + ONEBARHEIGHT;
|
||||
if (DESIREDHEIGHT != ASSIGNEDBOX.h)
|
||||
g_pDecorationPositioner->repositionDeco(this);
|
||||
|
||||
|
@ -232,7 +235,7 @@ 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);
|
||||
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));
|
||||
|
|
Loading…
Add table
Reference in a new issue