add findWindows()
This commit is contained in:
parent
4e5c6f2515
commit
bf8cbddf1a
|
@ -9,21 +9,6 @@ import (
|
||||||
"go.wit.com/widget"
|
"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
|
// 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
|
// 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
|
// 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
|
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 {
|
func (tk *guiWidget) setFullSize() rectType {
|
||||||
r := tk.getFullSize()
|
r := tk.getFullSize()
|
||||||
|
|
||||||
|
|
50
window.go
50
window.go
|
@ -9,37 +9,43 @@ import (
|
||||||
"go.wit.com/widget"
|
"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
|
// re-draws the buttons for each of the windows
|
||||||
func (tk *guiWidget) redoWindows(nextW int, nextH int) {
|
func (tk *guiWidget) redoWindows(nextW int, nextH int) {
|
||||||
|
for _, win := range findWindows() {
|
||||||
for _, child := range tk.children {
|
win.gocuiSize.w0 = nextW
|
||||||
if child.node.WidgetType != widget.Window {
|
win.gocuiSize.h0 = nextH
|
||||||
continue
|
|
||||||
}
|
|
||||||
child.gocuiSize.w0 = nextW
|
|
||||||
child.gocuiSize.h0 = nextH
|
|
||||||
|
|
||||||
tmp := fmt.Sprintf("redoWindowsS (%d,%d)", nextW, nextH)
|
tmp := fmt.Sprintf("redoWindowsS (%d,%d)", nextW, nextH)
|
||||||
child.dumpWidget(tmp)
|
win.dumpWidget(tmp)
|
||||||
|
|
||||||
child.frame = false
|
win.frame = false
|
||||||
child.hasTabs = false
|
win.hasTabs = false
|
||||||
|
|
||||||
// this should make the window the full size and re-draw it
|
// this should make the window the full size and re-draw it
|
||||||
child.setFullSize() // child.gocuiSetWH(nextW, nextH)
|
win.setFullSize() // win.gocuiSetWH(nextW, nextH)
|
||||||
child.Hide()
|
win.Hide()
|
||||||
child.DrawAt(nextW, nextH)
|
win.DrawAt(nextW, nextH)
|
||||||
child.Show()
|
win.Show()
|
||||||
|
|
||||||
tmp = fmt.Sprintf("redoWindowsE (%d,%d)", nextW, nextH)
|
tmp = fmt.Sprintf("redoWindowsE (%d,%d)", nextW, nextH)
|
||||||
child.dumpWidget(tmp)
|
win.dumpWidget(tmp)
|
||||||
|
|
||||||
nextW += child.gocuiSize.Width() + 4
|
// increment the width for the next window
|
||||||
child.redoWindows(nextW, nextH)
|
nextW += win.gocuiSize.Width() + 4
|
||||||
/*
|
|
||||||
sizeW := child.gocuiSize.Width()
|
|
||||||
nextW += sizeW + 4
|
|
||||||
child.redoWindows(startW+3, startH+2)
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue