gocui: more dumb and broken attempts at fixing this code
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
0fb9ab6702
commit
5146cdfa80
|
@ -46,8 +46,9 @@ func (w *cuiWidget) showWidgetPlacement(b bool, s string) {
|
||||||
pId = w.parent.id
|
pId = w.parent.id
|
||||||
}
|
}
|
||||||
s1 = fmt.Sprintf("(wId,pId)=(%2d,%2d) ", w.id, pId)
|
s1 = fmt.Sprintf("(wId,pId)=(%2d,%2d) ", w.id, pId)
|
||||||
s1 += fmt.Sprintf("real()=(%2d,%2d,%2d,%2d) ", w.gocuiSize.w0, w.gocuiSize.h0, w.gocuiSize.w1, w.gocuiSize.h1)
|
s1 += fmt.Sprintf("W,H()=(%2d,%2d) ", w.startW, w.startH)
|
||||||
s1 += fmt.Sprintf("size()=(%2d,%2d) ", w.realWidth, w.realHeight)
|
s1 += fmt.Sprintf("size()=(%2d,%2d) ", w.realWidth, w.realHeight)
|
||||||
|
s1 += fmt.Sprintf("real()=(%2d,%2d,%2d,%2d) ", w.gocuiSize.w0, w.gocuiSize.h0, w.gocuiSize.w1, w.gocuiSize.h1)
|
||||||
|
|
||||||
switch w.widgetType {
|
switch w.widgetType {
|
||||||
case toolkit.Grid:
|
case toolkit.Grid:
|
||||||
|
|
|
@ -15,15 +15,15 @@ func (w *cuiWidget) setFake() {
|
||||||
// setup fake labels for non-visable things off screen
|
// setup fake labels for non-visable things off screen
|
||||||
w.realWidth = t + 2
|
w.realWidth = t + 2
|
||||||
w.realHeight = me.defaultHeight
|
w.realHeight = me.defaultHeight
|
||||||
w.gocuiSize.w0 = fakeStartWidth
|
w.startW = fakeStartWidth
|
||||||
w.gocuiSize.h0 = fakeStartHeight
|
w.startH = fakeStartHeight
|
||||||
w.gocuiSize.w1 = w.gocuiSize.w0 + w.realWidth
|
|
||||||
w.gocuiSize.h1 = w.gocuiSize.h0 + w.realHeight
|
|
||||||
fakeStartHeight += 3
|
fakeStartHeight += 3
|
||||||
if (fakeStartHeight > 24) {
|
if (fakeStartHeight > 24) {
|
||||||
fakeStartHeight = 3
|
fakeStartHeight = 3
|
||||||
fakeStartWidth += 20
|
fakeStartWidth += 20
|
||||||
}
|
}
|
||||||
|
w.setWH()
|
||||||
w.showWidgetPlacement(logNow, "setFake()")
|
w.showWidgetPlacement(logNow, "setFake()")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -193,6 +193,18 @@ func (w *cuiWidget) redoBox(draw bool) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (w *cuiWidget) setWH() {
|
||||||
|
w.gocuiSize.w0 = w.startW
|
||||||
|
w.gocuiSize.h0 = w.startH
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
func (w *cuiWidget) moveTo(leftW int, topH int) {
|
func (w *cuiWidget) moveTo(leftW int, topH int) {
|
||||||
if (w.isFake) {
|
if (w.isFake) {
|
||||||
// don't ever move these
|
// don't ever move these
|
||||||
|
|
|
@ -22,22 +22,26 @@ func (w *cuiWidget) setStartWH() {
|
||||||
w.id = 0
|
w.id = 0
|
||||||
w.isFake = true
|
w.isFake = true
|
||||||
w.setFake()
|
w.setFake()
|
||||||
w.showWidgetPlacement(logNow, "Tree:")
|
w.showWidgetPlacement(logNow, "StartWH:")
|
||||||
return
|
return
|
||||||
case toolkit.Flag:
|
case toolkit.Flag:
|
||||||
w.startW = 1
|
w.startW = 1
|
||||||
w.startH = 1
|
w.startH = 1
|
||||||
w.isFake = true
|
w.isFake = true
|
||||||
w.setFake()
|
w.setFake()
|
||||||
w.showWidgetPlacement(logNow, "Tree:")
|
w.showWidgetPlacement(logNow, "StartWH:")
|
||||||
return
|
return
|
||||||
case toolkit.Window:
|
case toolkit.Window:
|
||||||
w.startW = 1
|
w.startW = 1
|
||||||
w.startH = 3
|
w.startH = 3
|
||||||
|
w.setTabWH()
|
||||||
|
w.showWidgetPlacement(logNow, "StartWH:")
|
||||||
return
|
return
|
||||||
case toolkit.Tab:
|
case toolkit.Tab:
|
||||||
w.startW = 1
|
w.startW = 1
|
||||||
w.startH = 3
|
w.startH = 3
|
||||||
|
w.setTabWH()
|
||||||
|
w.showWidgetPlacement(logNow, "StartWH:")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
p := w.parent
|
p := w.parent
|
||||||
|
|
|
@ -48,6 +48,31 @@ func (w *cuiWidget) showWidgets() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (w *cuiWidget) setTabWH() {
|
||||||
|
t := len(w.text)
|
||||||
|
|
||||||
|
w.realWidth = t + me.buttonPadding
|
||||||
|
w.realHeight = me.defaultHeight
|
||||||
|
|
||||||
|
startW := 1
|
||||||
|
startH := 1
|
||||||
|
|
||||||
|
for _, child := range me.rootNode.children {
|
||||||
|
if (w == child) {
|
||||||
|
w.startW = startW
|
||||||
|
w.startH = startH
|
||||||
|
w.moveTo(w.startW, w.startH)
|
||||||
|
w.showWidgetPlacement(logNow, "setTabWH:")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
startW += child.realWidth
|
||||||
|
}
|
||||||
|
w.startW = startW
|
||||||
|
w.startH = startH
|
||||||
|
w.setWH()
|
||||||
|
w.showWidgetPlacement(logNow, "setTabWH:")
|
||||||
|
}
|
||||||
|
|
||||||
func (w *cuiWidget) redoTabs(draw bool) {
|
func (w *cuiWidget) redoTabs(draw bool) {
|
||||||
if (w == nil) {
|
if (w == nil) {
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in New Issue