maybe fixed wierd clicks on window drag

This commit is contained in:
Jeff Carr 2025-02-07 02:34:40 -06:00
parent fb3c16707d
commit 7813fc126d
8 changed files with 133 additions and 33 deletions

View File

@ -282,26 +282,3 @@ func (tk *guiWidget) setColorButtonDenseOLD() {
tk.color.selBg = gocui.NewRGBColor(r, g, b) tk.color.selBg = gocui.NewRGBColor(r, g, b)
*/ */
} }
// weird. lots of color problems for me on debian sid using the traditional Andy Herzfield 'gnome'
func (tk *guiWidget) setColorWindow() {
if tk.color == nil {
tk.color = new(colorT)
}
tk.color.frame = gocui.AttrNone
tk.color.fg = gocui.ColorBlue
tk.color.bg = gocui.AttrNone
tk.color.selFg = gocui.ColorWhite
tk.color.selBg = gocui.ColorBlue
}
func (tk *guiWidget) setColorButtonDense() {
if tk.color == nil {
tk.color = new(colorT)
}
tk.color.frame = gocui.AttrNone
tk.color.fg = gocui.ColorBlue
tk.color.bg = gocui.AttrNone
tk.color.selFg = gocui.ColorWhite
tk.color.selBg = gocui.ColorBlue
}

106
colorNew.go Normal file
View File

@ -0,0 +1,106 @@
// Copyright 2017-2025 WIT.COM Inc. All rights reserved.
// Use of this source code is governed by the GPL 3.0
package main
// simple colors for light and dark
import (
"github.com/awesome-gocui/gocui"
)
// weird. lots of color problems for me on debian sid using the traditional Andy Herzfield 'gnome'
func (tk *guiWidget) setColorWindowTitle() {
if tk.color == nil {
tk.color = new(colorT)
}
if me.dark { // use a dark color palette
tk.color.frame = gocui.AttrNone
tk.color.fg = gocui.ColorBlue
tk.color.bg = gocui.AttrNone
tk.color.selFg = gocui.ColorWhite
tk.color.selBg = gocui.ColorBlue
return
}
tk.color.frame = gocui.ColorWhite
tk.color.fg = gocui.AttrNone
tk.color.bg = gocui.ColorBlue
tk.color.selFg = gocui.ColorBlue
tk.color.selBg = gocui.AttrNone
}
func (tk *guiWidget) setColorBG() {
if tk.color == nil {
tk.color = new(colorT)
}
if me.dark {
tk.color.frame = gocui.AttrNone
tk.color.fg = gocui.ColorBlack
tk.color.bg = gocui.ColorBlack
tk.color.selFg = gocui.AttrNone
tk.color.selBg = gocui.AttrNone
return
}
tk.color.frame = gocui.ColorWhite
tk.color.fg = gocui.ColorWhite
tk.color.bg = gocui.AttrNone
tk.color.selFg = gocui.AttrNone
tk.color.selBg = gocui.AttrNone
}
func (tk *guiWidget) setColorButtonDense() {
if tk.color == nil {
tk.color = new(colorT)
}
if me.dark {
tk.color.frame = gocui.AttrNone
tk.color.fg = gocui.ColorBlue
tk.color.bg = gocui.AttrNone
tk.color.selFg = gocui.ColorWhite
tk.color.selBg = gocui.ColorBlue
return
}
tk.color.frame = gocui.AttrNone
tk.color.fg = gocui.ColorBlue
tk.color.bg = gocui.AttrNone
tk.color.selFg = gocui.ColorWhite
tk.color.selBg = gocui.ColorBlue
}
func (tk *guiWidget) setColorButton() {
if tk.color == nil {
tk.color = new(colorT)
}
if me.dark {
tk.color.frame = gocui.ColorBlue
tk.color.fg = gocui.AttrNone
tk.color.bg = gocui.AttrNone
tk.color.selFg = gocui.ColorWhite
tk.color.selBg = gocui.ColorBlue
return
}
tk.color.frame = gocui.ColorBlue
tk.color.fg = gocui.AttrNone
tk.color.bg = gocui.AttrNone
tk.color.selFg = gocui.ColorWhite
tk.color.selBg = gocui.ColorBlue
}
func (tk *guiWidget) setColorInput() {
if tk.color == nil {
tk.color = new(colorT)
}
if me.dark {
tk.color.frame = gocui.ColorYellow
tk.color.fg = gocui.AttrNone
tk.color.bg = gocui.AttrNone
tk.color.selFg = gocui.ColorYellow
tk.color.selBg = gocui.ColorBlack
return
}
tk.color.frame = gocui.ColorYellow
tk.color.fg = gocui.AttrNone
tk.color.bg = gocui.AttrNone
tk.color.selFg = gocui.ColorYellow
tk.color.selBg = gocui.ColorBlack
}

View File

