clip large windows
This commit is contained in:
parent
4a009f79a2
commit
c5d9522c0b
|
@ -71,6 +71,19 @@ func theSuperMouse(g *gocui.Gui, v *gocui.View) error {
|
|||
// use this to test code ideas // put whatever you want here and hit '2' to activate it
|
||||
func theNotsure(g *gocui.Gui, v *gocui.View) error {
|
||||
log.Info("got to theNotsure(). now what? dark =", me.dark)
|
||||
if me.debug {
|
||||
log.Info("debugging off")
|
||||
me.debug = false
|
||||
} else {
|
||||
log.Info("debugging on")
|
||||
me.debug = true
|
||||
}
|
||||
win := findWindowUnderMouse()
|
||||
if win != nil {
|
||||
win.dumpWidget("found() win. redrawing window:")
|
||||
win.redrawWindow(win.gocuiSize.w0, win.gocuiSize.h0)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
23
plugin.go
23
plugin.go
|
@ -99,12 +99,19 @@ func newaction(n *tree.Node, atype widget.ActionType) {
|
|||
w := n.TK.(*guiWidget)
|
||||
switch atype {
|
||||
case widget.Show:
|
||||
if me.debug {
|
||||
w.dumpWidget("Show()")
|
||||
}
|
||||
w.node.State.Hidden = false
|
||||
w.Show()
|
||||
case widget.Hide:
|
||||
if me.debug {
|
||||
w.dumpWidget("Hide()")
|
||||
}
|
||||
if n.Hidden() {
|
||||
// already hidden
|
||||
} else {
|
||||
log.Log(NOW, "attempt to hide() =", atype, n.WidgetId, n.WidgetType, n.ProgName())
|
||||
// log.Log(NOW, "attempt to hide() =", atype, n.WidgetId, n.WidgetType, n.ProgName())
|
||||
w.node.State.Hidden = true
|
||||
w.Hide()
|
||||
}
|
||||
|
@ -219,13 +226,16 @@ func (tk *guiWidget) Disable() {
|
|||
}
|
||||
tk.enable = false
|
||||
tk.node.State.Enable = false
|
||||
log.Info("disable widget in gocui", tk.node.WidgetType, tk.node.ProgName())
|
||||
// log.Info("disable widget in gocui", tk.node.WidgetType, tk.node.ProgName())
|
||||
switch tk.node.WidgetType {
|
||||
case widget.Box:
|
||||
log.Info("todo: blank out the window here")
|
||||
return
|
||||
case widget.Button:
|
||||
tk.setColorDisable()
|
||||
return
|
||||
default:
|
||||
log.Log(INFO, "don't know how to disable", tk.node.WidgetId, "w.name", tk.String())
|
||||
tk.dumpWidget("fixme: disable")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -236,12 +246,15 @@ func (tk *guiWidget) Enable() {
|
|||
}
|
||||
tk.enable = true
|
||||
tk.node.State.Enable = true
|
||||
log.Info("disable widget in gocui", tk.node.WidgetType, tk.node.ProgName())
|
||||
// log.Info("enable widget in gocui", tk.node.WidgetType, tk.node.ProgName())
|
||||
switch tk.node.WidgetType {
|
||||
case widget.Box:
|
||||
// log.Info("todo: blank out the window here")
|
||||
return
|
||||
case widget.Button:
|
||||
tk.restoreEnableColor()
|
||||
return
|
||||
default:
|
||||
log.Log(INFO, "don't know how to disable", tk.node.WidgetId, "w.name", tk.String())
|
||||
tk.dumpWidget("fixme: enable")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -74,6 +74,7 @@ type config struct {
|
|||
dark bool // use a 'dark' color palette
|
||||
mouse mouse // mouse settings
|
||||
showDebug bool // todo: move this into config struct
|
||||
debug bool // todo: move this into config struct
|
||||
outf *os.File // hacks for capturing stdout
|
||||
|
||||
}
|
||||
|
|
42
treeDraw.go
42
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()
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue