Finally got around to restoring the behavior of the toolbar with

respect to using the 3rd mouse button to hide a layer, and
indicating the layer is hidden by blanking the icon (which works
better with the new scrollable icon list, but got broken by the
same).  Also:  Added a previously missing behavior, which is to
correctly update the icon settings based on using the command
"see" and "see no" with layer aliases (e.g., "allm1").
This commit is contained in:
Tim Edwards 2024-10-01 16:01:28 -04:00
parent dba6f99d93
commit 3e0ad4ff58
2 changed files with 58 additions and 34 deletions

View File

@ -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 <KeyPress-u> \
"$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 <ButtonPress-1> "$win see $layername"
bind $child <ButtonPress-3> "$win see no $layername"
# Intercept mousewheel on the layer/button as well
bind $child <Button-4> \
[subst { event generate ${framename}.toolbar.canvas <Button-4> }]
bind $child <Button-5> \
[subst { event generate ${framename}.toolbar.canvas <Button-5> }]
}
# Bind the mouse enter event to highlight the label
bind $toolbar_label <Enter> "$toolbar_label configure -background yellow"
button $toolbar_button -image pale_$layername -command \
"$win see $layername"
bind $layer_frame <Enter> \
[subst {focus %W ; ${framename}.titlebar.message configure \
-text "$layername (locked)"}]
[subst {focus %W ; ${framename}.titlebar.message configure \
-text "$layername (locked)"}]
bind $layer_frame <ButtonPress-3> \
"$win see no $layername"
bind $layer_frame <KeyPress-u> \
"$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 <ButtonPress-1> "$win see $layername"
bind $child <ButtonPress-2> "$win paint $layername"
bind $child <Shift-ButtonPress-2> "$win erase $layername"
bind $child <ButtonPress-3> "$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 <ButtonPress-1> "$win see $layername"
bind $child <ButtonPress-2> "$win paint $layername"
bind $child <Shift-ButtonPress-2> "$win erase $layername"
bind $child <ButtonPress-3> "$win see no $layername"
# Intercept mousewheel on the layer/button as well
bind $child <Button-4> \
[subst { event generate ${framename}.toolbar.canvas <Button-4> }]
bind $child <Button-5> \
[subst { event generate ${framename}.toolbar.canvas <Button-5> }]
}
# Intercept mousewheel on the layer/button as well
bind $child <Button-4> \
[subst { event generate ${framename}.toolbar.canvas <Button-4> }]
bind $child <Button-5> \
[subst { event generate ${framename}.toolbar.canvas <Button-5> }]
}
# Bind the mouse enter event to highlight the label
bind $toolbar_label <Enter> "$toolbar_label configure -background yellow"

View File

@ -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}
}
}
}
}