define a background widget more properly
This commit is contained in:
parent
9ef16c1bf2
commit
75014f4b28
|
@ -7,7 +7,6 @@ import (
|
|||
"errors"
|
||||
|
||||
"github.com/awesome-gocui/gocui"
|
||||
|
||||
"go.wit.com/log"
|
||||
)
|
||||
|
||||
|
|
19
find.go
19
find.go
|
@ -94,25 +94,6 @@ func (tk *guiWidget) findWindows() []*guiWidget {
|
|||
return found
|
||||
}
|
||||
|
||||
// find the BG widget.
|
||||
// This widget is always in the background and covers the whole screen.
|
||||
// gocui seems to not return mouse events unless there is something there
|
||||
func (tk *guiWidget) findBG() *guiWidget {
|
||||
if tk.WidgetType() == widget.Stdout {
|
||||
if tk.WidgetId() != me.stdout.wId {
|
||||
tk.isBG = true
|
||||
return tk
|
||||
}
|
||||
}
|
||||
|
||||
for _, child := range tk.children {
|
||||
if found := child.findBG(); found != nil {
|
||||
return found
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// used by gocui.TabKey to rotate through the windows
|
||||
func findNextWindow() *guiWidget {
|
||||
var found bool
|
||||
|
|
23
init.go
23
init.go
|
@ -26,6 +26,9 @@ var BUILDTIME string
|
|||
|
||||
var PLUGIN string = "gocui"
|
||||
|
||||
// this is called at the very initial connection
|
||||
// between the app and this gocui plugin
|
||||
// this is a good place to initialize gocui's default behavior
|
||||
func toolkitInit() {
|
||||
log.Info("gocui toolkitInit() me.ok =", me.ok)
|
||||
if me.baseGui == nil {
|
||||
|
@ -62,14 +65,19 @@ func toolkitInit() {
|
|||
setThingsOnTop()
|
||||
// SETUP STDOUT END
|
||||
|
||||
// SETUP BG
|
||||
if me.BG.tk == nil {
|
||||
me.BG.tk = makeNewInternalWidget(me.BG.wId)
|
||||
}
|
||||
|
||||
// PUT INIT DEBUG COOE HERE
|
||||
var toggle bool
|
||||
for i := 0; i < 3; i++ {
|
||||
for i := 0; i < 6; i++ {
|
||||
w := me.treeRoot.TK.(*guiWidget)
|
||||
w.dumpTree("MM")
|
||||
w.dumpWindows("WW")
|
||||
|
||||
time.Sleep(500 * time.Millisecond)
|
||||
time.Sleep(1000 * time.Millisecond)
|
||||
if toggle {
|
||||
toggle = false
|
||||
log.Info("gocui toolkitInit() put testing true stuff here")
|
||||
|
@ -77,6 +85,7 @@ func toolkitInit() {
|
|||
toggle = true
|
||||
log.Info("gocui toolkitInit() put testing false stuff here")
|
||||
}
|
||||
setBottomBG()
|
||||
}
|
||||
// PUT INIT DEBUG COOE HERE END
|
||||
|
||||
|
@ -145,15 +154,15 @@ func initPlugin() {
|
|||
log.Info("error opening file:", err)
|
||||
os.Exit(0)
|
||||
}
|
||||
// todo: some early output still goes to the /tmp/ file
|
||||
//time.Sleep(200 * time.Millisecond)
|
||||
log.CaptureMode(me.stdout)
|
||||
}
|
||||
me.starttime = time.Now()
|
||||
log.Log(INFO, "Init() of awesome-gocui")
|
||||
|
||||
// init the config struct default values
|
||||
Set(&me, "default")
|
||||
// todo: some early output still goes to the /tmp/ file
|
||||
//time.Sleep(200 * time.Millisecond)
|
||||
log.CaptureMode(me.stdout)
|
||||
|
||||
// initial app window settings
|
||||
|
||||
|
@ -167,6 +176,7 @@ func initPlugin() {
|
|||
me.dropdown.wId = -77
|
||||
me.textbox.wId = -55
|
||||
me.stdout.wId = -4
|
||||
me.BG.wId = -22
|
||||
|
||||
// the clock widget id and offset
|
||||
me.notify.clock.wId = -5
|
||||
|
@ -189,8 +199,9 @@ func initPlugin() {
|
|||
|
||||
log.Log(NOW, "Init() start pluginChan")
|
||||
if me.stdout.disable {
|
||||
log.Info("USING STDOUT")
|
||||
log.Info("Using STDOUT")
|
||||
} else {
|
||||
log.Info("Using gocui STDOUT")
|
||||
os.Stdout = me.outf
|
||||
log.CaptureMode(me.outf)
|
||||
}
|
||||
|
|
44
libnotify.go
44
libnotify.go
|
@ -144,19 +144,37 @@ func setThingsOnTop() {
|
|||
setBottomBG()
|
||||
}
|
||||
|
||||
// find the "BG" widget and set it to the background on the very very bottom
|
||||
func setBottomBG() {
|
||||
// this attempts to find the "BG" widget and set it to the background on the very very bottom
|
||||
rootTK := me.treeRoot.TK.(*guiWidget)
|
||||
if tk := rootTK.findBG(); tk != nil {
|
||||
// log.Info("found BG. setting to bottom", tk.cuiName)
|
||||
if me.dark {
|
||||
tk.v.BgColor = gocui.ColorBlack
|
||||
} else {
|
||||
tk.v.BgColor = gocui.ColorWhite
|
||||
}
|
||||
tk.v.Clear()
|
||||
me.baseGui.SetViewOnBottom(tk.cuiName)
|
||||
w, h := me.baseGui.Size()
|
||||
me.baseGui.SetView(tk.cuiName, -1, -1, w+1, h+1, 0)
|
||||
if me.BG.tk == nil {
|
||||
log.Info("background tk widget not initialized")
|
||||
return
|
||||
}
|
||||
tk := me.BG.tk
|
||||
log.Info("found BG. setting to bottom", tk.cuiName)
|
||||
if tk.v == nil {
|
||||
w, h := me.baseGui.Size()
|
||||
a := -1
|
||||
b := -1
|
||||
c := w + 1
|
||||
d := h + 1
|
||||
var err error
|
||||
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
|
||||
}
|
||||
log.Info("background tk View not initialized")
|
||||
return
|
||||
}
|
||||
if me.dark {
|
||||
tk.v.BgColor = gocui.ColorBlack
|
||||
} else {
|
||||
tk.v.BgColor = gocui.ColorWhite
|
||||
}
|
||||
tk.v.Clear()
|
||||
me.baseGui.SetViewOnBottom(tk.cuiName)
|
||||
w, h := me.baseGui.Size()
|
||||
me.baseGui.SetView(tk.cuiName, -1, -1, w+1, h+1, 0)
|
||||
}
|
||||
|
|
|
@ -115,8 +115,10 @@ func relocateStdoutOffscreen() {
|
|||
if me.stdout.tk == nil {
|
||||
return
|
||||
}
|
||||
log.CaptureMode(me.stdout.tk)
|
||||
// log.Log(ERROR, "setting log.CaptureMode(tk.v) in relocateStdoutOffscreen()")
|
||||
if !me.stdout.disable {
|
||||
log.Info("Using gocui STDOUT")
|
||||
log.CaptureMode(me.stdout.tk)
|
||||
}
|
||||
newW := 10
|
||||
newH := 0 - me.stdout.h - 4
|
||||
me.stdout.tk.relocateStdout(newW, newH)
|
||||
|
|
|
@ -77,6 +77,7 @@ type config struct {
|
|||
stdout stdout // information for the STDOUT window
|
||||
dropdown dropdown // the dropdown menu
|
||||
textbox dropdown // the textbox popup window
|
||||
BG dropdown // the background widget
|
||||
notify libnotify // emulates the desktop libnotify menu
|
||||
allwin []*guiWidget // for tracking which window is next
|
||||
dark bool // use a 'dark' color palette
|
||||
|
@ -187,7 +188,6 @@ type window struct {
|
|||
currentTab bool // the visible tab
|
||||
selectedTab *tree.Node // for a window, this is currently selected tab
|
||||
active bool // means this window is the active one
|
||||
isBG bool // means this is the background widget. There is only one of these
|
||||
order int // what level the window is on
|
||||
// resize bool // only set the title once
|
||||
collapsed bool // only show the window title bar
|
||||
|
@ -239,7 +239,6 @@ type guiWidget struct {
|
|||
color *colorT // what color to use
|
||||
colorLast colorT // the last color the widget had
|
||||
defaultColor *colorT // the default colors // TODO: make a function for this instead
|
||||
isBG bool // means this is the background widget. There is only one of these
|
||||
}
|
||||
|
||||
// THIS IS GO COMPILER MAGIC
|
||||
|
|
Loading…
Reference in New Issue