compute window size
This commit is contained in:
parent
d61e03b877
commit
65622d01cd
5
debug.go
5
debug.go
|
@ -42,9 +42,8 @@ func (tk *guiWidget) dumpWidget(s string) {
|
|||
tk.gocuiSize.w0, tk.gocuiSize.h0, tk.gocuiSize.w1, tk.gocuiSize.h1)
|
||||
// vx0, vy0, vx1, vy1, _ := me.baseGui.ViewPosition("msg")
|
||||
// vw0, vh0, vw1, vh1, _ := me.baseGui.ViewPosition(tk.v.Name())
|
||||
vw0, vh0, vw1, vh1, _ := me.baseGui.ViewPosition(tk.v.Name())
|
||||
s1 += fmt.Sprintf(" real=(%3d,%3d,%3d,%3d)",
|
||||
vw0, vh0, vw1, vh1)
|
||||
r := tk.getFullSize()
|
||||
s1 += fmt.Sprintf(" full=(%3d,%3d,%3d,%3d)", r.w0, r.h0, r.w1, r.h1)
|
||||
} else {
|
||||
s1 += fmt.Sprintf(" %3s %3s %3s %3s ", "", "", "", "")
|
||||
s1 += fmt.Sprintf(" %3s %3s %3s %3s ", "", "", "", "")
|
||||
|
|
30
find.go
30
find.go
|
@ -57,6 +57,36 @@ func (tk *guiWidget) findByXYreal(w int, h int) []*guiWidget {
|
|||
return widgets
|
||||
}
|
||||
|
||||
// this checks a widget to see if it is under (W,H), then checks the widget's children
|
||||
// anything that matches is passed back as an array of widgets
|
||||
func (tk *guiWidget) getFullSize() rectType {
|
||||
var r rectType
|
||||
|
||||
r.w0 = tk.gocuiSize.w0
|
||||
r.w1 = tk.gocuiSize.w1
|
||||
r.h0 = tk.gocuiSize.h0
|
||||
r.h1 = tk.gocuiSize.h1
|
||||
|
||||
// search through the children widgets in the binary tree
|
||||
for _, child := range tk.children {
|
||||
cr := child.getFullSize()
|
||||
if r.w0 > cr.w0 {
|
||||
r.w0 = cr.w0
|
||||
}
|
||||
if r.h0 > cr.h0 {
|
||||
r.h0 = cr.h0
|
||||
}
|
||||
if r.w1 < cr.w1 {
|
||||
r.w1 = cr.w1
|
||||
}
|
||||
if r.h1 < cr.h1 {
|
||||
r.h1 = cr.h1
|
||||
}
|
||||
}
|
||||
|
||||
return r
|
||||
}
|
||||
|
||||
// returns the "highest priority widget under the mouse
|
||||
func findUnderMouse() *guiWidget {
|
||||
w, h := me.baseGui.MousePosition()
|
||||
|
|
Loading…
Reference in New Issue