@ -33,7 +33,7 @@ func makeNewFlagWidget(wId int) *guiWidget {
// set the name used by gocui to the id // set the name used by gocui to the id
tk.cuiName = fmt.Sprintf("%d DR", wId) tk.cuiName = fmt.Sprintf("%d DR", wId)
tk.color = &colorFlag tk.setColorInput()
// add this new widget on the binary tree // add this new widget on the binary tree
tk.parent = me.treeRoot.TK.(*guiWidget) tk.parent = me.treeRoot.TK.(*guiWidget)
@ -127,7 +127,7 @@ func (tk *guiWidget) showTextbox() {
if me.textbox.tk == nil { if me.textbox.tk == nil {
// should only happen once // should only happen once
me.textbox.tk = makeNewFlagWidget(me.textbox.wId) me.textbox.tk = makeNewFlagWidget(me.textbox.wId)
me.dropdown.tk.dumpWidget("init() textbox") me.textbox.tk.dumpWidget("init() textbox")
} }
if me.textbox.tk == nil { if me.textbox.tk == nil {
log.Log(GOCUI, "showTextbox() Is Broken") log.Log(GOCUI, "showTextbox() Is Broken")
@ -137,7 +137,7 @@ func (tk *guiWidget) showTextbox() {
// log.Log(GOCUI, "showTextbox() SHOWING AT W,H=", startW, startH) // log.Log(GOCUI, "showTextbox() SHOWING AT W,H=", startW, startH)
me.textbox.tk.MoveToOffset(startW+3, startH+2) me.textbox.tk.MoveToOffset(startW+3, startH+2)
me.textbox.tk.labelN = "holy cow" me.textbox.tk.labelN = "holy cow"
me.textbox.tk.SetColorRed() me.textbox.tk.setColorInput()
me.textbox.tk.Show() me.textbox.tk.Show()
me.textbox.active = true me.textbox.active = true
me.textbox.callerTK = tk me.textbox.callerTK = tk

View File

@ -99,7 +99,12 @@ func addDropdown() *tree.Node {
// use this to test code ideas // put whatever you want here and hit '2' to activate it // use this to test code ideas // put whatever you want here and hit '2' to activate it
func theNotsure(g *gocui.Gui, v *gocui.View) error { func theNotsure(g *gocui.Gui, v *gocui.View) error {
log.Info("got keypress 2. now what?") if me.dark {
me.dark = false
} else {
me.dark = true
}
log.Info("got keypress 2. now what? dark =", me.dark)
return nil return nil
} }

View File

@ -101,11 +101,19 @@ func mouseDown(g *gocui.Gui, v *gocui.View) error {
} }
} }
} }
if tk.node.WidgetType == widget.Stdout {
tk.dumpWidget("stdout fixme drag()" + tk.labelN)
me.currentDrag = tk
tk.dragW = w - tk.gocuiSize.w0
tk.dragH = h - tk.gocuiSize.h0
// tk.doWidgetClick(w-tk.dragW, w-tk.dragH)
return nil
}
tk.dumpWidget("mouse drag()" + tk.labelN) tk.dumpWidget("mouse drag()" + tk.labelN)
me.currentDrag = tk me.currentDrag = tk
tk.dragW = w - tk.gocuiSize.w0 tk.dragW = w - tk.gocuiSize.w0
tk.dragH = h - tk.gocuiSize.h0 tk.dragH = h - tk.gocuiSize.h0
tk.doWidgetClick(w-tk.dragW, w-tk.dragH) // tk.doWidgetClick(w-tk.dragW, w-tk.dragH)
return nil return nil
// move the msg I guess // move the msg I guess

View File

@ -100,6 +100,8 @@ func (tk *guiWidget) doWidgetClick(w int, h int) {
tk.showTextbox() tk.showTextbox()
case widget.Flag: case widget.Flag:
tk.dropdownClicked(w, h) tk.dropdownClicked(w, h)
case widget.Stdout:
tk.dumpWidget("stdout click()")
default: default:
tk.dumpWidget("undef click()") tk.dumpWidget("undef click()")
} }

View File

@ -71,7 +71,7 @@ type config struct {
downW int // where the mouse was pressed down downW int // where the mouse was pressed down
downH int // where the mouse was pressed down downH int // where the mouse was pressed down
currentDrag *guiWidget // what widget is currently being moved around currentDrag *guiWidget // what widget is currently being moved around
dark bool // use a 'dark' color palette
} }
// settings for the stdout window // settings for the stdout window

View File

@ -63,14 +63,16 @@ func addWidget(n *tree.Node) {
tk.color = &colorTab tk.color = &colorTab
return return
case widget.Button: case widget.Button:
tk.color = &colorButton tk.setColorButton()
return return
case widget.Checkbox: case widget.Checkbox:
tk.color = &colorCheckbox // tk.color = &colorCheckbox
tk.setColorInput()
tk.labelN = "X " + n.State.Label tk.labelN = "X " + n.State.Label
return return
case widget.Dropdown: case widget.Dropdown:
tk.color = &colorDropdown // tk.color = &colorDropdown
tk.setColorInput()
return return
case widget.Textbox: case widget.Textbox:
n.State.Label = "TEXTBOX" n.State.Label = "TEXTBOX"
@ -91,7 +93,7 @@ func addWidget(n *tree.Node) {
setFake(n) setFake(n)
return return
case widget.Group: case widget.Group:
tk.color = &colorGroup // tk.color = &colorLabel
tk.frame = false tk.frame = false
return return
case widget.Label: case widget.Label: