working on button disable
This commit is contained in:
parent
a575a08bcc
commit
0a60272440
10
place.go
10
place.go
|
@ -145,9 +145,15 @@ func (tk *guiWidget) placeWidgets(startW int, startH int) (int, int) {
|
||||||
case widget.Button:
|
case widget.Button:
|
||||||
if tk.isWindowDense() && tk.isInGrid() {
|
if tk.isWindowDense() && tk.isInGrid() {
|
||||||
tk.frame = false
|
tk.frame = false
|
||||||
tk.color = nil
|
// tk.color = nil
|
||||||
tk.defaultColor = nil
|
// tk.defaultColor = nil
|
||||||
|
/*
|
||||||
|
if tk.node.IsEnabled() {
|
||||||
tk.setColorButtonDense()
|
tk.setColorButtonDense()
|
||||||
|
} else {
|
||||||
|
tk.setColorDisable()
|
||||||
|
}
|
||||||
|
*/
|
||||||
// if tk.full.Height() > 0 {
|
// if tk.full.Height() > 0 {
|
||||||
tk.full.h1 = tk.full.h0
|
tk.full.h1 = tk.full.h0
|
||||||
// }
|
// }
|
||||||
|
|
62
plugin.go
62
plugin.go
|
@ -220,13 +220,23 @@ func (tk *guiWidget) GetText() string {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func (tk *guiWidget) Disable() {
|
func hideDisable() {
|
||||||
if tk == nil {
|
if me.textbox.tk == nil {
|
||||||
log.Log(NOW, "widget is nil")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
initTextbox()
|
initTextbox()
|
||||||
tk.prepTextbox()
|
me.textbox.tk.prepTextbox()
|
||||||
|
}
|
||||||
|
|
||||||
|
me.textbox.tk.Hide()
|
||||||
|
me.textbox.tk.enable = false
|
||||||
|
me.textbox.tk.node.State.Enable = false
|
||||||
|
me.textbox.active = false
|
||||||
|
}
|
||||||
|
|
||||||
|
func showDisable() {
|
||||||
|
if me.textbox.tk == nil {
|
||||||
|
initTextbox()
|
||||||
|
me.textbox.tk.prepTextbox()
|
||||||
|
}
|
||||||
r := new(rectType)
|
r := new(rectType)
|
||||||
r.w0 = 2
|
r.w0 = 2
|
||||||
r.h0 = 1
|
r.h0 = 1
|
||||||
|
@ -252,22 +262,17 @@ func (tk *guiWidget) Disable() {
|
||||||
me.baseGui.SetKeybinding(me.textbox.tk.v.Name(), gocui.KeyEnter, gocui.ModNone, theCloseTheTextbox)
|
me.baseGui.SetKeybinding(me.textbox.tk.v.Name(), gocui.KeyEnter, gocui.ModNone, theCloseTheTextbox)
|
||||||
|
|
||||||
me.textbox.active = true
|
me.textbox.active = true
|
||||||
|
}
|
||||||
|
|
||||||
|
func (tk *guiWidget) Disable() {
|
||||||
|
if tk == nil {
|
||||||
|
log.Log(NOW, "widget is nil")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
tk.enable = false
|
|
||||||
tk.node.State.Enable = false
|
|
||||||
// log.Info("disable widget in gocui", tk.node.WidgetType, tk.node.ProgName())
|
|
||||||
switch tk.node.WidgetType {
|
switch tk.node.WidgetType {
|
||||||
case widget.Box:
|
case widget.Box:
|
||||||
// log.Info("todo: blank out the window here", tk.String())
|
showDisable()
|
||||||
r := new(rectType)
|
|
||||||
// startW, startH := tk.Position()
|
|
||||||
r.w0 = 0
|
|
||||||
r.h0 = 0
|
|
||||||
r.w1 = r.w0 + 24
|
|
||||||
r.h1 = r.h0 + 2
|
|
||||||
me.textbox.tk.forceSizes(r)
|
|
||||||
showTextbox("Running...")
|
|
||||||
return
|
return
|
||||||
case widget.Button:
|
case widget.Button:
|
||||||
tk.setColorDisable()
|
tk.setColorDisable()
|
||||||
|
@ -275,7 +280,6 @@ func (tk *guiWidget) Disable() {
|
||||||
default:
|
default:
|
||||||
tk.dumpWidget("fixme: disable")
|
tk.dumpWidget("fixme: disable")
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (tk *guiWidget) Enable() {
|
func (tk *guiWidget) Enable() {
|
||||||
|
@ -283,25 +287,10 @@ func (tk *guiWidget) Enable() {
|
||||||
log.Log(NOW, "widget is nil")
|
log.Log(NOW, "widget is nil")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
initTextbox()
|
|
||||||
tk.prepTextbox()
|
|
||||||
|
|
||||||
me.textbox.tk.Hide()
|
|
||||||
me.textbox.tk.enable = false
|
|
||||||
me.textbox.tk.node.State.Enable = false
|
|
||||||
|
|
||||||
/*
|
|
||||||
initTextbox()
|
|
||||||
|
|
||||||
tk.enable = true
|
|
||||||
tk.node.State.Enable = true
|
|
||||||
// log.Info("enable widget in gocui", tk.node.WidgetType, tk.node.ProgName())
|
|
||||||
switch tk.node.WidgetType {
|
switch tk.node.WidgetType {
|
||||||
case widget.Box:
|
case widget.Box:
|
||||||
// log.Info("todo: un blank the window here")
|
hideDisable()
|
||||||
me.textbox.tk.Hide()
|
|
||||||
me.textbox.active = false
|
|
||||||
// log.Info("escaped from textbox")
|
|
||||||
return
|
return
|
||||||
case widget.Button:
|
case widget.Button:
|
||||||
tk.restoreEnableColor()
|
tk.restoreEnableColor()
|
||||||
|
@ -309,5 +298,4 @@ func (tk *guiWidget) Enable() {
|
||||||
default:
|
default:
|
||||||
tk.dumpWidget("fixme: enable")
|
tk.dumpWidget("fixme: enable")
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ func setFake(n *tree.Node) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// func (n *node) addWidget(n *tree.Node) {
|
// mostly just sets the colors of things
|
||||||
func addWidget(n *tree.Node) {
|
func addWidget(n *tree.Node) {
|
||||||
if !me.ok {
|
if !me.ok {
|
||||||
log.Log(INFO, "addWidget() START NOT OKAY")
|
log.Log(INFO, "addWidget() START NOT OKAY")
|
||||||
|
@ -36,8 +36,7 @@ func addWidget(n *tree.Node) {
|
||||||
log.Log(INFO, "addWidget() START NOT OKAY")
|
log.Log(INFO, "addWidget() START NOT OKAY")
|
||||||
waitOK()
|
waitOK()
|
||||||
}
|
}
|
||||||
var tk *guiWidget
|
tk := n.TK.(*guiWidget)
|
||||||
tk = n.TK.(*guiWidget)
|
|
||||||
log.Log(INFO, "setStartWH() w.id =", n.WidgetId, "n.name", n.String())
|
log.Log(INFO, "setStartWH() w.id =", n.WidgetId, "n.name", n.String())
|
||||||
switch n.WidgetType {
|
switch n.WidgetType {
|
||||||
case widget.Root:
|
case widget.Root:
|
||||||
|
@ -67,10 +66,9 @@ func addWidget(n *tree.Node) {
|
||||||
// tk.color = &colorTab
|
// tk.color = &colorTab
|
||||||
return
|
return
|
||||||
case widget.Button:
|
case widget.Button:
|
||||||
|
tk.setColorButton()
|
||||||
if tk.node.IsEnabled() {
|
if tk.node.IsEnabled() {
|
||||||
tk.setColorButton()
|
|
||||||
} else {
|
} else {
|
||||||
tk.setColorButton()
|
|
||||||
tk.setColorDisable()
|
tk.setColorDisable()
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
|
13
treeDraw.go
13
treeDraw.go
|
@ -182,6 +182,19 @@ func (tk *guiWidget) drawView() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switch tk.node.WidgetType {
|
||||||
|
case widget.Button:
|
||||||
|
if tk.node.IsEnabled() {
|
||||||
|
if tk.isWindowDense() && tk.isInGrid() {
|
||||||
|
tk.setColorButtonDense()
|
||||||
|
} else {
|
||||||
|
tk.setColorButton()
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
tk.setColorDisable()
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
}
|
||||||
// if you don't do this here, it will be black & white only
|
// if you don't do this here, it will be black & white only
|
||||||
if tk.color != nil {
|
if tk.color != nil {
|
||||||
tk.v.FrameColor = tk.color.frame
|
tk.v.FrameColor = tk.color.frame
|
||||||
|
|
Loading…
Reference in New Issue