getting closer on windows
This commit is contained in:
parent
d2c681f573
commit
5a28806bdf
2
color.go
2
color.go
|
@ -55,7 +55,7 @@ var colorWindow colorT = colorT{
|
|||
selBg: powdererBlue,
|
||||
name: "normal window",
|
||||
}
|
||||
var colorActiveW colorT = colorT{none, none, powdererBlue, none, powdererBlue, "active window"}
|
||||
var colorActiveW colorT = colorT{none, none, powdererBlue, none, powdererBlue, "active window"} // sets the window to blue
|
||||
|
||||
var colorTab colorT = colorT{gocui.ColorBlue, gocui.ColorBlue, none, none, powdererBlue, "normal tab"}
|
||||
var colorActiveT colorT = colorT{gocui.ColorBlue, none, powdererBlue, none, powdererBlue, "active tab"}
|
||||
|
|
2
debug.go
2
debug.go
|
@ -38,11 +38,11 @@ func (tk *guiWidget) dumpWidget(s string) {
|
|||
sizeW, sizeH := tk.Size()
|
||||
s1 += fmt.Sprintf("size=(%3d,%3d)", sizeW, sizeH)
|
||||
if tk.Visible() {
|
||||
r := tk.setFullSize()
|
||||
s1 += fmt.Sprintf("gocui=(%3d,%3d,%3d,%3d)",
|
||||
tk.gocuiSize.w0, tk.gocuiSize.h0, tk.gocuiSize.w1, tk.gocuiSize.h1)
|
||||
// vx0, vy0, vx1, vy1, _ := me.baseGui.ViewPosition("msg")
|
||||
// vw0, vh0, vw1, vh1, _ := me.baseGui.ViewPosition(tk.v.Name())
|
||||
r := tk.getFullSize()
|
||||
s1 += fmt.Sprintf(" full=(%3d,%3d,%3d,%3d)", r.w0, r.h0, r.w1, r.h1)
|
||||
} else {
|
||||
s1 += fmt.Sprintf(" %3s %3s %3s %3s ", "", "", "", "")
|
||||
|
|
|
@ -18,7 +18,7 @@ func (tk *guiWidget) doWidgetClick(w int, h int) {
|
|||
// if there is a current window, hide it
|
||||
if me.currentWindow != nil {
|
||||
me.currentWindow.setColor(&colorWindow)
|
||||
me.currentWindow.hideWidgets()
|
||||
// me.currentWindow.hideWidgets()
|
||||
me.currentWindow.isCurrent = false
|
||||
}
|
||||
|
||||
|
@ -27,17 +27,18 @@ func (tk *guiWidget) doWidgetClick(w int, h int) {
|
|||
me.currentWindow.isCurrent = true
|
||||
tk.active = false
|
||||
|
||||
// might make the green box the right size
|
||||
tk.setFullSize()
|
||||
|
||||
// draw the current window
|
||||
w := tk.gocuiSize.w0 + 4
|
||||
h := tk.gocuiSize.h0 + 4
|
||||
tk.DrawAt(w, h)
|
||||
tk.setColor(&colorActiveW)
|
||||
tk.setColor(&colorActiveW) // sets the window to Green BG
|
||||
tk.showWidgets()
|
||||
tk.placeWidgets(w, h) // compute the sizes & places for each widget
|
||||
|
||||
full := tk.getFullSize()
|
||||
tk.gocuiSize.w1 = full.w1
|
||||
tk.gocuiSize.h1 = full.h1
|
||||
tk.setFullSize()
|
||||
me.baseGui.SetView(tk.cuiName, tk.gocuiSize.w0, tk.gocuiSize.h0, tk.gocuiSize.w1, tk.gocuiSize.h1, 0)
|
||||
case widget.Group:
|
||||
if tk.active {
|
||||
|
|
39
find.go
39
find.go
|
@ -5,6 +5,7 @@ package main
|
|||
|
||||
import (
|
||||
"github.com/awesome-gocui/gocui"
|
||||
log "go.wit.com/log"
|
||||
"go.wit.com/widget"
|
||||
)
|
||||
|
||||
|
@ -57,6 +58,44 @@ func (tk *guiWidget) findByXYreal(w int, h int) []*guiWidget {
|
|||
return widgets
|
||||
}
|
||||
|
||||
func (tk *guiWidget) setFullSize() rectType {
|
||||
r := tk.getFullSize()
|
||||
|
||||
/*
|
||||
r.w0 = tk.gocuiSize.w0
|
||||
r.w1 = tk.gocuiSize.w1
|
||||
r.h0 = tk.gocuiSize.h0
|
||||
r.h1 = tk.gocuiSize.h1
|
||||
*/
|
||||
var changed bool
|
||||
if tk.gocuiSize.w0 != r.w0 {
|
||||
tk.gocuiSize.w0 = r.w0
|
||||
changed = true
|
||||
}
|
||||
if tk.gocuiSize.w1 != r.w1 {
|
||||
tk.gocuiSize.w1 = r.w1
|
||||
changed = true
|
||||
}
|
||||
if tk.gocuiSize.h0 != r.h0 {
|
||||
tk.gocuiSize.h0 = r.h0
|
||||
changed = true
|
||||
}
|
||||
if tk.gocuiSize.h1 != r.h1 {
|
||||
tk.gocuiSize.h1 = r.h1
|
||||
changed = true
|
||||
}
|
||||
if changed {
|
||||
if tk.node.WidgetType == widget.Window {
|
||||
log.Info("REDRAW WINDOW IN setFullSize()")
|
||||
tk.gocuiSize.w1 = r.w1 + 2
|
||||
tk.gocuiSize.h1 = r.h1 + 1
|
||||
tk.Hide()
|
||||
tk.drawView()
|
||||
}
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
// this checks a widget to see if it is under (W,H), then checks the widget's children
|
||||
// anything that matches is passed back as an array of widgets
|
||||
func (tk *guiWidget) getFullSize() rectType {
|
||||
|
|
|
@ -120,6 +120,7 @@ type guiWidget struct {
|
|||
frame bool // ?
|
||||
selectedTab *tree.Node // for a window, this is currently selected tab
|
||||
color *colorT // what color to use
|
||||
resize bool
|
||||
}
|
||||
|
||||
// from the gocui devs:
|
||||
|
|
140
treeDraw.go
140
treeDraw.go
|
@ -10,9 +10,80 @@ import (
|
|||
|
||||
"github.com/awesome-gocui/gocui"
|
||||
log "go.wit.com/log"
|
||||
"go.wit.com/widget"
|
||||
)
|
||||
|
||||
var toggle bool = true
|
||||
// display's the text of the widget in gocui
|
||||
// deletes the old view if it exists and recreates it
|
||||
func (tk *guiWidget) drawView() {
|
||||
var err error
|
||||
log.Log(INFO, "drawView() START", tk.node.WidgetType, tk.String())
|
||||
if me.baseGui == nil {
|
||||
log.Log(ERROR, "drawView() ERROR: me.baseGui == nil", tk)
|
||||
return
|
||||
}
|
||||
|
||||
if tk.cuiName == "" {
|
||||
log.Log(ERROR, "drawView() tk.cuiName was not set for widget", tk)
|
||||
tk.cuiName = strconv.Itoa(tk.node.WidgetId) + " TK"
|
||||
}
|
||||
log.Log(INFO, "drawView() labelN =", tk.labelN)
|
||||
|
||||
// this deletes the button from gocui
|
||||
me.baseGui.DeleteView(tk.cuiName)
|
||||
tk.v = nil
|
||||
|
||||
if tk.node.WidgetType == widget.Window {
|
||||
if !tk.resize {
|
||||
tk.resize = true
|
||||
tk.textResize() // resize window only once
|
||||
}
|
||||
} else {
|
||||
tk.textResize() // resize everything except windows
|
||||
}
|
||||
a := tk.gocuiSize.w0
|
||||
b := tk.gocuiSize.h0
|
||||
c := tk.gocuiSize.w1
|
||||
d := tk.gocuiSize.h1
|
||||
|
||||
tk.v, err = me.baseGui.SetView(tk.cuiName, a, b, c, d, 0)
|
||||
if err == nil {
|
||||
tk.dumpWidget("drawView() err")
|
||||
log.Log(ERROR, "drawView() internal plugin error err = nil")
|
||||
return
|
||||
}
|
||||
if !errors.Is(err, gocui.ErrUnknownView) {
|
||||
tk.dumpWidget("drawView() err")
|
||||
log.Log(ERROR, "drawView() internal plugin error error.IS()", err)
|
||||
return
|
||||
}
|
||||
|
||||
// this sets up the keybinding for the name of the window
|
||||
// does this really need to be done? I think we probably already
|
||||
// know everything about where all the widgets are so we could bypass
|
||||
// the gocui package and just handle all the mouse events internally here (?)
|
||||
// for now, the w.v.Name is a string "1", "2", "3", etc from the widgetId
|
||||
|
||||
// set the binding for this gocui view now that it has been created
|
||||
// gocui handles overlaps of views so it will run on the view that is clicked on
|
||||
// me.baseGui.SetKeybinding(w.v.Name(), gocui.MouseLeft, gocui.ModNone, click)
|
||||
|
||||
// this actually sends the text to display to gocui
|
||||
tk.v.Wrap = true
|
||||
tk.v.Frame = tk.frame
|
||||
tk.v.Clear()
|
||||
fmt.Fprint(tk.v, tk.labelN)
|
||||
|
||||
// if you don't do this here, it will be black & white only
|
||||
if tk.color != nil {
|
||||
tk.v.FrameColor = tk.color.frame
|
||||
tk.v.FgColor = tk.color.fg
|
||||
tk.v.BgColor = tk.color.bg
|
||||
tk.v.SelFgColor = tk.color.selFg
|
||||
tk.v.SelBgColor = tk.color.selBg
|
||||
}
|
||||
log.Log(INFO, "drawView() END")
|
||||
}
|
||||
|
||||
func (w *guiWidget) DrawAt(offsetW, offsetH int) {
|
||||
w.setColor(&colorActiveW)
|
||||
|
@ -27,6 +98,8 @@ func (w *guiWidget) simpleDrawAt(offsetW, offsetH int) {
|
|||
w.dumpWidget("simpleDrawAt()")
|
||||
}
|
||||
|
||||
var toggle bool = true
|
||||
|
||||
func (w *guiWidget) toggleTree() {
|
||||
if toggle {
|
||||
w.drawTree(toggle)
|
||||
|
@ -54,68 +127,3 @@ func (w *guiWidget) drawTree(draw bool) {
|
|||
child.drawTree(draw)
|
||||
}
|
||||
}
|
||||
|
||||
// display's the text of the widget in gocui
|
||||
// deletes the old view if it exists and recreates it
|
||||
func (w *guiWidget) drawView() {
|
||||
var err error
|
||||
log.Log(INFO, "drawView() START", w.node.WidgetType, w.String())
|
||||
if me.baseGui == nil {
|
||||
log.Log(ERROR, "drawView() ERROR: me.baseGui == nil", w)
|
||||
return
|
||||
}
|
||||
|
||||
if w.cuiName == "" {
|
||||
log.Log(ERROR, "drawView() w.cuiName was not set for widget", w)
|
||||
w.cuiName = strconv.Itoa(w.node.WidgetId) + " TK"
|
||||
}
|
||||
log.Log(INFO, "drawView() labelN =", w.labelN)
|
||||
|
||||
// this deletes the button from gocui
|
||||
me.baseGui.DeleteView(w.cuiName)
|
||||
w.v = nil
|
||||
|
||||
w.textResize()
|
||||
a := w.gocuiSize.w0
|
||||
b := w.gocuiSize.h0
|
||||
c := w.gocuiSize.w1
|
||||
d := w.gocuiSize.h1
|
||||
|
||||
w.v, err = me.baseGui.SetView(w.cuiName, a, b, c, d, 0)
|
||||
if err == nil {
|
||||
w.dumpWidget("drawView() err")
|
||||
log.Log(ERROR, "drawView() internal plugin error err = nil")
|
||||
return
|
||||
}
|
||||
if !errors.Is(err, gocui.ErrUnknownView) {
|
||||
w.dumpWidget("drawView() err")
|
||||
log.Log(ERROR, "drawView() internal plugin error error.IS()", err)
|
||||
return
|
||||
}
|
||||
|
||||
// this sets up the keybinding for the name of the window
|
||||
// does this really need to be done? I think we probably already
|
||||
// know everything about where all the widgets are so we could bypass
|
||||
// the gocui package and just handle all the mouse events internally here (?)
|
||||
// for now, the w.v.Name is a string "1", "2", "3", etc from the widgetId
|
||||
|
||||
// set the binding for this gocui view now that it has been created
|
||||
// gocui handles overlaps of views so it will run on the view that is clicked on
|
||||
// me.baseGui.SetKeybinding(w.v.Name(), gocui.MouseLeft, gocui.ModNone, click)
|
||||
|
||||
// this actually sends the text to display to gocui
|
||||
w.v.Wrap = true
|
||||
w.v.Frame = w.frame
|
||||
w.v.Clear()
|
||||
fmt.Fprint(w.v, w.labelN)
|
||||
|
||||
// if you don't do this here, it will be black & white only
|
||||
if w.color != nil {
|
||||
w.v.FrameColor = w.color.frame
|
||||
w.v.FgColor = w.color.fg
|
||||
w.v.BgColor = w.color.bg
|
||||
w.v.SelFgColor = w.color.selFg
|
||||
w.v.SelBgColor = w.color.selBg
|
||||
}
|
||||
log.Log(INFO, "drawView() END")
|
||||
}
|
||||
|
|
|
@ -20,10 +20,11 @@ func (w *guiWidget) redoWindows(nextW int, nextH int) {
|
|||
child.frame = false
|
||||
child.hasTabs = false
|
||||
|
||||
child.gocuiSetWH(nextW, nextH)
|
||||
// this should make the window the full size and re-draw it
|
||||
child.setFullSize() // child.gocuiSetWH(nextW, nextH)
|
||||
child.Hide()
|
||||
|
||||
child.drawView()
|
||||
|
||||
sizeW := child.gocuiSize.Width()
|
||||
nextW += sizeW + 4
|
||||
child.redoWindows(startW+3, startH+2)
|
||||
|
|
Loading…
Reference in New Issue