clock works again

This commit is contained in:
Jeff Carr 2025-03-03 15:00:27 -06:00
parent 76e15fa1df
commit 5e6d7cffdf
3 changed files with 96 additions and 5 deletions

View File

@ -52,6 +52,10 @@ func toolkitInit() {
// SETUP HELP END
// SETUP STDOUT START
if me.stdout.tk == nil {
makeOutputWidget(me.baseGui, "from setThingsOnTop()")
}
time.Sleep(300 * time.Millisecond)
log.Info("gocui toolkitInit() me.ok =", me.ok)
me.baseGui.Update(testRefresh)
@ -72,10 +76,7 @@ func toolkitInit() {
// SETUP libnotify
makeNotifyClock(me.notify.clock.wId)
if me.stdout.tk == nil {
makeOutputWidget(me.baseGui, "from setThingsOnTop()")
}
makeNotifyMenu(me.notify.menu.wId)
// PUT INIT DEBUG COOE HERE
var toggle bool

View File

@ -65,7 +65,25 @@ func makeNotifyClock(wId int) {
me.notify.clock.tk.setColorLabel()
me.notify.clock.tk.Show()
me.notify.clock.active = true
me.notify.clock.tk.dumpWidget("showClock()")
me.notify.clock.tk.dumpWidget("notifyClock()")
}
func makeNotifyMenu(wId int) {
if me.treeRoot == nil {
log.Info("gogui makeClock() error. treeRoot == nil")
return
}
me.notify.menu.tk = makeNewInternalWidget(wId)
me.notify.menu.tk.dumpWidget("init() menu")
w, _ := me.baseGui.Size()
me.notify.menu.tk.MoveToOffset(w-5, me.notify.clock.offsetH)
me.notify.menu.tk.labelN = "|jwc|"
me.notify.menu.tk.frame = false
me.notify.menu.tk.setColorButton()
me.notify.menu.tk.Show()
me.notify.menu.active = true
me.notify.menu.tk.dumpWidget("notifyMenu()")
}
@ -99,6 +117,26 @@ func libNotifyUpdate() {
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)
hardDrawAtgocuiSize(me.notify.clock.tk)
// hardDrawUnderMouse(me.notify.clock.tk, "clock")
log.Info("libNotifyUpdate updated clock", me.notify.clock.tk.labelN)
if me.notify.menu.tk == nil {
log.Info("libNotifyUpdate error menu.tk == nil")
return
}
if me.notify.menu.tk.v == nil {
log.Info("libNotifyUpdate error menu.tk.v == nil")
return
}
// update the menu
me.notify.menu.tk.v.Clear()
me.notify.menu.tk.labelN = "boo"
me.notify.menu.tk.v.WriteString(me.notify.menu.tk.labelN)
// hardDrawUnderMouse(me.notify.menu.tk, "menu")
me.baseGui.SetViewOnTop(me.notify.menu.tk.v.Name())
me.baseGui.SetViewOnTop(me.notify.clock.tk.v.Name())
}
// in the very end of redrawing things, this will place the help and stdout on the top or botton
@ -109,10 +147,17 @@ func setThingsOnTop() {
} else {
me.baseGui.SetViewOnTop("help")
}
if me.notify.clock.tk != nil {
me.baseGui.SetViewOnTop(me.notify.clock.tk.v.Name())
}
if me.notify.menu.tk != nil {
if me.notify.menu.tk.v != nil {
me.baseGui.SetViewOnTop(me.notify.menu.tk.v.Name())
}
}
if me.stdout.tk == nil {
makeOutputWidget(me.baseGui, "from setThingsOnTop()")
}
@ -143,6 +188,47 @@ func setThingsOnTop() {
setBottomBG()
}
// useful for debuggging
func hardDrawUnderMouse(tk *guiWidget, name string) {
if tk.v != nil {
tk.Hide()
}
w, h := me.baseGui.MousePosition()
a := w
b := h
c := w + 8
d := h + 4
var err error
tk.v, err = me.baseGui.SetView(tk.cuiName, a, b, c, d, 0)
if err == nil {
log.Info("hardDrawUnderMouse() err ok widget", tk.cuiName)
tk.dumpWidget("hard draw err")
}
tk.v.Frame = false
tk.v.Clear()
tk.v.WriteString(tk.labelN + "\n" + name)
}
func hardDrawAtgocuiSize(tk *guiWidget) {
if tk.v != nil {
tk.Hide()
}
a := tk.gocuiSize.w0
b := tk.gocuiSize.h0
c := tk.gocuiSize.w1
d := tk.gocuiSize.h1
var err error
tk.v, err = me.baseGui.SetView(tk.cuiName, a, b, c, d, 0)
if err == nil {
log.Info("hardDrawAtgocuiSize() err ok widget", tk.cuiName)
tk.dumpWidget("hard draw err")
}
tk.v.Frame = false
tk.v.Clear()
tk.v.WriteString(tk.labelN)
log.Info("hardDrawAtgocuiSize() err ok widget", tk.cuiName, a, b, c, d, tk.v.Name())
}
// find the "BG" widget and set it to the background on the very very bottom
func setBottomBG() {
if me.BG.tk == nil {

View File

@ -71,6 +71,10 @@ func (tk *guiWidget) redrawWindow(w int, h int) {
tk.setFullSize()
tk.Show()
if tk.v == nil {
log.Info("redrawWindow on tk.v == nil")
standardExit()
}
tk.v.Clear()
fmt.Fprint(tk.v, "ZZZ"+tk.GetText())
tk.showWidgets()