Scale the side-panel layout height thresholds by panel count

The height thresholds that decide between the proportional layout and
the squashed layout (and, within the squashed layout, between 3-row and
1-row unfocused panels) were hard-coded constants tuned for the fixed
set of five side panels. Now that the panels are configurable, a layout
with fewer panels has less to fit, yet was still forced into the
squashed layout at the same height as five panels would be.

Scale the thresholds down in proportion to the panel count so a smaller
layout keeps using the proportional layout at smaller heights. Only ever
scale down: raising the thresholds for more panels would make them
squash sooner, which works against the reason someone adds panels in the
first place (they want to see them).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Stefan Haller 2026-07-01 17:05:11 +02:00
parent 758b5dde1f
commit b039d98b09

View file

@ -430,6 +430,15 @@ func sidePanelChildren(args WindowArrangementArgs) func(width int, height int) [
return func(width int, height int) []*boxlayout.Box {
windows := sideWindowNames(args.UserConfig)
// These thresholds were originally tuned for the default five side panels.
// With fewer panels there's less to fit, so scale them down proportionally
// to keep using the proportional layout at smaller heights rather than
// squashing unnecessarily. We only ever scale down: making more panels
// squash sooner tends to work against the reason people add panels.
const defaultSidePanelCount = 5
minHeightForNormalLayout := min(28, 28*len(windows)/defaultSidePanelCount)
minHeightForTallSquashedPanels := min(21, 21*len(windows)/defaultSidePanelCount)
boxForEachWindow := func(boxForWindow func(window string) *boxlayout.Box) []*boxlayout.Box {
boxes := make([]*boxlayout.Box, 0, len(windows))
for _, window := range windows {
@ -454,7 +463,7 @@ func sidePanelChildren(args WindowArrangementArgs) func(width int, height int) [
}
return boxForEachWindow(fullHeightBox)
} else if height >= 28 {
} else if height >= minHeightForNormalLayout {
accordionMode := args.UserConfig.Gui.ExpandFocusedSidePanel
accordionBox := func(defaultBox *boxlayout.Box) *boxlayout.Box {
if accordionMode && defaultBox.Window == args.CurrentSideWindow {
@ -487,7 +496,7 @@ func sidePanelChildren(args WindowArrangementArgs) func(width int, height int) [
}
squashedHeight := 1
if height >= 21 {
if height >= minHeightForTallSquashedPanels {
squashedHeight = 3
}