summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-02-06 20:34:29 -0600
committerJeff Carr <[email protected]>2025-02-06 20:34:29 -0600
commit5d1a3b2578580bd2d41e47d3ab3e6f48411c8613 (patch)
tree2070fbb66ed44f04c41e7ddc09617009df347274
parente39bcafb78d8388ee5bc77366efbab4f3717466c (diff)
finally. dense window view
-rw-r--r--place.go38
-rw-r--r--structs.go1
-rw-r--r--window.go3
3 files changed, 36 insertions, 6 deletions
diff --git a/place.go b/place.go
index 8d15308..20d7759 100644
--- a/place.go
+++ b/place.go
@@ -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
}
diff --git a/structs.go b/structs.go
index 310f4cf..186d228 100644
--- a/structs.go
+++ b/structs.go
@@ -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 {
diff --git a/window.go b/window.go
index 7d612e4..57950a1 100644
--- a/window.go
+++ b/window.go
@@ -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