finally. dense window view
This commit is contained in:
parent
e39bcafb78
commit
5d1a3b2578
38
place.go
38
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
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue