add findWindows()
This commit is contained in:
parent
4e5c6f2515
commit
bf8cbddf1a
|
@ -9,21 +9,6 @@ import (
|
|||
"go.wit.com/widget"
|
||||
)
|
||||
|
||||
func (tk *guiWidget) redrawWindow(w int, h int) {
|
||||
if tk.node.WidgetType != widget.Window {
|
||||
return
|
||||
}
|
||||
tk.setFullSize() // might make the green box the right size
|
||||
|
||||
tk.DrawAt(w, h)
|
||||
tk.setColor(&colorActiveW) // sets the window to Green BG
|
||||
tk.placeWidgets(w, h) // compute the sizes & places for each widget
|
||||
tk.showWidgets()
|
||||
|
||||
tk.setFullSize()
|
||||
me.baseGui.SetView(tk.cuiName, tk.gocuiSize.w0, tk.gocuiSize.h0, tk.gocuiSize.w1, tk.gocuiSize.h1, 0)
|
||||
}
|
||||
|
||||
// this whole things was impossible to make but it got me where I am now
|
||||
// the debugging is way way better now with it being visible in the Stdout window
|
||||
// so now it's possible to redo all this and make it better
|
||||
|
|
20
find.go
20
find.go
|
@ -58,6 +58,26 @@ func (tk *guiWidget) findByXYreal(w int, h int) []*guiWidget {
|
|||
return widgets
|
||||
}
|
||||
|
||||
// returns all the windows from the root of the binary tree
|
||||
func findWindows() []*guiWidget {
|
||||
rootW := me.treeRoot.TK.(*guiWidget)
|
||||
return rootW.findWindows()
|
||||
}
|
||||
|
||||
// walk the binary tree looking for WidgetType == Window
|
||||
func (tk *guiWidget) findWindows() []*guiWidget {
|
||||
var found []*guiWidget
|
||||
|
||||
if tk.node.WidgetType == widget.Window {
|
||||
found = append(found, tk)
|
||||
}
|
||||
|
||||
for _, child := range tk.children {
|
||||
found = append(found, child.findWindows()...)
|
||||
}
|
||||
return found
|
||||
}
|
||||
|
||||
func (tk *guiWidget) setFullSize() rectType {
|
||||
r := tk.getFullSize()
|
||||
|
||||
|
|
50
window.go
50
window.go
|
@ -9,37 +9,43 @@ import (
|
|||
"go.wit.com/widget"
|
||||
)
|
||||
|
||||
func (tk *guiWidget) redrawWindow(w int, h int) {
|
||||
if tk.node.WidgetType != widget.Window {
|
||||
return
|
||||
}
|
||||
tk.setFullSize() // might make the green box the right size
|
||||
|
||||
tk.DrawAt(w, h)
|
||||
tk.setColor(&colorActiveW) // sets the window to Green BG
|
||||
tk.placeWidgets(w, h) // compute the sizes & places for each widget
|
||||
tk.showWidgets()
|
||||
|
||||
tk.setFullSize()
|
||||
me.baseGui.SetView(tk.cuiName, tk.gocuiSize.w0, tk.gocuiSize.h0, tk.gocuiSize.w1, tk.gocuiSize.h1, 0)
|
||||
}
|
||||
|
||||
// re-draws the buttons for each of the windows
|
||||
func (tk *guiWidget) redoWindows(nextW int, nextH int) {
|
||||
|
||||
for _, child := range tk.children {
|
||||
if child.node.WidgetType != widget.Window {
|
||||
continue
|
||||
}
|
||||
child.gocuiSize.w0 = nextW
|
||||
child.gocuiSize.h0 = nextH
|
||||
for _, win := range findWindows() {
|
||||
win.gocuiSize.w0 = nextW
|
||||
win.gocuiSize.h0 = nextH
|
||||
|
||||
tmp := fmt.Sprintf("redoWindowsS (%d,%d)", nextW, nextH)
|
||||
child.dumpWidget(tmp)
|
||||
win.dumpWidget(tmp)
|
||||
|
||||
child.frame = false
|
||||
child.hasTabs = false
|
||||
win.frame = false
|
||||
win.hasTabs = false
|
||||
|
||||
// this should make the window the full size and re-draw it
|
||||
child.setFullSize() // child.gocuiSetWH(nextW, nextH)
|
||||
child.Hide()
|
||||
child.DrawAt(nextW, nextH)
|
||||
child.Show()
|
||||
win.setFullSize() // win.gocuiSetWH(nextW, nextH)
|
||||
win.Hide()
|
||||
win.DrawAt(nextW, nextH)
|
||||
win.Show()
|
||||
|
||||
tmp = fmt.Sprintf("redoWindowsE (%d,%d)", nextW, nextH)
|
||||
child.dumpWidget(tmp)
|
||||
win.dumpWidget(tmp)
|
||||
|
||||
nextW += child.gocuiSize.Width() + 4
|
||||
child.redoWindows(nextW, nextH)
|
||||
/*
|
||||
sizeW := child.gocuiSize.Width()
|
||||
nextW += sizeW + 4
|
||||
child.redoWindows(startW+3, startH+2)
|
||||
*/
|
||||
// increment the width for the next window
|
||||
nextW += win.gocuiSize.Width() + 4
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue