From c5d9522c0b1d176ecea10b9347c65dc6d99e898e Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sun, 9 Feb 2025 08:28:10 -0600 Subject: clip large windows --- treeDraw.go | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'treeDraw.go') 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() } -- cgit v1.2.3