gocui: next step hide junk
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
6b7d1fb30b
commit
c29faf4f9b
|
@ -0,0 +1,95 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
// "github.com/awesome-gocui/gocui"
|
||||||
|
"git.wit.org/wit/gui/toolkit"
|
||||||
|
)
|
||||||
|
|
||||||
|
var fakeStartWidth int = 40
|
||||||
|
var fakeStartHeight int = 3
|
||||||
|
func (w *cuiWidget) setFake() {
|
||||||
|
if (w.isFake == false) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
t := len(w.name)
|
||||||
|
// setup fake labels for non-visable things off screen
|
||||||
|
w.realWidth = t + 2
|
||||||
|
w.realHeight = me.defaultHeight
|
||||||
|
|
||||||
|
w.gocuiSize.width = t + 2
|
||||||
|
w.gocuiSize.height = me.defaultHeight
|
||||||
|
w.gocuiSize.startW = fakeStartWidth
|
||||||
|
w.gocuiSize.startH = fakeStartHeight
|
||||||
|
|
||||||
|
fakeStartHeight += 3
|
||||||
|
if (fakeStartHeight > 24) {
|
||||||
|
fakeStartHeight = 3
|
||||||
|
fakeStartWidth += 20
|
||||||
|
}
|
||||||
|
w.setWH()
|
||||||
|
w.showWidgetPlacement(logNow, "setFake()")
|
||||||
|
}
|
||||||
|
|
||||||
|
// set the widget start width & height
|
||||||
|
func (w *cuiWidget) addWidget() {
|
||||||
|
log(logInfo, "setStartWH() w.id =", w.id, "w.name", w.name)
|
||||||
|
switch w.widgetType {
|
||||||
|
case toolkit.Root:
|
||||||
|
log(logInfo, "setStartWH() rootNode w.id =", w.id, "w.name", w.name)
|
||||||
|
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.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.startW = w.parent.startW
|
||||||
|
w.startH = w.parent.startH
|
||||||
|
w.showWidgetPlacement(logNow, "StartWH:")
|
||||||
|
w.drawView()
|
||||||
|
return
|
||||||
|
case toolkit.Group:
|
||||||
|
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()
|
||||||
|
}
|
||||||
|
}
|
|
@ -6,7 +6,7 @@ import (
|
||||||
// "github.com/awesome-gocui/gocui"
|
// "github.com/awesome-gocui/gocui"
|
||||||
)
|
)
|
||||||
|
|
||||||
func setupWidget(a *toolkit.Action) *cuiWidget {
|
func makeWidget(a *toolkit.Action) *cuiWidget {
|
||||||
var w *cuiWidget
|
var w *cuiWidget
|
||||||
w = new(cuiWidget)
|
w = new(cuiWidget)
|
||||||
|
|
||||||
|
|
|
@ -5,33 +5,9 @@ import (
|
||||||
"git.wit.org/wit/gui/toolkit"
|
"git.wit.org/wit/gui/toolkit"
|
||||||
)
|
)
|
||||||
|
|
||||||
var fakeStartWidth int = 40
|
/*
|
||||||
var fakeStartHeight int = 3
|
|
||||||
func (w *cuiWidget) setFake() {
|
|
||||||
if (w.isFake == false) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
t := len(w.name)
|
|
||||||
// setup fake labels for non-visable things off screen
|
|
||||||
w.realWidth = t + 2
|
|
||||||
w.realHeight = me.defaultHeight
|
|
||||||
|
|
||||||
w.gocuiSize.width = t + 2
|
|
||||||
w.gocuiSize.height = me.defaultHeight
|
|
||||||
w.gocuiSize.startW = fakeStartWidth
|
|
||||||
w.gocuiSize.startH = fakeStartHeight
|
|
||||||
|
|
||||||
fakeStartHeight += 3
|
|
||||||
if (fakeStartHeight > 24) {
|
|
||||||
fakeStartHeight = 3
|
|
||||||
fakeStartWidth += 20
|
|
||||||
}
|
|
||||||
w.setWH()
|
|
||||||
w.showWidgetPlacement(logNow, "setFake()")
|
|
||||||
}
|
|
||||||
|
|
||||||
// find the start (w,h) for child a inside a box widget
|
// find the start (w,h) for child a inside a box widget
|
||||||
func (w *cuiWidget) getBoxWH() {
|
func (w *cuiWidget) setBoxWH() {
|
||||||
p := w.parent // the parent must be a box widget
|
p := w.parent // the parent must be a box widget
|
||||||
|
|
||||||
// update parent gocuiSize
|
// update parent gocuiSize
|
||||||
|
@ -63,6 +39,7 @@ func (w *cuiWidget) getBoxWH() {
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
// find the start (w,h) for child a inside a Group widget
|
// find the start (w,h) for child a inside a Group widget
|
||||||
func (w *cuiWidget) getGroupWH() {
|
func (w *cuiWidget) getGroupWH() {
|
||||||
|
@ -205,27 +182,6 @@ func (w *cuiWidget) moveTo(leftW int, topH int) {
|
||||||
w.showWidgetPlacement(logNow, "moveTo()")
|
w.showWidgetPlacement(logNow, "moveTo()")
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
func (w *cuiWidget) updateLogicalSizes() {
|
|
||||||
for _, child := range w.children {
|
|
||||||
// if (w.isReal)
|
|
||||||
child.updateLogicalSizes()
|
|
||||||
if (w.logicalSize.w0 > child.logicalSize.w0) {
|
|
||||||
w.logicalSize.w0 = child.logicalSize.w0
|
|
||||||
}
|
|
||||||
if (w.logicalSize.w1 < child.logicalSize.w1) {
|
|
||||||
w.logicalSize.w1 = child.logicalSize.w1
|
|
||||||
}
|
|
||||||
if (w.logicalSize.h0 > child.logicalSize.h0) {
|
|
||||||
w.logicalSize.h0 = child.logicalSize.h0
|
|
||||||
}
|
|
||||||
if (w.logicalSize.h1 < child.logicalSize.h1) {
|
|
||||||
w.logicalSize.h1 = child.logicalSize.h1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
func (w *cuiWidget) drawGrid() {
|
func (w *cuiWidget) drawGrid() {
|
||||||
w.showWidgetPlacement(logNow, "gridBounds:")
|
w.showWidgetPlacement(logNow, "gridBounds:")
|
||||||
|
|
||||||
|
|
|
@ -10,101 +10,13 @@ func Quit() {
|
||||||
me.baseGui.Close()
|
me.baseGui.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
// set the widget start width & height
|
|
||||||
// re-run this when things change to recalibrate the position of the gocui view rect
|
|
||||||
func (w *cuiWidget) setStartWH() {
|
|
||||||
log(logInfo, "setStartWH() w.id =", w.id, "w.name", w.name)
|
|
||||||
switch w.widgetType {
|
|
||||||
case toolkit.Root:
|
|
||||||
log(logInfo, "setStartWH() rootNode w.id =", w.id, "w.name", w.name)
|
|
||||||
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.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.startW = w.parent.startW
|
|
||||||
w.startH = w.parent.startH
|
|
||||||
w.showWidgetPlacement(logNow, "StartWH:")
|
|
||||||
w.drawView()
|
|
||||||
return
|
|
||||||
case toolkit.Group:
|
|
||||||
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) {
|
func Action(a *toolkit.Action) {
|
||||||
log(logInfo, "Action() START", a.WidgetId, a.ActionType, a.WidgetType, a.Name)
|
log(logInfo, "Action() START", a.WidgetId, a.ActionType, a.WidgetType, a.Name)
|
||||||
w := findWidget(a.WidgetId, me.rootNode)
|
w := findWidget(a.WidgetId, me.rootNode)
|
||||||
switch a.ActionType {
|
switch a.ActionType {
|
||||||
case toolkit.Add:
|
case toolkit.Add:
|
||||||
w = setupWidget(a)
|
w = makeWidget(a)
|
||||||
w.setStartWH()
|
w.addWidget()
|
||||||
case toolkit.Show:
|
case toolkit.Show:
|
||||||
if (a.B) {
|
if (a.B) {
|
||||||
w.drawView()
|
w.drawView()
|
||||||
|
|
Loading…
Reference in New Issue