diff --git a/pkg/gui/arrangement.go b/pkg/gui/arrangement.go index 6c7e3e067..3c6cbc5b9 100644 --- a/pkg/gui/arrangement.go +++ b/pkg/gui/arrangement.go @@ -47,7 +47,7 @@ func (gui *Gui) getMidSectionWeights() (int, int) { mainSectionWeight := int(1/sidePanelWidthRatio) - 1 sideSectionWeight := 1 - if gui.isMainPanelSplit() { + if gui.splitMainPanelSideBySide() { mainSectionWeight = 5 // need to shrink side panel to make way for main panels if side-by-side } @@ -108,6 +108,28 @@ func (gui *Gui) infoSectionChildren(informationStr string, appStatus string) []* return result } +func (gui *Gui) splitMainPanelSideBySide() bool { + if !gui.isMainPanelSplit() { + return false + } + + mainPanelSplitMode := gui.Config.GetUserConfig().Gui.MainPanelSplitMode + width, height := gui.g.Size() + + switch mainPanelSplitMode { + case "vertical": + return false + case "horizontal": + return true + default: + if width < 200 && height > 30 { // 2 80 character width panels + 40 width for side panel + return false + } else { + return true + } + } +} + func (gui *Gui) getWindowDimensions(informationStr string, appStatus string) map[string]boxlayout.Dimensions { width, height := gui.g.Size() @@ -119,6 +141,11 @@ func (gui *Gui) getWindowDimensions(informationStr string, appStatus string) map sidePanelsDirection = boxlayout.ROW } + mainPanelsDirection := boxlayout.ROW + if gui.splitMainPanelSideBySide() { + mainPanelsDirection = boxlayout.COLUMN + } + root := &boxlayout.Box{ Direction: boxlayout.ROW, Children: []*boxlayout.Box{ @@ -132,23 +159,7 @@ func (gui *Gui) getWindowDimensions(informationStr string, appStatus string) map ConditionalChildren: gui.sidePanelChildren, }, { - ConditionalDirection: func(width int, height int) int { - mainPanelSplitMode := gui.Config.GetUserConfig().Gui.MainPanelSplitMode - - switch mainPanelSplitMode { - case "vertical": - return boxlayout.ROW - case "horizontal": - return boxlayout.COLUMN - default: - if width < 160 && height > 30 { // 2 80 character width panels - return boxlayout.ROW - } else { - return boxlayout.COLUMN - } - } - }, - Direction: boxlayout.COLUMN, + Direction: mainPanelsDirection, Weight: mainSectionWeight, Children: gui.mainSectionChildren(), },