diff options
| author | Jeff Carr <[email protected]> | 2025-02-09 08:28:10 -0600 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-02-09 08:28:10 -0600 |
| commit | c5d9522c0b1d176ecea10b9347c65dc6d99e898e (patch) | |
| tree | fd6067d839e2a0f09ac106bc22f656266b2674ad /treeDraw.go | |
| parent | 4a009f79a23b9ce1ac9198fee2fb36a12c13ac60 (diff) | |
clip large windows
Diffstat (limited to 'treeDraw.go')
| -rw-r--r-- | treeDraw.go | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/treeDraw.go b/treeDraw.go index 802e498..e9f9d20 100644 --- a/treeDraw.go +++ b/treeDraw.go @@ -13,6 +13,34 @@ import ( "go.wit.com/widget" ) +// don't draw widgets that are too far down the window +func (tk *guiWidget) doNotDraw() bool { + var check bool + switch tk.node.WidgetType { + case widget.Button: + check = true + case widget.Label: + check = true + default: + } + if !check { + return false + } + win := tk.findParentWindow() + if win == nil { + // don't draw anything if you can't find the parent window + return true + } + + h := tk.gocuiSize.h0 - win.gocuiSize.h0 + + if h > 20 { + return true + } + + return false +} + // display's the text of the widget in gocui // deletes the old view if it exists and recreates it func (tk *guiWidget) drawView() { @@ -33,11 +61,22 @@ func (tk *guiWidget) drawView() { me.baseGui.DeleteView(tk.cuiName) tk.v = nil + if tk.doNotDraw() { + return + } + a := tk.gocuiSize.w0 b := tk.gocuiSize.h0 c := tk.gocuiSize.w1 d := tk.gocuiSize.h1 + if tk.node.WidgetType == widget.Window || tk.node.WidgetType == widget.Flag { + if tk.gocuiSize.Height() > 30 { + tk.gocuiSize.h1 = tk.gocuiSize.h0 + 30 + d = tk.gocuiSize.h1 + } + } + // this is all terrible. This sets the title. kinda if tk.node.WidgetType == widget.Window { tk.textResize() @@ -139,6 +178,9 @@ func (w *guiWidget) Show() { // never show hidden widgets return } + if me.debug { + w.dumpWidget("drawView()") + } w.drawView() } |
