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"
|
"strings"
|
||||||
|
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
"go.wit.com/toolkits/tree"
|
|
||||||
"go.wit.com/widget"
|
"go.wit.com/widget"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -150,12 +149,24 @@ func (tk *guiWidget) placeWidgets(startW int, startH int) (int, int) {
|
||||||
return 0, 0
|
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) {
|
func (w *guiWidget) placeGrid(startW int, startH int) (int, int) {
|
||||||
// w.showWidgetPlacement("grid0:")
|
// w.showWidgetPlacement("grid0:")
|
||||||
if w.node.WidgetType != widget.Grid {
|
if w.node.WidgetType != widget.Grid {
|
||||||
return 0, 0
|
return 0, 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dense := w.isWindowDense()
|
||||||
|
|
||||||
w.full.w0 = startW
|
w.full.w0 = startW
|
||||||
w.full.h0 = startH
|
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 {
|
if w.heights[child.node.State.AtH] < childH {
|
||||||
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: ")
|
// child.showWidgetPlacement("grid: ")
|
||||||
log.Log(INFO, "placeGrid:", child.String(), "child()", childW, childH, "At()", child.node.State.AtW, child.node.State.AtH)
|
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
|
return newR
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
func textSize(n *tree.Node) (int, int) {
|
func textSize(n *tree.Node) (int, int) {
|
||||||
var tk *guiWidget
|
var tk *guiWidget
|
||||||
tk = n.TK.(*guiWidget)
|
tk = n.TK.(*guiWidget)
|
||||||
|
@ -269,12 +289,21 @@ func textSize(n *tree.Node) (int, int) {
|
||||||
}
|
}
|
||||||
return width, height
|
return width, height
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
func (tk *guiWidget) gocuiSetWH(sizeW, sizeH int) {
|
func (tk *guiWidget) gocuiSetWH(sizeW, sizeH int) {
|
||||||
w := len(widget.GetString(tk.value))
|
w := len(widget.GetString(tk.value))
|
||||||
lines := strings.Split(widget.GetString(tk.value), "\n")
|
lines := strings.Split(widget.GetString(tk.value), "\n")
|
||||||
h := len(lines)
|
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
|
// tk := n.tk
|
||||||
if tk.isFake {
|
if tk.isFake {
|
||||||
tk.gocuiSize.w0 = sizeW
|
tk.gocuiSize.w0 = sizeW
|
||||||
|
@ -298,11 +327,8 @@ func (tk *guiWidget) gocuiSetWH(sizeW, sizeH int) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (tk *guiWidget) setStdoutWH(sizeW, sizeH int) {
|
func (tk *guiWidget) setStdoutWH(sizeW, sizeH int) {
|
||||||
w := 120
|
|
||||||
h := 40
|
|
||||||
|
|
||||||
tk.gocuiSize.w0 = sizeW
|
tk.gocuiSize.w0 = sizeW
|
||||||
tk.gocuiSize.h0 = sizeH
|
tk.gocuiSize.h0 = sizeH
|
||||||
tk.gocuiSize.w1 = tk.gocuiSize.w0 + w
|
tk.gocuiSize.w1 = tk.gocuiSize.w0 + me.stdout.w
|
||||||
tk.gocuiSize.h1 = tk.gocuiSize.h0 + h
|
tk.gocuiSize.h1 = tk.gocuiSize.h0 + me.stdout.h
|
||||||
}
|
}
|
||||||
|
|
|
@ -131,6 +131,7 @@ type window struct {
|
||||||
order int // what level the window is on
|
order int // what level the window is on
|
||||||
resize bool // only set the title once
|
resize bool // only set the title once
|
||||||
collapsed bool // only show the window title bar
|
collapsed bool // only show the window title bar
|
||||||
|
dense bool // true if the window is huge
|
||||||
}
|
}
|
||||||
|
|
||||||
type guiWidget struct {
|
type guiWidget struct {
|
||||||
|
|
|
@ -15,6 +15,9 @@ func (tk *guiWidget) redrawWindow(w int, h int) {
|
||||||
if tk.node.WidgetType != widget.Window {
|
if tk.node.WidgetType != widget.Window {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if tk.full.Height() > 40 {
|
||||||
|
tk.window.dense = true
|
||||||
|
}
|
||||||
// pin the window to (w,h)
|
// pin the window to (w,h)
|
||||||
tk.gocuiSize.w0 = w
|
tk.gocuiSize.w0 = w
|
||||||
tk.gocuiSize.h0 = h
|
tk.gocuiSize.h0 = h
|
||||||
|
|
Loading…
Reference in New Issue