Skip to content

Commit 7cf2c3b

Browse files
committed
fix(bar): align grouped widget hover spacing
1 parent 4607988 commit 7cf2c3b

1 file changed

Lines changed: 10 additions & 9 deletions

File tree

src/shell/bar/bar.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ namespace {
457457
// only the hovered member lights up.
458458
void placeCapsuleHoverBoxes(
459459
BarCapsuleRun& run, bool isVertical, float shellW, float shellH, float contentX, float contentY,
460-
float capsuleRadius
460+
float capsuleRadius, float widgetHoverPadding
461461
) {
462462
if (run.hoverBoxes.empty()) {
463463
return;
@@ -474,9 +474,9 @@ namespace {
474474
}
475475
const float scale = run.contentScale;
476476
const float crossInset = kGroupHoverCrossInset * scale;
477-
// Same breathing room a single capsule would give the member; pills may reach into the
478-
// gap toward a neighbor, which is fine — only the hovered member's pill is visible.
479-
const float mainPad = run.spec.padding * scale;
477+
// Use the normal per-widget inset, independent of the shared capsule's configurable
478+
// padding, so grouped and standalone widgets receive the same hover treatment.
479+
const float mainInset = widgetHoverPadding * scale;
480480
const float shellMain = isVertical ? shellH : shellW;
481481
const float shellCross = isVertical ? shellW : shellH;
482482
const float contentMain = isVertical ? contentY : contentX;
@@ -496,8 +496,8 @@ namespace {
496496
}
497497
const float rootStart = contentMain + (isVertical ? member->y() : member->x());
498498
const float rootExtent = isVertical ? member->height() : member->width();
499-
const float mainStart = std::max(0.0f, rootStart - mainPad);
500-
const float mainExtent = std::max(0.0f, std::min(shellMain, rootStart + rootExtent + mainPad) - mainStart);
499+
const float mainStart = std::max(0.0f, rootStart - mainInset);
500+
const float mainExtent = std::max(0.0f, std::min(shellMain, rootStart + rootExtent + mainInset) - mainStart);
501501
if (isVertical) {
502502
box->setPosition(crossInset, mainStart);
503503
box->setSize(crossExtent, mainExtent);
@@ -927,7 +927,8 @@ namespace {
927927
// Capsule cross-size is a fraction of the bar thickness (capsule_thickness), the same for every capsule
928928
// regardless of per-widget content scale. The max() guard keeps a thin bar from yielding a 0px capsule.
929929
const float capsuleCross = std::max(1.0f, std::round(slotCross * instance.barConfig.capsuleThickness));
930-
auto finalizeCapsules = [isVertical, capsuleCross, &renderer](std::vector<BarCapsuleRun>& runs) {
930+
auto finalizeCapsules = [isVertical, capsuleCross, widgetHoverPadding = instance.barConfig.widgetCapsulePadding,
931+
&renderer](std::vector<BarCapsuleRun>& runs) {
931932
for (auto& run : runs) {
932933
Node* shell = run.shell;
933934
Box* bg = run.bg;
@@ -959,7 +960,7 @@ namespace {
959960
bg->setVisible(false);
960961
bg->setPosition(0.0f, 0.0f);
961962
bg->setSize(iw, ih);
962-
placeCapsuleHoverBoxes(run, isVertical, iw, ih, 0.0f, 0.0f, std::min(iw, ih) * 0.5f);
963+
placeCapsuleHoverBoxes(run, isVertical, iw, ih, 0.0f, 0.0f, std::min(iw, ih) * 0.5f, widgetHoverPadding);
963964
continue;
964965
}
965966
const float pad = run.spec.padding * scale;
@@ -984,7 +985,7 @@ namespace {
984985
const float capsuleRadius = radiusSource != nullptr ? radiusSource->resolvedBarCapsuleRadius(shellW, shellH)
985986
: std::max(0.0f, std::min(shellW, shellH) * 0.5f);
986987
bg->setRadius(capsuleRadius);
987-
placeCapsuleHoverBoxes(run, isVertical, shellW, shellH, contentX, contentY, capsuleRadius);
988+
placeCapsuleHoverBoxes(run, isVertical, shellW, shellH, contentX, contentY, capsuleRadius, widgetHoverPadding);
988989
}
989990
};
990991
finalizeCapsules(instance.startCapsuleRuns);

0 commit comments

Comments
 (0)