summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2020-10-13 07:25:56 +1100
committerJesse Duffield <jessedduffield@gmail.com>2020-10-13 07:31:14 +1100
commit624fb8da21c644fe79c9c11848930f8ff4b6dede (patch)
tree8ed5262d0edc83584a451d006188886d0be4cb16
parent1ff405edd8aa818a2924ab61c930ab58a77e03ea (diff)
preserve width of side panel when main view split unless window is wide enough
-rw-r--r--pkg/gui/arrangement.go47
1 files changed, 29 insertions, 18 deletions
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(),
},