window dragging works fairly well

This commit is contained in:
Jeff Carr 2025-02-05 16:30:06 -06:00
parent 07f6b7842e
commit efebe00640
5 changed files with 19 additions and 5 deletions

View File

@ -30,9 +30,13 @@ func (w *guiWidget) dumpWindows(s string) {
log.Log(ERROR, "dump w.TK == nil", w.node.WidgetId, w.node.WidgetType, w.String()) log.Log(ERROR, "dump w.TK == nil", w.node.WidgetId, w.node.WidgetType, w.String())
return return
} }
s += fmt.Sprintf("(%d,%d)", w.force.w0, w.force.h0)
if w.node.WidgetType == widget.Window { if w.node.WidgetType == widget.Window {
s += fmt.Sprintf(" F(%d,%d)", w.force.w0, w.force.h0)
// can't set this here. doesn't work
// w.full.w0 = w.force.w0
// w.full.h0 = w.force.h0
w.dumpWidget("dumpWindow() " + s) w.dumpWidget("dumpWindow() " + s)
w.windowFrame.dumpWidget("dumpFrame() " + s)
} }
for _, child := range w.children { for _, child := range w.children {

View File

@ -77,6 +77,8 @@ func (tk *guiWidget) placeWidgets(startW int, startH int) (int, int) {
switch tk.node.WidgetType { switch tk.node.WidgetType {
case widget.Window: case widget.Window:
tk.full.w0 = startW
tk.full.h0 = startH
startW += 4 startW += 4
startH += 4 startH += 4
for _, child := range tk.children { for _, child := range tk.children {

View File

@ -194,6 +194,7 @@ func (tk *guiWidget) setFullSize() bool {
} }
// widget might be forced to a certain location // widget might be forced to a certain location
if tk.full.w0 < tk.force.w0 { if tk.full.w0 < tk.force.w0 {
tk.gocuiSize.w0 = tk.force.w0
tk.full.w0 = tk.force.w0 tk.full.w0 = tk.force.w0
changed = false changed = false
} }
@ -207,6 +208,7 @@ func (tk *guiWidget) setFullSize() bool {
} }
// widget might be forced to a certain location // widget might be forced to a certain location
if tk.full.h0 < tk.force.h0 { if tk.full.h0 < tk.force.h0 {
tk.gocuiSize.h0 = tk.force.h0
tk.full.h0 = tk.force.h0 tk.full.h0 = tk.force.h0
changed = false changed = false
} }

View File

@ -43,6 +43,8 @@ func (tk *guiWidget) drawView() {
tk.resize = true tk.resize = true
tk.textResize() // resize window only once tk.textResize() // resize window only once
} else { } else {
tk.full.w0 = tk.force.w0
tk.full.h0 = tk.force.h0
// for windows, make it the full size // for windows, make it the full size
a = tk.full.w0 a = tk.full.w0
b = tk.full.h0 b = tk.full.h0

View File

@ -31,6 +31,10 @@ func (tk *guiWidget) redrawWindow(w int, h int) {
tk.setColor(&colorActiveW) // sets the window to Green BG tk.setColor(&colorActiveW) // sets the window to Green BG
tk.placeWidgets(w, h) // compute the sizes & places for each widget tk.placeWidgets(w, h) // compute the sizes & places for each widget
// this is a test. this should not be needed
tk.full.w0 = tk.force.w0
tk.full.h0 = tk.force.h0
tk.setFullSize() tk.setFullSize()
me.baseGui.SetView(tk.cuiName, tk.gocuiSize.w0, tk.gocuiSize.h0, tk.gocuiSize.w1, tk.gocuiSize.h1, 0) me.baseGui.SetView(tk.cuiName, tk.gocuiSize.w0, tk.gocuiSize.h0, tk.gocuiSize.w1, tk.gocuiSize.h1, 0)
tk.Show() tk.Show()
@ -43,13 +47,13 @@ func (tk *guiWidget) redrawWindow(w int, h int) {
} }
// tk.windowFrame.MoveToOffset(w, h+2) // tk.windowFrame.MoveToOffset(w, h+2)
r := tk.getFullSize() r := tk.getFullSize()
tk.windowFrame.gocuiSize.w0 = r.w0 tk.windowFrame.gocuiSize.w0 = tk.force.w0
tk.windowFrame.gocuiSize.w1 = r.w1 + 1 tk.windowFrame.gocuiSize.w1 = r.w1 + 1
tk.windowFrame.gocuiSize.h0 = r.h0 + 2 tk.windowFrame.gocuiSize.h0 = tk.force.h0 + 2
tk.windowFrame.gocuiSize.h1 = r.h1 + 1 tk.windowFrame.gocuiSize.h1 = r.h1 + 1
tk.windowFrame.full.w0 = r.w0 tk.windowFrame.full.w0 = tk.force.w0
tk.windowFrame.full.w1 = r.w1 + 1 tk.windowFrame.full.w1 = r.w1 + 1
tk.windowFrame.full.h0 = r.h0 + 2 tk.windowFrame.full.h0 = tk.force.h0 + 2
tk.windowFrame.full.h1 = r.h1 + 1 tk.windowFrame.full.h1 = r.h1 + 1
// tk.windowFrame.drawView() // tk.windowFrame.drawView()
tk.windowFrame.Hide() tk.windowFrame.Hide()