From 56fa4350c748a998f8bac04964a5c31aee36eb90 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Sun, 15 Nov 2026 16:34:00 +0100 Subject: [PATCH] Name the layouts that show both the side panels and the main view A later commit remembers a size of the side panels separately for each of these layouts. Naming them also makes it easier to see which weights apply in which screen mode. Co-Authored-By: Claude Opus 5.5 --- pkg/config/app_state.go | 18 ++++++ .../helpers/window_arrangement_helper.go | 61 +++++++++++++------ 2 files changed, 62 insertions(+), 17 deletions(-) diff --git a/pkg/config/app_state.go b/pkg/config/app_state.go index b1e55caa5..907365e7f 100644 --- a/pkg/config/app_state.go +++ b/pkg/config/app_state.go @@ -247,6 +247,24 @@ type AppState struct { HideCommandLog bool } +// SidePanelLayout names an arrangement of the side panels relative to the main +// view. It only covers the arrangements that show both. +type SidePanelLayout string + +const ( + // The side panels are left of the main view. + SidePanelLayoutNormal SidePanelLayout = "normal" + // The side panels are above the main view (portrait mode). + SidePanelLayoutNormalPortrait SidePanelLayout = "normalPortrait" + // The side panels are left of the main view, and the main view is split + // into two panes side by side. + SidePanelLayoutSplitMainPanel SidePanelLayout = "splitMainPanel" + // Half screen mode, with the focused side panel left of the main view. + SidePanelLayoutHalfScreen SidePanelLayout = "halfScreen" + // Half screen mode, with the focused side panel above the main view. + SidePanelLayoutHalfScreenTop SidePanelLayout = "halfScreenTop" +) + func getDefaultAppState() *AppState { return &AppState{} } diff --git a/pkg/gui/controllers/helpers/window_arrangement_helper.go b/pkg/gui/controllers/helpers/window_arrangement_helper.go index 72e267177..fc08d00a9 100644 --- a/pkg/gui/controllers/helpers/window_arrangement_helper.go +++ b/pkg/gui/controllers/helpers/window_arrangement_helper.go @@ -238,31 +238,58 @@ func mainSectionChildren(args WindowArrangementArgs) []*boxlayout.Box { return []*boxlayout.Box{mainPane, secondaryPane} } +// sidePanelLayout returns how the side panels are arranged relative to the main +// view, or false if only one of the two is visible. +func sidePanelLayout(args WindowArrangementArgs) (config.SidePanelLayout, bool) { + if args.ScreenMode == types.SCREEN_FULL { + return "", false + } + if args.ScreenMode == types.SCREEN_HALF { + if isMainWindow(args.CurrentWindow) { + return "", false + } + if args.UserConfig.Gui.EnlargedSideViewLocation == "top" { + return config.SidePanelLayoutHalfScreenTop, true + } + return config.SidePanelLayoutHalfScreen, true + } + + if shouldUsePortraitMode(args) { + return config.SidePanelLayoutNormalPortrait, true + } + if splitMainPanelSideBySide(args) { + return config.SidePanelLayoutSplitMainPanel, true + } + return config.SidePanelLayoutNormal, true +} + +func isMainWindow(window string) bool { + return window == "main" || window == "secondary" +} + func getMidSectionWeights(args WindowArrangementArgs) (int, int) { + layout, ok := sidePanelLayout(args) + if !ok { + if isMainWindow(args.CurrentWindow) { + return 0, 1 + } + return 1, 0 + } + sidePanelWidthRatio := args.UserConfig.Gui.SidePanelWidth // Using 120 so that the default of 0.3333 will remain consistent with previous behavior const maxColumnCount = 120 mainSectionWeight := int(math.Round(maxColumnCount * (1 - sidePanelWidthRatio))) sideSectionWeight := int(math.Round(maxColumnCount * sidePanelWidthRatio)) - if splitMainPanelSideBySide(args) && !shouldUsePortraitMode(args) { + switch layout { + case config.SidePanelLayoutSplitMainPanel: mainSectionWeight = sideSectionWeight * 5 // need to shrink side panel to make way for main panels if side-by-side - } - - if args.CurrentWindow == "main" || args.CurrentWindow == "secondary" { - if args.ScreenMode == types.SCREEN_HALF || args.ScreenMode == types.SCREEN_FULL { - sideSectionWeight = 0 - } - } else { - if args.ScreenMode == types.SCREEN_HALF { - if args.UserConfig.Gui.EnlargedSideViewLocation == "top" { - mainSectionWeight = sideSectionWeight * 2 - } else { - mainSectionWeight = sideSectionWeight - } - } else if args.ScreenMode == types.SCREEN_FULL { - mainSectionWeight = 0 - } + case config.SidePanelLayoutHalfScreen: + mainSectionWeight = sideSectionWeight + case config.SidePanelLayoutHalfScreenTop: + mainSectionWeight = sideSectionWeight * 2 + case config.SidePanelLayoutNormal, config.SidePanelLayoutNormalPortrait: } return sideSectionWeight, mainSectionWeight