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