gocui: hmm. trying to reformat the layout
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
816ee16b67
commit
092ac51f5e
|
@ -5,21 +5,24 @@ import (
|
||||||
"git.wit.org/wit/gui/toolkit"
|
"git.wit.org/wit/gui/toolkit"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// TODO: make these defaults in config struct definition
|
||||||
var fakeStartWidth int = 40
|
var fakeStartWidth int = 40
|
||||||
var fakeStartHeight int = 3
|
var fakeStartHeight int = 3
|
||||||
func (w *cuiWidget) setFake() {
|
func (w *cuiWidget) setFake() {
|
||||||
w.isFake = true
|
w.isFake = true
|
||||||
t := len(w.name)
|
t := len(w.name)
|
||||||
// setup fake labels for non-visable things off screen
|
// setup fake labels for non-visable things off screen
|
||||||
w.realWidth = t + 2
|
|
||||||
w.realHeight = me.defaultHeight
|
|
||||||
|
|
||||||
w.gocuiSize.width = t + 2
|
w.gocuiSize.width = t + me.PadW
|
||||||
w.gocuiSize.height = me.defaultHeight
|
w.gocuiSize.height = me.DefaultHeight + me.PadH
|
||||||
w.gocuiSize.w0 = fakeStartWidth
|
w.gocuiSize.w0 = fakeStartWidth
|
||||||
w.gocuiSize.h0 = fakeStartHeight
|
w.gocuiSize.h0 = fakeStartHeight
|
||||||
|
|
||||||
fakeStartHeight += 3
|
w.realWidth = w.gocuiSize.width + me.FramePadW
|
||||||
|
w.realHeight = w.gocuiSize.height + me.FramePadH
|
||||||
|
|
||||||
|
fakeStartHeight += w.realHeight
|
||||||
|
// TODO: use the actual max hight of the terminal window
|
||||||
if (fakeStartHeight > 24) {
|
if (fakeStartHeight > 24) {
|
||||||
fakeStartHeight = 3
|
fakeStartHeight = 3
|
||||||
fakeStartWidth += 20
|
fakeStartWidth += 20
|
||||||
|
@ -64,11 +67,11 @@ func (w *cuiWidget) addWidget() {
|
||||||
return
|
return
|
||||||
case toolkit.Group:
|
case toolkit.Group:
|
||||||
w.startW = w.parent.startW + 4
|
w.startW = w.parent.startW + 4
|
||||||
w.startH = w.parent.startH + 3
|
w.startH = w.parent.startH + me.DefaultHeight + me.FramePadH
|
||||||
|
|
||||||
t := len(w.text)
|
t := len(w.text)
|
||||||
w.gocuiSize.width = t + me.buttonPadding
|
w.gocuiSize.width = t + me.FramePadW
|
||||||
w.gocuiSize.height = me.defaultHeight
|
w.gocuiSize.height = me.DefaultHeight + me.FramePadH
|
||||||
return
|
return
|
||||||
default:
|
default:
|
||||||
w.startW = w.parent.startW
|
w.startW = w.parent.startW
|
||||||
|
|
|
@ -22,9 +22,9 @@ func makeWidget(a *toolkit.Action) *cuiWidget {
|
||||||
|
|
||||||
t := len(w.text)
|
t := len(w.text)
|
||||||
w.realWidth = t + me.buttonPadding
|
w.realWidth = t + me.buttonPadding
|
||||||
w.realHeight = me.defaultHeight
|
w.realHeight = me.DefaultHeight
|
||||||
w.gocuiSize.width = t + me.buttonPadding
|
w.gocuiSize.width = t + me.buttonPadding
|
||||||
w.gocuiSize.height = me.defaultHeight
|
w.gocuiSize.height = me.DefaultHeight
|
||||||
|
|
||||||
w.widgetType = a.WidgetType
|
w.widgetType = a.WidgetType
|
||||||
w.id = a.WidgetId
|
w.id = a.WidgetId
|
||||||
|
@ -33,6 +33,11 @@ func makeWidget(a *toolkit.Action) *cuiWidget {
|
||||||
// set the gocui view.Frame = true by default
|
// set the gocui view.Frame = true by default
|
||||||
w.frame = true
|
w.frame = true
|
||||||
|
|
||||||
|
if (w.frame) {
|
||||||
|
w.realHeight += me.FramePadH
|
||||||
|
w.gocuiSize.height += me.FramePadH
|
||||||
|
}
|
||||||
|
|
||||||
if w.widgetType == toolkit.Root {
|
if w.widgetType == toolkit.Root {
|
||||||
log(logInfo, "setupWidget() FOUND ROOT w.id =", w.id, "w.parent", w.parent, "ParentId =", a.ParentId)
|
log(logInfo, "setupWidget() FOUND ROOT w.id =", w.id, "w.parent", w.parent, "ParentId =", a.ParentId)
|
||||||
w.id = 0
|
w.id = 0
|
||||||
|
|
|
@ -15,19 +15,15 @@ func init() {
|
||||||
log(logInfo, "Init() of awesome-gocui")
|
log(logInfo, "Init() of awesome-gocui")
|
||||||
Set(&me, "default")
|
Set(&me, "default")
|
||||||
|
|
||||||
me.groupPadding = 4
|
// me.groupPadding = 4
|
||||||
me.buttonPadding = 3
|
// me.buttonPadding = 3
|
||||||
|
|
||||||
// the raw beginning of each window (or tab)
|
|
||||||
me.rawW = 7
|
|
||||||
me.rawH = 3
|
|
||||||
|
|
||||||
// todo, remove all of these
|
// todo, remove all of these
|
||||||
me.defaultWidth = 10
|
// me.defaultWidth = 10
|
||||||
me.defaultHeight = 2 // this means by default one line of text in a button
|
// me.defaultHeight = 2 // this means by default one line of text in a button
|
||||||
|
|
||||||
me.horizontalPadding = 20
|
// me.horizontalPadding = 20
|
||||||
me.horizontalPadding = 20
|
// me.horizontalPadding = 20
|
||||||
// todo, remove all of these
|
// todo, remove all of these
|
||||||
|
|
||||||
me.pluginChan = make(chan toolkit.Action)
|
me.pluginChan = make(chan toolkit.Action)
|
||||||
|
|
|
@ -88,10 +88,10 @@ func (w *cuiWidget) placeWidgets() {
|
||||||
switch w.widgetType {
|
switch w.widgetType {
|
||||||
case toolkit.Window:
|
case toolkit.Window:
|
||||||
for _, child := range w.children {
|
for _, child := range w.children {
|
||||||
w.startW = me.rawW
|
w.startW = me.RawW
|
||||||
w.startH = me.rawH
|
w.startH = me.RawH
|
||||||
w.nextW = me.rawW
|
w.nextW = me.RawW
|
||||||
w.nextH = me.rawH
|
w.nextH = me.RawH
|
||||||
w.showWidgetPlacement(logNow, "place()")
|
w.showWidgetPlacement(logNow, "place()")
|
||||||
child.placeWidgets()
|
child.placeWidgets()
|
||||||
if (w.realWidth < child.realWidth) {
|
if (w.realWidth < child.realWidth) {
|
||||||
|
@ -104,10 +104,10 @@ func (w *cuiWidget) placeWidgets() {
|
||||||
}
|
}
|
||||||
case toolkit.Tab:
|
case toolkit.Tab:
|
||||||
for _, child := range w.children {
|
for _, child := range w.children {
|
||||||
w.startW = me.rawW
|
w.startW = me.RawW
|
||||||
w.startH = me.rawH
|
w.startH = me.RawH
|
||||||
w.nextW = me.rawW
|
w.nextW = me.RawW
|
||||||
w.nextH = me.rawH
|
w.nextH = me.RawH
|
||||||
w.showWidgetPlacement(logNow, "place()")
|
w.showWidgetPlacement(logNow, "place()")
|
||||||
child.placeWidgets()
|
child.placeWidgets()
|
||||||
if (w.realWidth < child.realWidth) {
|
if (w.realWidth < child.realWidth) {
|
||||||
|
|
|
@ -35,18 +35,30 @@ type config struct {
|
||||||
helpLabel *gocui.View
|
helpLabel *gocui.View
|
||||||
|
|
||||||
DefaultBehavior bool `default:"true"`
|
DefaultBehavior bool `default:"true"`
|
||||||
defaultWidth int
|
|
||||||
defaultHeight int
|
|
||||||
// nextW int // where the next window or tab flag should go
|
|
||||||
|
|
||||||
// the amount to put between winodw tab widgets
|
// Buttons, Group, Tabs, Windows, etc are by default assumed to be a single line
|
||||||
TabPadW int `default:"4" dense:"2"`
|
// as a default, we make buttons 8 chars wide
|
||||||
// PadH int `default:"3" dense:"2"`
|
DefaultWidth int `default:"8"`
|
||||||
|
DefaultHeight int `default:"1"`
|
||||||
|
|
||||||
|
// When the widget has a frame, like a button, it adds 2 lines runes on each side
|
||||||
|
// so you need 3 char spacing in each direction to not have them overlap
|
||||||
|
// the amount of padding when there is a frame
|
||||||
|
FramePadW int `default:"4" dense:"0"`
|
||||||
|
FramePadH int `default:"1" dense:"0"`
|
||||||
|
|
||||||
|
PadW int `default:"1" dense:"0"`
|
||||||
|
PadH int `default:"1" dense:"0"`
|
||||||
|
|
||||||
|
// additional amount of space to put between window & tab widgets
|
||||||
|
TabPadW int `default:"2" dense:"0"`
|
||||||
|
|
||||||
|
// additional amount of space to indent on a group
|
||||||
|
GroupPadW int `default:"6" dense:"2"`
|
||||||
|
|
||||||
// the raw beginning of each window (or tab)
|
// the raw beginning of each window (or tab)
|
||||||
rawW int `default:"7"`
|
RawW int `default:"7"`
|
||||||
JWC int `default:"7"`
|
RawH int `default:"3"`
|
||||||
rawH int `default:"3"`
|
|
||||||
|
|
||||||
bookshelf bool // do you want things arranged in the box like a bookshelf or a stack?
|
bookshelf bool // do you want things arranged in the box like a bookshelf or a stack?
|
||||||
canvas bool // if set to true, the windows are a raw canvas
|
canvas bool // if set to true, the windows are a raw canvas
|
||||||
|
@ -55,8 +67,8 @@ type config struct {
|
||||||
padded bool // add space between things like buttons
|
padded bool // add space between things like buttons
|
||||||
margin bool // add space around the frames of windows
|
margin bool // add space around the frames of windows
|
||||||
|
|
||||||
horizontalPadding int
|
// horizontalPadding int
|
||||||
groupPadding int `default:"6" dense:"2"` // this is supposed to be how far to indent to the left
|
// groupPadding int `default:"6" dense:"2"` // this is supposed to be how far to indent to the left
|
||||||
buttonPadding int `default:"4" dense:"3"` // if 3, buttons slightly overlap
|
buttonPadding int `default:"4" dense:"3"` // if 3, buttons slightly overlap
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,19 +55,17 @@ 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)
|
t := len(w.text)
|
||||||
w.gocuiSize.width = t + me.buttonPadding
|
w.gocuiSize.width = t + me.PadW
|
||||||
w.gocuiSize.height = me.defaultHeight
|
w.gocuiSize.height = me.DefaultHeight + me.PadH
|
||||||
w.gocuiSize.w0 = me.rootNode.nextW
|
w.gocuiSize.w0 = me.rootNode.nextW
|
||||||
w.gocuiSize.h0 = me.rootNode.nextH
|
w.gocuiSize.h0 = me.rootNode.nextH
|
||||||
|
|
||||||
|
w.realWidth = w.gocuiSize.width + me.FramePadW
|
||||||
|
w.realHeight = w.gocuiSize.height + me.FramePadH
|
||||||
|
|
||||||
// move the rootNode width over for the next window or tab
|
// move the rootNode width over for the next window or tab
|
||||||
me.rootNode.nextW += w.gocuiSize.width + me.TabPadW
|
me.rootNode.nextW += w.gocuiSize.width + me.TabPadW
|
||||||
|
|
||||||
w.startW = me.rawW
|
|
||||||
w.startH = me.rawH
|
|
||||||
w.nextW = me.rawW
|
|
||||||
w.nextH = me.rawH
|
|
||||||
|
|
||||||
w.setWH()
|
w.setWH()
|
||||||
w.showWidgetPlacement(logNow, "setTabWH:")
|
w.showWidgetPlacement(logNow, "setTabWH:")
|
||||||
}
|
}
|
||||||
|
@ -83,11 +81,6 @@ func (w *cuiWidget) setLabel() {
|
||||||
// move the rootNode width over for the next window or tab
|
// move the rootNode width over for the next window or tab
|
||||||
me.rootNode.nextW += w.gocuiSize.width
|
me.rootNode.nextW += w.gocuiSize.width
|
||||||
|
|
||||||
w.startW = me.rawW
|
|
||||||
w.startH = me.rawH
|
|
||||||
w.nextW = me.rawW
|
|
||||||
w.nextH = me.rawH
|
|
||||||
|
|
||||||
w.setWH()
|
w.setWH()
|
||||||
w.showWidgetPlacement(logNow, "setLabel:")
|
w.showWidgetPlacement(logNow, "setLabel:")
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,8 +30,8 @@ func (w *cuiWidget) textResize() {
|
||||||
}
|
}
|
||||||
height = i
|
height = i
|
||||||
}
|
}
|
||||||
w.gocuiSize.width = width + 3
|
w.gocuiSize.width = width + me.FramePadW
|
||||||
w.gocuiSize.height = me.defaultHeight + height
|
w.gocuiSize.height = height + me.FramePadH
|
||||||
w.setWH()
|
w.setWH()
|
||||||
w.showWidgetPlacement(logNow, "textResize()")
|
w.showWidgetPlacement(logNow, "textResize()")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue