aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans-Christoph Steiner <eighthave@users.sourceforge.net>2012-12-20 03:27:45 +0000
committerHans-Christoph Steiner <eighthave@users.sourceforge.net>2012-12-20 03:27:45 +0000
commitd9398eace7a59e62ebfcae277a87304f435a15b7 (patch)
treea91ca29cf9483d0ba6341346edcc8f96da2e4fb2
parent99ef672e3a1e69d8d4059f10855fd5b0889b6378 (diff)
made it remember any user color changes, and fixed visual bugs
svn path=/trunk/scripts/guiplugins/simple_examples/; revision=16713
-rw-r--r--editmode_look-plugin.tcl31
1 files changed, 21 insertions, 10 deletions
diff --git a/editmode_look-plugin.tcl b/editmode_look-plugin.tcl
index f7ab005..b766ce4 100644
--- a/editmode_look-plugin.tcl
+++ b/editmode_look-plugin.tcl
@@ -1,35 +1,46 @@
# this script makes it so that the cords are hidden when not in edit mode
-proc set_cords_by_editmode {mytoplevel eventname} {
+namespace eval ::editmode_look {
+ # array of the original background colors for each window
+ array set original_color {}
+}
+
+proc ::editmode_look::set_cords_by_editmode {mytoplevel} {
+ variable original_color
if {$mytoplevel eq ".pdwindow"} {return}
set tkcanvas [tkcanvas_name $mytoplevel]
- if { ! [winfo exists $mytoplevel] } {return}
+ # if the mytoplevel sent to us doesn't currently have a window, silently quit
+ if { ! [winfo exists $mytoplevel] } {return}
+ # if the array doesn't have this instance, get the current color
+ if {[array get original_color $mytoplevel] eq ""} {
+ set original_color($mytoplevel) [$tkcanvas cget -background]
+ }
if {$::editmode($mytoplevel) == 1} {
- $tkcanvas configure -background "#fff"
$tkcanvas itemconfigure graph -fill black
$tkcanvas itemconfigure array -fill black
$tkcanvas itemconfigure array -activefill blue
$tkcanvas itemconfigure label -fill black
- $tkcanvas itemconfigure obj -fill black
$tkcanvas itemconfigure msg -activefill black
$tkcanvas itemconfigure atom -activefill black
$tkcanvas itemconfigure cord -fill black
$tkcanvas itemconfigure {inlet || outlet} -outline black
- $tkcanvas raise cord
+ $tkcanvas raise {inlet || outlet || cord}
+ # store the background color, in case its been changed
+ set original_color($mytoplevel) [$tkcanvas cget -background]
+ $tkcanvas configure -background "lightblue"
} else {
- $tkcanvas configure -background white
- $tkcanvas itemconfigure graph -fill magenta
+ $tkcanvas itemconfigure graph -fill grey
$tkcanvas itemconfigure array -fill cyan
$tkcanvas itemconfigure array -activefill blue
$tkcanvas itemconfigure label -fill "#777777"
- $tkcanvas itemconfigure obj -fill grey
$tkcanvas itemconfigure msg -activefill blue
$tkcanvas itemconfigure atom -activefill blue
$tkcanvas itemconfigure cord -fill grey
$tkcanvas itemconfigure {inlet || outlet} -outline white
$tkcanvas lower {inlet || outlet || cord}
+ $tkcanvas configure -background $original_color($mytoplevel)
}
}
-bind PatchWindow <<EditMode>> {+set_cords_by_editmode %W editmode}
-bind PatchWindow <<Loaded>> {+set_cords_by_editmode %W loaded}
+bind PatchWindow <<EditMode>> {+::editmode_look::set_cords_by_editmode %W}
+bind PatchWindow <<Loaded>> {+::editmode_look::set_cords_by_editmode %W}