gocui: windows & tabs in seperate rows
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
132efe17fe
commit
ea37ba6823
|
@ -13,7 +13,9 @@ import (
|
||||||
func (w *cuiWidget) doWidgetClick() {
|
func (w *cuiWidget) doWidgetClick() {
|
||||||
switch w.widgetType {
|
switch w.widgetType {
|
||||||
case toolkit.Root:
|
case toolkit.Root:
|
||||||
// me.rootNode.logicalSize.w1 = 1
|
// THIS IS THE BEGINING OF THE LAYOUT
|
||||||
|
me.rootNode.nextW = 0
|
||||||
|
me.rootNode.nextH = 0
|
||||||
me.rootNode.redoTabs(true)
|
me.rootNode.redoTabs(true)
|
||||||
case toolkit.Flag:
|
case toolkit.Flag:
|
||||||
me.rootNode.redoColor(true)
|
me.rootNode.redoColor(true)
|
||||||
|
|
|
@ -46,9 +46,9 @@ func addDebugKeys(g *gocui.Gui) {
|
||||||
func(g *gocui.Gui, v *gocui.View) error {
|
func(g *gocui.Gui, v *gocui.View) error {
|
||||||
log(logNow, "gocui.SetKeyBinding() dumpTree() START")
|
log(logNow, "gocui.SetKeyBinding() dumpTree() START")
|
||||||
// me.rootNode.dumpTree(true)
|
// me.rootNode.dumpTree(true)
|
||||||
if (showDebug) {
|
|
||||||
fakeStartWidth = me.DevelOffsetW
|
fakeStartWidth = me.DevelOffsetW
|
||||||
fakeStartHeight = me.TabH + me.FramePadH
|
fakeStartHeight = me.TabH + me.FramePadH
|
||||||
|
if (showDebug) {
|
||||||
me.rootNode.showFake()
|
me.rootNode.showFake()
|
||||||
showDebug = false
|
showDebug = false
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -39,9 +39,9 @@ func layout(g *gocui.Gui) error {
|
||||||
if _, err := g.View("msg"); msgMouseDown && err == nil {
|
if _, err := g.View("msg"); msgMouseDown && err == nil {
|
||||||
moveMsg(g)
|
moveMsg(g)
|
||||||
}
|
}
|
||||||
// if v, err := g.SetView("global", -1, -1, maxX, maxY, 0); err != nil {
|
// TODO: figure out what this might be useful for
|
||||||
// what is this do? I made it just the top 2 lines for now. Is this useful for something?
|
// what is this do? I made it just 2 lines for now. Is this useful for something?
|
||||||
if v, err := g.SetView("global", -1, -1, maxX, 2, 10); err != nil {
|
if v, err := g.SetView("global", 15, 5, maxX, 8, 10); err != nil {
|
||||||
if !errors.Is(err, gocui.ErrUnknownView) {
|
if !errors.Is(err, gocui.ErrUnknownView) {
|
||||||
log("global failed", maxX, maxY)
|
log("global failed", maxX, maxY)
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -51,10 +51,13 @@ type config struct {
|
||||||
PadH int `default:"1" dense:"0"`
|
PadH int `default:"1" dense:"0"`
|
||||||
|
|
||||||
// additional amount of space to put between window & tab widgets
|
// additional amount of space to put between window & tab widgets
|
||||||
TabPadW int `default:"2" dense:"0"`
|
WindowPadW int `default:"8" dense:"0"`
|
||||||
|
TabPadW int `default:"4" dense:"0"`
|
||||||
|
|
||||||
// how far down to start Window or Tab headings
|
// how far down to start Window or Tab headings
|
||||||
WindowH int `default:"1" dense:"0"`
|
WindowW int `default:"20" dense:"0"`
|
||||||
|
WindowH int `default:"0" dense:"0"`
|
||||||
|
TabW int `default:"2" dense:"0"`
|
||||||
TabH int `default:"2" dense:"0"`
|
TabH int `default:"2" dense:"0"`
|
||||||
|
|
||||||
// additional amount of space to indent on a group
|
// additional amount of space to indent on a group
|
||||||
|
|
|
@ -56,11 +56,19 @@ func (w *cuiWidget) showWidgets() {
|
||||||
|
|
||||||
func (w *cuiWidget) setTabWH() {
|
func (w *cuiWidget) setTabWH() {
|
||||||
// set the start and size of the tab gocui button
|
// set the start and size of the tab gocui button
|
||||||
t := len(w.text)
|
if w.frame {
|
||||||
|
// this means it should work like a tab
|
||||||
w.gocuiSize.w0 = me.rootNode.nextW
|
w.gocuiSize.w0 = me.rootNode.nextW
|
||||||
w.gocuiSize.h0 = me.rootNode.nextH
|
w.gocuiSize.h0 = me.TabH
|
||||||
w.gocuiSize.w1 = w.gocuiSize.w1 + t + me.PadW
|
} else {
|
||||||
w.gocuiSize.h1 = w.gocuiSize.h1 + me.DefaultHeight + me.PadH
|
// this means it should just be a window label
|
||||||
|
w.gocuiSize.w0 = me.rootNode.nextW
|
||||||
|
w.gocuiSize.h0 = me.WindowH
|
||||||
|
}
|
||||||
|
|
||||||
|
t := len(w.text)
|
||||||
|
w.gocuiSize.w1 = w.gocuiSize.w0 + t + me.PadW
|
||||||
|
w.gocuiSize.h1 = w.gocuiSize.h0 + me.DefaultHeight + me.PadH
|
||||||
|
|
||||||
w.realWidth = w.gocuiSize.Width()
|
w.realWidth = w.gocuiSize.Width()
|
||||||
w.realHeight = w.gocuiSize.Height()
|
w.realHeight = w.gocuiSize.Height()
|
||||||
|
@ -68,10 +76,13 @@ func (w *cuiWidget) setTabWH() {
|
||||||
if w.frame {
|
if w.frame {
|
||||||
w.realWidth += me.FramePadW
|
w.realWidth += me.FramePadW
|
||||||
w.realHeight += me.FramePadH
|
w.realHeight += me.FramePadH
|
||||||
}
|
|
||||||
|
|
||||||
// move the rootNode width over for the next window or tab
|
// move the rootNode width over for the next tab
|
||||||
me.rootNode.nextW += w.realWidth + me.TabPadW
|
me.rootNode.nextW += w.realWidth + me.TabPadW
|
||||||
|
} else {
|
||||||
|
// move the rootNode width over for the next window
|
||||||
|
me.rootNode.nextW += w.realWidth + me.WindowPadW
|
||||||
|
}
|
||||||
|
|
||||||
w.showWidgetPlacement(logNow, "setTabWH:")
|
w.showWidgetPlacement(logNow, "setTabWH:")
|
||||||
}
|
}
|
||||||
|
@ -92,11 +103,11 @@ func (w *cuiWidget) redoTabs(draw bool) {
|
||||||
w.frame = true
|
w.frame = true
|
||||||
}
|
}
|
||||||
w.setTabWH()
|
w.setTabWH()
|
||||||
|
|
||||||
w.deleteView()
|
w.deleteView()
|
||||||
w.drawView()
|
w.drawView()
|
||||||
}
|
}
|
||||||
if (w.widgetType == toolkit.Tab) {
|
if (w.widgetType == toolkit.Tab) {
|
||||||
|
w.setTabWH()
|
||||||
w.deleteView()
|
w.deleteView()
|
||||||
w.drawView()
|
w.drawView()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue