diff --git a/tcltk/toolbar.tcl b/tcltk/toolbar.tcl index a587dac3..d8f68e22 100644 --- a/tcltk/toolbar.tcl +++ b/tcltk/toolbar.tcl @@ -121,26 +121,46 @@ proc createLayerFrame {framename layername i} { # Place the layer button, checking if it is locked or not set locklist [tech locked] - # Locked button bindings if {[lsearch $locklist $layername] != -1} { + # Locked button bindings + set toolbar_button ${layer_frame}.p + button $toolbar_button -image pale_$layername + + # Bind keypresses when mouse if over layer frame + bind $layer_frame \ + "$win tech unlock $layername ; \ + grid forget $toolbar_button ; \ + grid ${layer_frame}.b -row $i -column 0 -sticky w" + + # Bindings for painiting, erasing and seeing layers, + # which are bound both to the layer button, as well + # as the layer label + set childrenList [winfo children $layer_frame] + + foreach child $childrenList { + # 3rd mouse button makes layer invisible; 1st mouse button restores it. + # 2nd mouse button paints the layer color. Key "p" also does paint, esp. + # for users with 2-button mice. Key "e" erases, as does Shift-Button-2. + bind $child "$win see $layername" + bind $child "$win see no $layername" + + # Intercept mousewheel on the layer/button as well + bind $child \ + [subst { event generate ${framename}.toolbar.canvas }] + bind $child \ + [subst { event generate ${framename}.toolbar.canvas }] + } + + # Bind the mouse enter event to highlight the label + bind $toolbar_label "$toolbar_label configure -background yellow" - button $toolbar_button -image pale_$layername -command \ - "$win see $layername" bind $layer_frame \ - [subst {focus %W ; ${framename}.titlebar.message configure \ - -text "$layername (locked)"}] + [subst {focus %W ; ${framename}.titlebar.message configure \ + -text "$layername (locked)"}] - bind $layer_frame \ - "$win see no $layername" - - bind $layer_frame \ - "$win tech unlock $layername ; \ - grid forget $toolbar_button ; \ - grid ${layer_frame}.b -row $i -column 0 -sticky w" - - # Unlocked button bindings } else { + # Unlocked button bindings set toolbar_button ${layer_frame}.b button $toolbar_button -image img_$layername @@ -162,21 +182,21 @@ proc createLayerFrame {framename layername i} { # as the layer label set childrenList [winfo children $layer_frame] - foreach child $childrenList { - # 3rd mouse button makes layer invisible; 1st mouse button restores it. - # 2nd mouse button paints the layer color. Key "p" also does paint, esp. - # for users with 2-button mice. Key "e" erases, as does Shift-Button-2. - bind $child "$win see $layername" - bind $child "$win paint $layername" - bind $child "$win erase $layername" - bind $child "$win see no $layername" + foreach child $childrenList { + # 3rd mouse button makes layer invisible; 1st mouse button restores it. + # 2nd mouse button paints the layer color. Key "p" also does paint, esp. + # for users with 2-button mice. Key "e" erases, as does Shift-Button-2. + bind $child "$win see $layername" + bind $child "$win paint $layername" + bind $child "$win erase $layername" + bind $child "$win see no $layername" - # Intercept mousewheel on the layer/button as well - bind $child \ - [subst { event generate ${framename}.toolbar.canvas }] - bind $child \ - [subst { event generate ${framename}.toolbar.canvas }] - } + # Intercept mousewheel on the layer/button as well + bind $child \ + [subst { event generate ${framename}.toolbar.canvas }] + bind $child \ + [subst { event generate ${framename}.toolbar.canvas }] + } # Bind the mouse enter event to highlight the label bind $toolbar_label "$toolbar_label configure -background yellow" diff --git a/tcltk/wrapper.tcl b/tcltk/wrapper.tcl index bd99d48e..73f18ae9 100644 --- a/tcltk/wrapper.tcl +++ b/tcltk/wrapper.tcl @@ -760,12 +760,16 @@ proc magic::toolupdate {win {yesno "yes"} {layerlist "none"}} { # "hidespecial" is used, so catch each configure command. if {$canon != ""} { - if {$yesno == "yes"} { - catch {${framename}.toolbar.b$canon configure -image img_$canon} - catch {${framename}.toolbar.p$canon configure -image pale_$canon} - } else { - catch {${framename}.toolbar.b$canon configure -image img_space} - catch {${framename}.toolbar.p$canon configure -image img_space} + # Layer aliases like "allm1" expand into multiple layers + foreach clayer $canon { + set toolframe ${framename}.toolbar.canvas.frame.f${clayer} + if {$yesno == "yes"} { + catch {${toolframe}.b configure -image img_$clayer} + catch {${toolframe}.p configure -image pale_$clayer} + } else { + catch {${toolframe}.b configure -image img_space} + catch {${toolframe}.p configure -image img_space} + } } } }