gocui: don't try to draw on add()
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
65f4d0e231
commit
bd23ef8338
|
@ -13,7 +13,7 @@ import (
|
|||
func (w *cuiWidget) doWidgetClick() {
|
||||
switch w.widgetType {
|
||||
case toolkit.Root:
|
||||
me.rootNode.logicalSize.w1 = 1
|
||||
// me.rootNode.logicalSize.w1 = 1
|
||||
me.rootNode.redoTabs(true)
|
||||
case toolkit.Flag:
|
||||
me.rootNode.redoColor(true)
|
||||
|
@ -43,9 +43,9 @@ func (w *cuiWidget) doWidgetClick() {
|
|||
case toolkit.Box:
|
||||
// w.showWidgetPlacement(logNow, "drawTree()")
|
||||
if (w.horizontal) {
|
||||
log("BOX IS HORIZONTAL", w.nextW, w.nextH, w.name)
|
||||
log("BOX IS HORIZONTAL", w.name)
|
||||
} else {
|
||||
log("BOX IS VERTICAL", w.nextW, w.nextH, w.name)
|
||||
log("BOX IS VERTICAL", w.name)
|
||||
}
|
||||
w.redoBox(true)
|
||||
w.toggleTree()
|
||||
|
@ -164,11 +164,10 @@ func ctrlDown(g *gocui.Gui, v *gocui.View) error {
|
|||
if (found == nil) {
|
||||
found = me.rootNode
|
||||
}
|
||||
found.updateLogicalSizes()
|
||||
me.ctrlDown.gocuiSize.w0 = found.logicalSize.w0
|
||||
me.ctrlDown.gocuiSize.w1 = found.logicalSize.w1
|
||||
me.ctrlDown.gocuiSize.h0 = found.logicalSize.h0
|
||||
me.ctrlDown.gocuiSize.h1 = found.logicalSize.h1
|
||||
me.ctrlDown.gocuiSize.startW = found.gocuiSize.startW
|
||||
me.ctrlDown.gocuiSize.startH = found.gocuiSize.startH
|
||||
me.ctrlDown.gocuiSize.width = found.gocuiSize.startW
|
||||
me.ctrlDown.gocuiSize.height = found.gocuiSize.startH
|
||||
|
||||
if (me.ctrlDown.v == nil) {
|
||||
me.ctrlDown.text = found.text
|
||||
|
|
|
@ -55,23 +55,6 @@ func (w *cuiWidget) showWidgetPlacement(b bool, s string) {
|
|||
case toolkit.Grid:
|
||||
s1 += fmt.Sprintf("next()=(%2d,%2d)", w.nextW, w.nextH)
|
||||
default:
|
||||
// s1 += fmt.Sprintf("L()=(%2d,%2d,%2d,%2d)",
|
||||
// w.logicalSize.w0, w.logicalSize.h0, w.logicalSize.w1, w.logicalSize.h1)
|
||||
}
|
||||
log(b, s1, s, w.widgetType, ",", w.name) // , "text=", w.text)
|
||||
|
||||
/*
|
||||
if (w.realWidth != (w.gocuiSize.w1 - w.gocuiSize.w0)) {
|
||||
log(b, "dump()", s,
|
||||
"badsize()=(", w.realWidth, ",", w.realHeight, ")",
|
||||
"badreal()=(", w.gocuiSize.w0, ",", w.gocuiSize.h0, ",", w.gocuiSize.w1, ",", w.gocuiSize.h1, ")",
|
||||
w.widgetType, ",", w.name)
|
||||
}
|
||||
if (w.realHeight != (w.gocuiSize.h1 - w.gocuiSize.h0)) {
|
||||
log(b, "dump()", s,
|
||||
"badsize()=(", w.realWidth, ",", w.realHeight, ")",
|
||||
"badreal()=(", w.gocuiSize.w0, ",", w.gocuiSize.h0, ",", w.gocuiSize.w1, ",", w.gocuiSize.h1, ")",
|
||||
w.widgetType, ",", w.name)
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
|
|
@ -1,75 +0,0 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
// "git.wit.org/wit/gui/toolkit"
|
||||
)
|
||||
|
||||
var adjusted bool = false
|
||||
|
||||
/*
|
||||
// expands the logical size of the parents
|
||||
func (w *cuiWidget) setParentLogical() {
|
||||
p := w.parent
|
||||
if (w.isFake) {
|
||||
// expand the parent logicalsize to include the widget logicalsize
|
||||
if (p.logicalSize.w0 > w.logicalSize.w0) {
|
||||
p.logicalSize.w0 = w.logicalSize.w0
|
||||
adjusted = true
|
||||
}
|
||||
if (p.logicalSize.h0 > w.logicalSize.h0) {
|
||||
p.logicalSize.h0 = w.logicalSize.h0
|
||||
adjusted = true
|
||||
}
|
||||
if (p.logicalSize.w1 < w.logicalSize.w1) {
|
||||
p.logicalSize.w1 = w.logicalSize.w1
|
||||
adjusted = true
|
||||
}
|
||||
if (p.logicalSize.h1 < w.logicalSize.h1) {
|
||||
p.logicalSize.h1 = w.logicalSize.h1
|
||||
adjusted = true
|
||||
}
|
||||
} else {
|
||||
// expand the parent logicalsize to include the widget realSize
|
||||
if (p.logicalSize.w0 > w.realSize.w0) {
|
||||
p.logicalSize.w0 = w.realSize.w0
|
||||
adjusted = true
|
||||
}
|
||||
if (p.logicalSize.h0 > w.realSize.h0) {
|
||||
p.logicalSize.h0 = w.realSize.h0
|
||||
adjusted = true
|
||||
}
|
||||
if (p.logicalSize.w1 < w.realSize.w1) {
|
||||
p.logicalSize.w1 = w.realSize.w1
|
||||
adjusted = true
|
||||
}
|
||||
if (p.logicalSize.h1 < w.realSize.h1) {
|
||||
p.logicalSize.h1 = w.realSize.h1
|
||||
adjusted = true
|
||||
}
|
||||
}
|
||||
if (! w.isFake) {
|
||||
// adjust the widget realSize to the top left corner of the logicalsize
|
||||
if (w.logicalSize.w0 > w.realSize.w0) {
|
||||
w.realSize.w0 = w.logicalSize.w0
|
||||
w.realSize.w1 = w.realSize.w0 + w.realWidth
|
||||
adjusted = true
|
||||
}
|
||||
if (w.logicalSize.h0 > w.realSize.h0) {
|
||||
w.realSize.h0 = w.logicalSize.h0
|
||||
w.realSize.h1 = w.realSize.h0 + w.realHeight
|
||||
adjusted = true
|
||||
}
|
||||
}
|
||||
w.showWidgetPlacement(logNow, "setParentLogical() widget")
|
||||
p.showWidgetPlacement(logNow, "setParentLogical() parent")
|
||||
if (w.id == 0) || (p.id == 0) {
|
||||
// stop resizing when you hit the root widget
|
||||
return
|
||||
}
|
||||
// pass the logical resizing up
|
||||
pP := w.parent
|
||||
if (pP != nil) {
|
||||
pP.setParentLogical()
|
||||
}
|
||||
}
|
||||
*/
|
|
@ -30,26 +30,6 @@ func (w *cuiWidget) setFake() {
|
|||
w.showWidgetPlacement(logNow, "setFake()")
|
||||
}
|
||||
|
||||
func findPlace(w *cuiWidget) {
|
||||
w.isFake = false
|
||||
switch w.widgetType {
|
||||
case toolkit.Root:
|
||||
w.isFake = true
|
||||
w.setFake()
|
||||
case toolkit.Flag:
|
||||
w.isFake = true
|
||||
w.setFake()
|
||||
case toolkit.Grid:
|
||||
w.isFake = true
|
||||
w.setFake()
|
||||
case toolkit.Box:
|
||||
w.isFake = true
|
||||
w.setFake()
|
||||
default:
|
||||
// w.redoBox(true)
|
||||
}
|
||||
}
|
||||
|
||||
// find the start (w,h) for child a inside a box widget
|
||||
func (w *cuiWidget) getBoxWH() {
|
||||
p := w.parent // the parent must be a box widget
|
||||
|
@ -146,11 +126,6 @@ func (w *cuiWidget) redoBox(draw bool) {
|
|||
w.nextH = p.nextH
|
||||
w.gridBounds()
|
||||
case toolkit.Box:
|
||||
w.logicalSize.w0 = p.nextW
|
||||
w.logicalSize.h0 = p.nextH
|
||||
w.logicalSize.w1 = p.nextW
|
||||
w.logicalSize.h1 = p.nextH
|
||||
|
||||
w.nextW = p.nextW
|
||||
w.nextH = p.nextH
|
||||
for _, child := range w.children {
|
||||
|
@ -201,31 +176,20 @@ func (w *cuiWidget) setWH() {
|
|||
w.gocuiSize.h0 = w.gocuiSize.startH
|
||||
w.gocuiSize.w1 = w.gocuiSize.w0 + w.gocuiSize.width
|
||||
w.gocuiSize.h1 = w.gocuiSize.h0 + w.gocuiSize.height
|
||||
|
||||
w.logicalSize.w0 = w.gocuiSize.w0
|
||||
w.logicalSize.h0 = w.gocuiSize.h0
|
||||
w.logicalSize.w1 = w.gocuiSize.w1
|
||||
w.logicalSize.h1 = w.gocuiSize.h1
|
||||
}
|
||||
|
||||
func (w *cuiWidget) moveTo(leftW int, topH int) {
|
||||
if (w.isFake) {
|
||||
// don't ever move these
|
||||
} else {
|
||||
w.gocuiSize.w0 = leftW
|
||||
w.gocuiSize.h0 = topH
|
||||
return
|
||||
}
|
||||
w.gocuiSize.w1 = w.gocuiSize.w0 + w.realWidth
|
||||
w.gocuiSize.h1 = w.gocuiSize.h0 + w.realHeight
|
||||
|
||||
w.logicalSize.w0 = w.gocuiSize.w0
|
||||
w.logicalSize.h0 = w.gocuiSize.h0
|
||||
w.logicalSize.w1 = w.gocuiSize.w1
|
||||
w.logicalSize.h1 = w.gocuiSize.h1
|
||||
w.gocuiSize.startW = leftW
|
||||
w.gocuiSize.startH = topH
|
||||
|
||||
w.setWH()
|
||||
w.showWidgetPlacement(logNow, "moveTo()")
|
||||
}
|
||||
|
||||
/*
|
||||
func (w *cuiWidget) updateLogicalSizes() {
|
||||
for _, child := range w.children {
|
||||
// if (w.isReal)
|
||||
|
@ -244,21 +208,12 @@ func (w *cuiWidget) updateLogicalSizes() {
|
|||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
func (w *cuiWidget) gridBounds() {
|
||||
w.showWidgetPlacement(logNow, "gridBounds:")
|
||||
p := w.parent
|
||||
|
||||
/*
|
||||
for a := 0; a < w.x; a++ {
|
||||
for b := 0; b < w.y; b++ {
|
||||
log(logNow, "gridBounds() (w,h)", a, b,
|
||||
"logical(W,H)", w.widths[a], w.heights[b],
|
||||
"p.next(W,H)", p.nextW, p.nextH)
|
||||
}
|
||||
log("\n")
|
||||
}
|
||||
*/
|
||||
var wCount int = 0
|
||||
var hCount int = 0
|
||||
for _, child := range w.children {
|
||||
|
|
|
@ -20,44 +20,84 @@ func (w *cuiWidget) setStartWH() {
|
|||
w.isFake = true
|
||||
w.setFake()
|
||||
w.showWidgetPlacement(logNow, "StartWH:")
|
||||
w.drawView()
|
||||
return
|
||||
case toolkit.Flag:
|
||||
w.isFake = true
|
||||
w.setFake()
|
||||
w.showWidgetPlacement(logNow, "StartWH:")
|
||||
w.drawView()
|
||||
return
|
||||
case toolkit.Window:
|
||||
w.setTabWH()
|
||||
w.showWidgetPlacement(logNow, "StartWH:")
|
||||
w.drawView()
|
||||
return
|
||||
case toolkit.Tab:
|
||||
w.setTabWH()
|
||||
w.showWidgetPlacement(logNow, "StartWH:")
|
||||
w.drawView()
|
||||
return
|
||||
case toolkit.Box:
|
||||
w.isFake = true
|
||||
w.setFake()
|
||||
w.getBoxWH()
|
||||
w.setWH()
|
||||
w.startW = w.parent.startW
|
||||
w.startH = w.parent.startH
|
||||
w.showWidgetPlacement(logNow, "StartWH:")
|
||||
w.drawView()
|
||||
return
|
||||
case toolkit.Grid:
|
||||
w.isFake = true
|
||||
w.setFake()
|
||||
w.getGridWH()
|
||||
w.setWH()
|
||||
w.startW = w.parent.startW
|
||||
w.startH = w.parent.startH
|
||||
w.showWidgetPlacement(logNow, "StartWH:")
|
||||
w.drawView()
|
||||
return
|
||||
case toolkit.Group:
|
||||
w.getGroupWH()
|
||||
w.startW = w.parent.startW + 4
|
||||
w.startH = w.parent.startH + 3
|
||||
|
||||
t := len(w.text)
|
||||
w.gocuiSize.width = t + me.buttonPadding
|
||||
w.gocuiSize.height = me.defaultHeight
|
||||
w.gocuiSize.startW = w.startW
|
||||
w.gocuiSize.startH = w.startH
|
||||
|
||||
w.setWH()
|
||||
w.showWidgetPlacement(logNow, "StartWH:")
|
||||
w.drawView()
|
||||
return
|
||||
default:
|
||||
w.startW = w.parent.startW
|
||||
w.startH = w.parent.startH
|
||||
w.setWH()
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
func (w *cuiWidget) setStartFromParent() {
|
||||
p := w.parent
|
||||
switch p.widgetType {
|
||||
case toolkit.Box:
|
||||
w.getBoxWH()
|
||||
case toolkit.Group:
|
||||
w.getGroupWH()
|
||||
case toolkit.Grid:
|
||||
w.getGridWH()
|
||||
default:
|
||||
w.gocuiSize.startW = p.startW
|
||||
w.gocuiSize.startH = p.startH
|
||||
}
|
||||
w.gocuiSize.startW = w.startW
|
||||
w.gocuiSize.startH = w.startH
|
||||
|
||||
w.startW = w.gocuiSize.startW
|
||||
w.startH = w.gocuiSize.startH
|
||||
w.showWidgetPlacement(logNow, "sSFP:")
|
||||
}
|
||||
*/
|
||||
|
||||
func Action(a *toolkit.Action) {
|
||||
log(logInfo, "Action() START", a.WidgetId, a.ActionType, a.WidgetType, a.Name)
|
||||
w := findWidget(a.WidgetId, me.rootNode)
|
||||
|
@ -65,9 +105,6 @@ func Action(a *toolkit.Action) {
|
|||
case toolkit.Add:
|
||||
w = setupWidget(a)
|
||||
w.setStartWH()
|
||||
// w.moveTo(w.startW, w.startH)
|
||||
w.drawView()
|
||||
// findPlace(w)
|
||||
case toolkit.Show:
|
||||
if (a.B) {
|
||||
w.drawView()
|
||||
|
|
|
@ -107,7 +107,7 @@ type cuiWidget struct {
|
|||
realHeight int
|
||||
|
||||
gocuiSize rectType // the display size of this widget
|
||||
logicalSize rectType // the logical size. Includes all the child widgets
|
||||
// logicalSize rectType // the logical size. Includes all the child widgets
|
||||
|
||||
// used to track the size of grids
|
||||
widths map[int]int // how tall each row in the grid is
|
||||
|
|
|
@ -57,6 +57,9 @@ func (w *cuiWidget) setTabWH() {
|
|||
w.gocuiSize.startW = me.rootNode.startW
|
||||
w.gocuiSize.startH = me.rootNode.startH
|
||||
|
||||
w.startW = w.gocuiSize.startW + 2
|
||||
w.startH = w.gocuiSize.startH + 3
|
||||
|
||||
for _, child := range me.rootNode.children {
|
||||
if (child.isFake) {
|
||||
continue
|
||||
|
@ -69,51 +72,17 @@ func (w *cuiWidget) setTabWH() {
|
|||
w.gocuiSize.startW += child.realWidth
|
||||
}
|
||||
|
||||
w.startW = me.rootNode.startW
|
||||
w.startH = me.rootNode.startH + me.buttonPadding
|
||||
|
||||
w.setWH()
|
||||
w.showWidgetPlacement(logNow, "setTabWH:")
|
||||
}
|
||||
|
||||
func (w *cuiWidget) redoTabs(draw bool) {
|
||||
if (w == nil) {
|
||||
return
|
||||
}
|
||||
log(logVerbose, "redoTabs() START about to check for window and tab ", w.name)
|
||||
w.text = w.name
|
||||
t := len(w.text)
|
||||
if ((w.widgetType == toolkit.Window) || (w.widgetType == toolkit.Tab)) {
|
||||
log(logVerbose, "redoTabs() in Window and Tab", w.name)
|
||||
w.realWidth = t + me.buttonPadding
|
||||
w.realHeight = me.defaultHeight
|
||||
|
||||
w.gocuiSize.w0 = me.rootNode.logicalSize.w1
|
||||
w.gocuiSize.w1 = w.gocuiSize.w0 + w.realWidth
|
||||
w.gocuiSize.h0 = 0
|
||||
w.gocuiSize.h1 = w.realHeight
|
||||
|
||||
// start logical sizes windows and in the top left corner
|
||||
w.logicalSize.w0 = 2
|
||||
w.logicalSize.w1 = 2
|
||||
w.logicalSize.h0 = w.realHeight
|
||||
w.logicalSize.h1 = w.realHeight
|
||||
|
||||
// start all windows and in the top left corner
|
||||
w.nextW = w.logicalSize.w0
|
||||
w.nextH = w.logicalSize.h0
|
||||
|
||||
me.rootNode.logicalSize.w1 = w.gocuiSize.w1
|
||||
me.rootNode.logicalSize.h1 = w.gocuiSize.h1
|
||||
|
||||
w.deleteView()
|
||||
w.drawView()
|
||||
w.showWidgetPlacement(logNow, "redoTabs()")
|
||||
}
|
||||
|
||||
log(logVerbose, "redoTabs() about to for loop children", w.name)
|
||||
for _, child := range w.children {
|
||||
log(logVerbose, "redoTabs() got to child", child.name)
|
||||
child.redoTabs(draw)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue