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 <noreply@anthropic.com>
This commit is contained in:
Stefan HallerandClaude Opus 5.5 committed 2026-11-15 16:34:00 +01:00
1 parent a0da44403a
commit 56fa4350c7
2 files changed
+62 -17

No files matched your search

+18
View File
@@ -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{}
}
@@ -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