finally. dense window view

This commit is contained in:
Jeff Carr 2025-02-06 20:34:29 -06:00
parent e39bcafb78
commit 5d1a3b2578
3 changed files with 36 additions and 6 deletions

View File

@ -7,7 +7,6 @@ import (
"strings"
"go.wit.com/log"
"go.wit.com/toolkits/tree"
"go.wit.com/widget"
)
@ -150,12 +149,24 @@ func (tk *guiWidget) placeWidgets(startW int, startH int) (int, int) {
return 0, 0
}
func (tk *guiWidget) isWindowDense() bool {
if tk.node.WidgetType == widget.Window {
return tk.window.dense
}
if tk.parent == nil {
return true
}
return tk.parent.isWindowDense()
}
func (w *guiWidget) placeGrid(startW int, startH int) (int, int) {
// w.showWidgetPlacement("grid0:")
if w.node.WidgetType != widget.Grid {
return 0, 0
}
dense := w.isWindowDense()
w.full.w0 = startW
w.full.h0 = startH
@ -170,6 +181,14 @@ func (w *guiWidget) placeGrid(startW int, startH int) (int, int) {
if w.heights[child.node.State.AtH] < childH {
w.heights[child.node.State.AtH] = childH
}
if dense {
if w.heights[child.node.State.AtH] > 0 {
w.heights[child.node.State.AtH] = 1
} else {
w.heights[child.node.State.AtH] = 0
}
}
// child.showWidgetPlacement("grid: ")
log.Log(INFO, "placeGrid:", child.String(), "child()", childW, childH, "At()", child.node.State.AtW, child.node.State.AtH)
}
@ -256,6 +275,7 @@ func (w *guiWidget) realGocuiSize() *rectType {
return newR
}
/*
func textSize(n *tree.Node) (int, int) {
var tk *guiWidget
tk = n.TK.(*guiWidget)
@ -269,12 +289,21 @@ func textSize(n *tree.Node) (int, int) {
}
return width, height
}
*/
func (tk *guiWidget) gocuiSetWH(sizeW, sizeH int) {
w := len(widget.GetString(tk.value))
lines := strings.Split(widget.GetString(tk.value), "\n")
h := len(lines)
if tk.Hidden() {
tk.gocuiSize.w0 = 0
tk.gocuiSize.h0 = 0
tk.gocuiSize.w1 = 0
tk.gocuiSize.h1 = 0
return
}
// tk := n.tk
if tk.isFake {
tk.gocuiSize.w0 = sizeW
@ -298,11 +327,8 @@ func (tk *guiWidget) gocuiSetWH(sizeW, sizeH int) {
}
func (tk *guiWidget) setStdoutWH(sizeW, sizeH int) {
w := 120
h := 40
tk.gocuiSize.w0 = sizeW
tk.gocuiSize.h0 = sizeH
tk.gocuiSize.w1 = tk.gocuiSize.w0 + w
tk.gocuiSize.h1 = tk.gocuiSize.h0 + h
tk.gocuiSize.w1 = tk.gocuiSize.w0 + me.stdout.w
tk.gocuiSize.h1 = tk.gocuiSize.h0 + me.stdout.h
}

View File

@ -131,6 +131,7 @@ type window struct {
order int // what level the window is on
resize bool // only set the title once
collapsed bool // only show the window title bar
dense bool // true if the window is huge
}
type guiWidget struct {

View File

@ -15,6 +15,9 @@ func (tk *guiWidget) redrawWindow(w int, h int) {
if tk.node.WidgetType != widget.Window {
return
}
if tk.full.Height() > 40 {
tk.window.dense = true
}
// pin the window to (w,h)
tk.gocuiSize.w0 = w
tk.gocuiSize.h0 = h