disable color works
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
50fe92a1b1
commit
4f19c8b64d
29
color.go
29
color.go
|
@ -41,7 +41,14 @@ var superLightGrey gocui.Attribute = gocui.GetColor("#55AAFF") // super light gr
|
||||||
// Normal Text On mouseover
|
// Normal Text On mouseover
|
||||||
//
|
//
|
||||||
// Widget Frame Text background Text background
|
// Widget Frame Text background Text background
|
||||||
var colorWindow colorT = colorT{none, gocui.ColorBlue, none, none, powdererBlue, "normal window"}
|
var colorWindow colorT = colorT {
|
||||||
|
frame: none,
|
||||||
|
fg: gocui.ColorBlue,
|
||||||
|
bg: none,
|
||||||
|
selFg: none,
|
||||||
|
selBg: powdererBlue,
|
||||||
|
name: "normal window",
|
||||||
|
}
|
||||||
var colorActiveW colorT = colorT{none, none, powdererBlue, none, powdererBlue, "active window"}
|
var colorActiveW colorT = colorT{none, none, powdererBlue, none, powdererBlue, "active window"}
|
||||||
|
|
||||||
var colorTab colorT = colorT{gocui.ColorBlue, gocui.ColorBlue, none, none, powdererBlue, "normal tab"}
|
var colorTab colorT = colorT{gocui.ColorBlue, gocui.ColorBlue, none, none, powdererBlue, "normal tab"}
|
||||||
|
@ -51,6 +58,15 @@ var colorButton colorT = colorT{gocui.ColorGreen, none, gocui.ColorWhite, gocui.
|
||||||
var colorLabel colorT = colorT{none, none, superLightGrey, none, superLightGrey, "normal label"}
|
var colorLabel colorT = colorT{none, none, superLightGrey, none, superLightGrey, "normal label"}
|
||||||
var colorGroup colorT = colorT{none, none, superLightGrey, none, superLightGrey, "normal group"}
|
var colorGroup colorT = colorT{none, none, superLightGrey, none, superLightGrey, "normal group"}
|
||||||
|
|
||||||
|
var colorDisabled colorT = colorT {
|
||||||
|
frame: superLightGrey,
|
||||||
|
fg: superLightGrey,
|
||||||
|
bg: superLightGrey,
|
||||||
|
selFg: gocui.ColorBlack,
|
||||||
|
selBg: gocui.ColorBlack,
|
||||||
|
name: "disabled widget",
|
||||||
|
}
|
||||||
|
|
||||||
// widget debugging colors. these widgets aren't displayed unless you are debugging
|
// widget debugging colors. these widgets aren't displayed unless you are debugging
|
||||||
var colorRoot colorT = colorT{gocui.ColorRed, none, powdererBlue, none, gocui.ColorBlue, "debug root"}
|
var colorRoot colorT = colorT{gocui.ColorRed, none, powdererBlue, none, gocui.ColorBlue, "debug root"}
|
||||||
var colorFlag colorT = colorT{gocui.ColorRed, none, powdererBlue, none, gocui.ColorGreen, "debug flag"}
|
var colorFlag colorT = colorT{gocui.ColorRed, none, powdererBlue, none, gocui.ColorGreen, "debug flag"}
|
||||||
|
@ -83,6 +99,17 @@ func (tk *guiWidget) setColor(newColor *colorT) {
|
||||||
tk.recreateView()
|
tk.recreateView()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (w *guiWidget) disableColor() {
|
||||||
|
if w.color != &colorDisabled {
|
||||||
|
w.defaultColor = w.color
|
||||||
|
}
|
||||||
|
w.setColor(&colorDisabled)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w *guiWidget) enableColor() {
|
||||||
|
w.setColor(w.defaultColor)
|
||||||
|
}
|
||||||
|
|
||||||
func (w *guiWidget) setDefaultWidgetColor() {
|
func (w *guiWidget) setDefaultWidgetColor() {
|
||||||
w.showView()
|
w.showView()
|
||||||
}
|
}
|
||||||
|
|
37
plugin.go
37
plugin.go
|
@ -28,6 +28,12 @@ func action(a widget.Action) {
|
||||||
me.treeRoot = n
|
me.treeRoot = n
|
||||||
}
|
}
|
||||||
addWidget(n)
|
addWidget(n)
|
||||||
|
w = n.TK.(*guiWidget)
|
||||||
|
if w.enable {
|
||||||
|
// don't change the color
|
||||||
|
} else {
|
||||||
|
w.setColor(&colorDisabled)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// this is done to protect the plugin being 'refreshed' with the
|
// this is done to protect the plugin being 'refreshed' with the
|
||||||
// widget binary tree. TODO: find a way to keep them in sync
|
// widget binary tree. TODO: find a way to keep them in sync
|
||||||
|
@ -35,10 +41,19 @@ func action(a widget.Action) {
|
||||||
a.WidgetId, a.ActionType, a.WidgetType, a.ProgName)
|
a.WidgetId, a.ActionType, a.WidgetType, a.ProgName)
|
||||||
}
|
}
|
||||||
case widget.Show:
|
case widget.Show:
|
||||||
if widget.GetBool(a.Value) {
|
if w.Visible() {
|
||||||
w.showView()
|
// widget was already shown
|
||||||
} else {
|
} else {
|
||||||
w.hideWidgets()
|
log.Log(INFO, "Setting Visible to true", a.ProgName)
|
||||||
|
w.SetVisible(true)
|
||||||
|
}
|
||||||
|
w.showView()
|
||||||
|
case widget.Hide:
|
||||||
|
if w.Visible() {
|
||||||
|
log.Log(INFO, "Setting Visible to false", a.ProgName)
|
||||||
|
w.SetVisible(false)
|
||||||
|
} else {
|
||||||
|
// widget was already hidden
|
||||||
}
|
}
|
||||||
case widget.Set:
|
case widget.Set:
|
||||||
if a.WidgetType == widget.Flag {
|
if a.WidgetType == widget.Flag {
|
||||||
|
@ -62,19 +77,11 @@ func action(a widget.Action) {
|
||||||
log.Log(NOW, "attempting to close the plugin and release stdout and stderr")
|
log.Log(NOW, "attempting to close the plugin and release stdout and stderr")
|
||||||
standardExit()
|
standardExit()
|
||||||
case widget.Enable:
|
case widget.Enable:
|
||||||
if w.Visible() {
|
w.enable = true
|
||||||
// widget was already shown
|
w.enableColor()
|
||||||
} else {
|
|
||||||
log.Log(INFO, "Setting Visible to true", a.ProgName)
|
|
||||||
w.SetVisible(true)
|
|
||||||
}
|
|
||||||
case widget.Disable:
|
case widget.Disable:
|
||||||
if w.Visible() {
|
w.enable = false
|
||||||
log.Log(INFO, "Setting Visible to false", a.ProgName)
|
w.disableColor()
|
||||||
w.SetVisible(false)
|
|
||||||
} else {
|
|
||||||
// widget was already hidden
|
|
||||||
}
|
|
||||||
case widget.Delete:
|
case widget.Delete:
|
||||||
if w == nil {
|
if w == nil {
|
||||||
return
|
return
|
||||||
|
|
|
@ -151,6 +151,11 @@ type guiWidget struct {
|
||||||
|
|
||||||
active bool
|
active bool
|
||||||
|
|
||||||
|
enable bool
|
||||||
|
defaultColor *colorT // store the color to go back to
|
||||||
|
|
||||||
|
hidden bool
|
||||||
|
|
||||||
// AtW int
|
// AtW int
|
||||||
// AtH int
|
// AtH int
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,8 @@ func initWidget(n *tree.Node) *guiWidget {
|
||||||
w.labelN = n.GetProgName()
|
w.labelN = n.GetProgName()
|
||||||
}
|
}
|
||||||
w.frame = true
|
w.frame = true
|
||||||
|
w.hidden = n.State.Hidden
|
||||||
|
w.enable = n.State.Enable
|
||||||
|
|
||||||
if n.WidgetType == widget.Root {
|
if n.WidgetType == widget.Root {
|
||||||
log.Log(INFO, "setupWidget() FOUND ROOT w.id =", n.WidgetId)
|
log.Log(INFO, "setupWidget() FOUND ROOT w.id =", n.WidgetId)
|
||||||
|
|
Loading…
Reference in New Issue