gocui: it might actually work
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
bd23ef8338
commit
1b7b794dd2
|
@ -18,28 +18,17 @@ func (w *cuiWidget) doWidgetClick() {
|
||||||
case toolkit.Flag:
|
case toolkit.Flag:
|
||||||
me.rootNode.redoColor(true)
|
me.rootNode.redoColor(true)
|
||||||
case toolkit.Window:
|
case toolkit.Window:
|
||||||
w.redoBox(true)
|
w.drawBox()
|
||||||
w.toggleTree()
|
w.toggleTree()
|
||||||
case toolkit.Tab:
|
case toolkit.Tab:
|
||||||
w.redoBox(true)
|
w.drawBox()
|
||||||
w.toggleTree()
|
w.toggleTree()
|
||||||
case toolkit.Group:
|
case toolkit.Group:
|
||||||
w.redoBox(true)
|
w.drawBox()
|
||||||
w.toggleTree()
|
w.toggleTree()
|
||||||
case toolkit.Grid:
|
case toolkit.Grid:
|
||||||
// w.setParentLogical()
|
w.drawGrid()
|
||||||
w.gridBounds()
|
w.toggleTree()
|
||||||
// w.setParentLogical()
|
|
||||||
for _, child := range w.children {
|
|
||||||
child.showWidgetPlacement(logNow, "gridBounds:")
|
|
||||||
if (child.v == nil) {
|
|
||||||
child.drawView()
|
|
||||||
} else {
|
|
||||||
child.deleteView()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// w.toggleTree()
|
|
||||||
// w.redoBox(true)
|
|
||||||
case toolkit.Box:
|
case toolkit.Box:
|
||||||
// w.showWidgetPlacement(logNow, "drawTree()")
|
// w.showWidgetPlacement(logNow, "drawTree()")
|
||||||
if (w.horizontal) {
|
if (w.horizontal) {
|
||||||
|
@ -47,7 +36,7 @@ func (w *cuiWidget) doWidgetClick() {
|
||||||
} else {
|
} else {
|
||||||
log("BOX IS VERTICAL", w.name)
|
log("BOX IS VERTICAL", w.name)
|
||||||
}
|
}
|
||||||
w.redoBox(true)
|
w.drawBox()
|
||||||
w.toggleTree()
|
w.toggleTree()
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,8 @@ func setupWidget(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.height = me.defaultHeight
|
||||||
|
|
||||||
w.widgetType = a.WidgetType
|
w.widgetType = a.WidgetType
|
||||||
w.id = a.WidgetId
|
w.id = a.WidgetId
|
||||||
|
|
|
@ -96,10 +96,10 @@ func (w *cuiWidget) getGridWH() {
|
||||||
w.startH = p.startH
|
w.startH = p.startH
|
||||||
w.nextW = p.startW
|
w.nextW = p.startW
|
||||||
w.nextH = p.startH
|
w.nextH = p.startH
|
||||||
w.gridBounds()
|
w.drawGrid()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *cuiWidget) redoBox(draw bool) {
|
func (w *cuiWidget) drawBox() {
|
||||||
if (w == nil) {
|
if (w == nil) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -114,60 +114,82 @@ func (w *cuiWidget) redoBox(draw bool) {
|
||||||
|
|
||||||
switch w.widgetType {
|
switch w.widgetType {
|
||||||
case toolkit.Window:
|
case toolkit.Window:
|
||||||
|
// draw only one thing
|
||||||
for _, child := range w.children {
|
for _, child := range w.children {
|
||||||
child.redoBox(draw)
|
child.drawBox()
|
||||||
|
return
|
||||||
}
|
}
|
||||||
case toolkit.Tab:
|
case toolkit.Tab:
|
||||||
|
// draw only one thing
|
||||||
for _, child := range w.children {
|
for _, child := range w.children {
|
||||||
child.redoBox(draw)
|
child.drawBox()
|
||||||
|
return
|
||||||
}
|
}
|
||||||
case toolkit.Grid:
|
case toolkit.Grid:
|
||||||
w.nextW = p.nextW
|
w.startW = p.startW
|
||||||
w.nextH = p.nextH
|
w.startH = p.startH
|
||||||
w.gridBounds()
|
w.getGridWH()
|
||||||
|
w.showWidgetPlacement(logNow, "drawBox:")
|
||||||
case toolkit.Box:
|
case toolkit.Box:
|
||||||
w.nextW = p.nextW
|
w.startW = p.startW
|
||||||
w.nextH = p.nextH
|
w.startH = p.startH
|
||||||
|
var maxW int
|
||||||
|
var maxH int
|
||||||
for _, child := range w.children {
|
for _, child := range w.children {
|
||||||
child.redoBox(draw)
|
child.drawBox()
|
||||||
if (w.horizontal) {
|
if (w.horizontal) {
|
||||||
log("BOX IS HORIZONTAL", p.nextW, p.nextW, p.name)
|
|
||||||
log("BOX IS HORIZONTAL", w.nextW, w.nextH, w.name)
|
|
||||||
log("BOX IS HORIZONTAL")
|
log("BOX IS HORIZONTAL")
|
||||||
// expand based on the child width
|
// expand based on the child width
|
||||||
w.nextW = child.nextW + me.horizontalPadding
|
w.startW += child.realWidth
|
||||||
// reset height to parent
|
|
||||||
w.nextH = p.nextH
|
|
||||||
} else {
|
} else {
|
||||||
log("BOX IS VERTICAL", p.nextW, p.nextW, p.name)
|
|
||||||
log("BOX IS VERTICAL", w.nextW, w.nextH, w.name)
|
|
||||||
log("BOX IS VERTICAL")
|
log("BOX IS VERTICAL")
|
||||||
// go straight down
|
|
||||||
w.nextW = p.nextW
|
|
||||||
// expand based on the child height
|
// expand based on the child height
|
||||||
w.nextH = child.nextH
|
w.startH += child.realHeight
|
||||||
|
}
|
||||||
|
if (maxW < child.realWidth) {
|
||||||
|
maxW = child.realWidth
|
||||||
|
}
|
||||||
|
if (maxH < child.realHeight) {
|
||||||
|
maxH = child.realHeight
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
w.showWidgetPlacement(logNow, "box:")
|
w.realWidth = maxW
|
||||||
|
w.realHeight = maxH
|
||||||
|
w.showWidgetPlacement(logNow, "drawBox:")
|
||||||
case toolkit.Group:
|
case toolkit.Group:
|
||||||
w.moveTo(p.nextW, p.nextH)
|
w.startW = p.startW
|
||||||
|
w.startH = p.startH
|
||||||
|
w.gocuiSize.startW = w.startW
|
||||||
|
w.gocuiSize.startH = w.startH
|
||||||
|
w.realWidth = w.gocuiSize.width
|
||||||
|
w.realHeight = w.gocuiSize.height
|
||||||
|
w.setWH()
|
||||||
|
|
||||||
w.nextW = p.nextW + me.groupPadding
|
w.startW = p.startW + 4
|
||||||
w.nextH = p.nextH + me.buttonPadding
|
w.startH = p.startH + 3
|
||||||
|
var maxW int
|
||||||
|
var maxH int
|
||||||
for _, child := range w.children {
|
for _, child := range w.children {
|
||||||
child.redoBox(draw)
|
child.drawBox()
|
||||||
// reset nextW to straight down
|
// reset nextW to straight down
|
||||||
w.nextW = p.nextW + 4
|
w.startH += child.realHeight
|
||||||
w.nextH = child.nextH
|
if (maxW < child.realWidth) {
|
||||||
|
maxW = child.realWidth
|
||||||
|
}
|
||||||
|
if (maxH < child.realHeight) {
|
||||||
|
maxH = child.realHeight
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// expand the height of the parent now that the group is done
|
w.realWidth += maxW
|
||||||
// p.nextW = w.nextW
|
w.realHeight += maxH
|
||||||
// p.nextH = w.nextH
|
w.showWidgetPlacement(logNow, "drawBox:")
|
||||||
w.showWidgetPlacement(logNow, "group:")
|
|
||||||
default:
|
default:
|
||||||
w.moveTo(p.nextW, p.nextH)
|
w.startW = p.startW
|
||||||
w.nextW = w.gocuiSize.w1
|
w.startH = p.startH
|
||||||
w.nextH = w.gocuiSize.h1
|
w.gocuiSize.startW = w.startW
|
||||||
|
w.gocuiSize.startH = w.startH
|
||||||
|
w.setWH()
|
||||||
|
w.showWidgetPlacement(logNow, "drawBox:")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -210,17 +232,16 @@ func (w *cuiWidget) updateLogicalSizes() {
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
func (w *cuiWidget) gridBounds() {
|
func (w *cuiWidget) drawGrid() {
|
||||||
w.showWidgetPlacement(logNow, "gridBounds:")
|
w.showWidgetPlacement(logNow, "gridBounds:")
|
||||||
p := w.parent
|
|
||||||
|
|
||||||
var wCount int = 0
|
var wCount int = 0
|
||||||
var hCount int = 0
|
var hCount int = 0
|
||||||
for _, child := range w.children {
|
for _, child := range w.children {
|
||||||
// increment for the next child
|
// increment for the next child
|
||||||
w.nextW = p.nextW + wCount * 20
|
w.nextW = w.startW + wCount * 20
|
||||||
w.nextH = p.nextH + hCount * 2
|
w.nextH = w.startH + hCount * 2
|
||||||
child.redoBox(true)
|
// child.drawBox()
|
||||||
|
|
||||||
// set the child's realWidth, and grid offset
|
// set the child's realWidth, and grid offset
|
||||||
child.parentH = hCount
|
child.parentH = hCount
|
||||||
|
@ -271,11 +292,12 @@ func (w *cuiWidget) gridBounds() {
|
||||||
realW := w.nextW + totalW
|
realW := w.nextW + totalW
|
||||||
realH := w.nextH + totalH
|
realH := w.nextH + totalH
|
||||||
|
|
||||||
|
log(logNow, "gridBounds()", child.id, "parent (W,H) =", child.parentW, child.parentH,
|
||||||
log(logInfo, "gridBounds()", child.id, "parent (W,H) =", child.parentW, child.parentH,
|
|
||||||
"total (W,H) =", totalW, totalH,
|
"total (W,H) =", totalW, totalH,
|
||||||
"real (W,H) =", realW, realH)
|
"real (W,H) =", realW, realH)
|
||||||
child.moveTo(realW, realH)
|
w.startW = realW
|
||||||
|
w.startH = realH
|
||||||
|
child.drawBox()
|
||||||
child.showWidgetPlacement(logInfo, "gridBounds:")
|
child.showWidgetPlacement(logInfo, "gridBounds:")
|
||||||
log(logInfo)
|
log(logInfo)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue