start moving to standard internal TK functions
This commit is contained in:
parent
f24c509859
commit
0638183356
88
help.go
88
help.go
|
@ -15,6 +15,8 @@ import (
|
|||
|
||||
"github.com/awesome-gocui/gocui"
|
||||
log "go.wit.com/log"
|
||||
"go.wit.com/toolkits/tree"
|
||||
"go.wit.com/widget"
|
||||
)
|
||||
|
||||
/*
|
||||
|
@ -86,16 +88,20 @@ func showHelp() error {
|
|||
}
|
||||
g.SetViewOnTop("help")
|
||||
me.helpLabel = help
|
||||
if me.clock.tk == nil {
|
||||
makeClock()
|
||||
me.clock.tk.MoveToOffset(maxX-10, 1)
|
||||
me.clock.tk.Hide()
|
||||
me.clock.tk.Show()
|
||||
if me.treeRoot == nil {
|
||||
log.Info("gogui makeClock() error. treeRoot == nil")
|
||||
return nil
|
||||
} else {
|
||||
if me.notify.clock.tk == nil {
|
||||
makeClock(me.notify.clock.wId)
|
||||
me.notify.clock.tk.MoveToOffset(maxX-10, 1)
|
||||
me.notify.clock.tk.Hide()
|
||||
me.notify.clock.tk.Show()
|
||||
}
|
||||
if me.clock.tk != nil {
|
||||
me.clock.tk.MoveToOffset(maxX-10, 1)
|
||||
me.clock.tk.Hide()
|
||||
me.clock.tk.Show()
|
||||
if me.notify.clock.tk != nil {
|
||||
me.notify.clock.tk.MoveToOffset(maxX-10, 1)
|
||||
me.notify.clock.tk.Hide()
|
||||
me.notify.clock.tk.Show()
|
||||
}
|
||||
if me.stdout.tk == nil {
|
||||
makeOutputWidget(me.baseGui, "made this in showHelp()")
|
||||
|
@ -103,20 +109,60 @@ func showHelp() error {
|
|||
me.stdout.Write([]byte(msg))
|
||||
log.Log(NOW, "log.log(NOW) test")
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func makeClock() {
|
||||
me.clock.tk = makeNewFlagWidget(me.clock.wId)
|
||||
me.clock.tk.dumpWidget("init() clock")
|
||||
// create a new widget in the binary tree
|
||||
func makeNewInternalWidget(wId int) *guiWidget {
|
||||
if me.treeRoot == nil {
|
||||
log.Info("GOGUI Init ERROR. treeRoot == nil")
|
||||
return nil
|
||||
}
|
||||
n := new(tree.Node)
|
||||
n.WidgetType = widget.Flag
|
||||
n.WidgetId = wId
|
||||
n.ParentId = 0
|
||||
|
||||
// store the internal toolkit information
|
||||
tk := new(guiWidget)
|
||||
tk.frame = true
|
||||
|
||||
tk.node = n
|
||||
tk.node.Parent = me.treeRoot
|
||||
|
||||
// set the name used by gocui to the id
|
||||
tk.cuiName = fmt.Sprintf("%d DR", wId)
|
||||
|
||||
tk.setColorInput()
|
||||
|
||||
// add this new widget on the binary tree
|
||||
tk.parent = me.treeRoot.TK.(*guiWidget)
|
||||
if tk.parent == nil {
|
||||
panic("makeNewFlagWidget() didn't get treeRoot guiWidget")
|
||||
} else {
|
||||
tk.parent.children = append(tk.parent.children, tk)
|
||||
}
|
||||
|
||||
n.TK = tk
|
||||
return tk
|
||||
}
|
||||
|
||||
func makeClock(wId int) {
|
||||
if me.treeRoot == nil {
|
||||
log.Info("gogui makeClock() error. treeRoot == nil")
|
||||
return
|
||||
}
|
||||
me.notify.clock.tk = makeNewInternalWidget(wId)
|
||||
me.notify.clock.tk.dumpWidget("init() clock")
|
||||
w, h := me.baseGui.MousePosition()
|
||||
me.clock.tk.MoveToOffset(w, h)
|
||||
me.clock.tk.labelN = time.Now().Format("15:04:05")
|
||||
me.clock.tk.frame = false
|
||||
me.clock.tk.setColorLabel()
|
||||
me.clock.tk.Show()
|
||||
me.clock.active = true
|
||||
me.clock.tk.dumpWidget("showClock()")
|
||||
me.notify.clock.tk.MoveToOffset(w, h)
|
||||
me.notify.clock.tk.labelN = time.Now().Format("15:04:05")
|
||||
me.notify.clock.tk.frame = false
|
||||
me.notify.clock.tk.setColorLabel()
|
||||
me.notify.clock.tk.Show()
|
||||
me.notify.clock.active = true
|
||||
me.notify.clock.tk.dumpWidget("showClock()")
|
||||
}
|
||||
|
||||
// in the very end of redrawing things, this will place the help and stdout on the top or botton
|
||||
|
@ -127,8 +173,8 @@ func setThingsOnTop() {
|
|||
} else {
|
||||
me.baseGui.SetViewOnTop("help")
|
||||
}
|
||||
if me.clock.tk != nil {
|
||||
me.baseGui.SetViewOnTop(me.clock.tk.v.Name())
|
||||
if me.notify.clock.tk != nil {
|
||||
me.baseGui.SetViewOnTop(me.notify.clock.tk.v.Name())
|
||||
}
|
||||
|
||||
if me.stdout.tk == nil {
|
||||
|
|
23
init.go
23
init.go
|
@ -68,7 +68,8 @@ func initPlugin() {
|
|||
me.dropdown.wId = -77
|
||||
me.textbox.wId = -55
|
||||
me.stdout.wId = -4
|
||||
me.clock.wId = -5
|
||||
me.notify.clock.wId = -5
|
||||
me.notify.menu.wId = -5
|
||||
|
||||
Set(&me.dropdown, "default")
|
||||
// s := fmt.Sprintln("fake default check =", me.FakeW, "dropdown.Id", me.dropdown.Id)
|
||||
|
@ -252,24 +253,24 @@ func refreshGocui() {
|
|||
// todo: add logic here to see if the application has changed anything
|
||||
// me.baseGui.UpdateAsync(testRefresh) // probably don't need this
|
||||
me.baseGui.Update(testRefresh)
|
||||
if me.clock.tk != nil && !me.showHelp {
|
||||
if me.notify.clock.tk != nil && !me.showHelp {
|
||||
// also double check the gocui view exists
|
||||
if me.clock.tk.v != nil {
|
||||
me.clock.tk.v.Clear()
|
||||
me.clock.tk.labelN = time.Now().Format("15:04:05")
|
||||
me.clock.tk.v.WriteString(me.clock.tk.labelN)
|
||||
if me.notify.clock.tk.v != nil {
|
||||
me.notify.clock.tk.v.Clear()
|
||||
me.notify.clock.tk.labelN = time.Now().Format("15:04:05")
|
||||
me.notify.clock.tk.v.WriteString(me.notify.clock.tk.labelN)
|
||||
}
|
||||
}
|
||||
lastRefresh = time.Now()
|
||||
} else {
|
||||
me.baseGui.Update(testRefresh)
|
||||
if time.Since(lastRefresh) > 3*time.Second {
|
||||
if me.clock.tk != nil && !me.showHelp {
|
||||
if me.notify.clock.tk != nil && !me.showHelp {
|
||||
// also double check the gocui view exists
|
||||
if me.clock.tk.v != nil {
|
||||
me.clock.tk.v.Clear()
|
||||
me.clock.tk.labelN = time.Now().Format("15:04:05")
|
||||
me.clock.tk.v.WriteString(me.clock.tk.labelN)
|
||||
if me.notify.clock.tk.v != nil {
|
||||
me.notify.clock.tk.v.Clear()
|
||||
me.notify.clock.tk.labelN = time.Now().Format("15:04:05")
|
||||
me.notify.clock.tk.v.WriteString(me.notify.clock.tk.labelN)
|
||||
}
|
||||
}
|
||||
lastRefresh = time.Now()
|
||||
|
|
18
structs.go
18
structs.go
|
@ -77,7 +77,8 @@ type config struct {
|
|||
stdout stdout // information for the STDOUT window
|
||||
dropdown dropdown // the dropdown menu
|
||||
textbox dropdown // the textbox popup window
|
||||
clock dropdown // the textbox popup window
|
||||
// clock dropdown // the textbox popup window
|
||||
notify libnotify // emulates the desktop libnotify menu
|
||||
allwin []*guiWidget // for tracking which window is next
|
||||
dark bool // use a 'dark' color palette
|
||||
mouse mouse // mouse settings
|
||||
|
@ -127,14 +128,23 @@ type dropdown struct {
|
|||
h int // the height
|
||||
active bool // is the dropdown menu currently in use?
|
||||
init bool // moves the window offscreen on startup
|
||||
Id int `default:"-78"` // the widget id to use
|
||||
// Id int `default:"-78"` // the widget id to use
|
||||
wId int `default:"-78"` // the widget id to use
|
||||
}
|
||||
|
||||
// settings for the dropdown window
|
||||
type internalTK struct {
|
||||
tk *guiWidget // where to show STDOUT
|
||||
callerTK *guiWidget // which widget called the dropdown menu
|
||||
wId int // the widget id to use
|
||||
active bool // is the internal widget currently in use?
|
||||
}
|
||||
|
||||
// the desktop libnotify menu
|
||||
type libnotify struct {
|
||||
clock *guiWidget // where to show the clock
|
||||
menu *guiWidget // where to show the clock
|
||||
clock internalTK // widget for the clock
|
||||
menu internalTK // libnotify menu icon
|
||||
window internalTK // the libnotify menu
|
||||
}
|
||||
|
||||
// this is the gocui way
|
||||
|
|
|
@ -109,7 +109,7 @@ func textboxClosed() {
|
|||
me.textbox.tk.Hide()
|
||||
// log.Info("textbox closed with text:", newtext, me.textbox.callerTK.cuiName)
|
||||
|
||||
if me.clock.tk.v != nil {
|
||||
if me.notify.clock.tk.v != nil {
|
||||
me.baseGui.SetCurrentView("help")
|
||||
} else {
|
||||
me.baseGui.SetCurrentView("msg")
|
||||
|
|
Loading…
Reference in New Issue