Skip to content

Commit f062e50

Browse files
stefanhallerpaulusmack
authored andcommitted
gitk: Work around empty back and forward images when buttons are disabled
On Mac, the back and forward buttons show an empty rectange instead of a grayed-out arrow when they are disabled. The reason is a Tk bug on Mac that causes disabled images not to draw correctly (not to draw at all, that is); see <https://groups.google.com/forum/?fromgroups=#!topic/comp.lang.tcl/V-nW1JBq0eU>. To work around this, we explicitly provide gray images for the disabled state; I think this looks better than the default stipple effect that you get on Windows as well, but that may be a matter of taste. Signed-off-by: Stefan Haller <[email protected]> Signed-off-by: Paul Mackerras <[email protected]>
1 parent 30441a6 commit f062e50

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

gitk

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2161,27 +2161,32 @@ proc makewindow {} {
21612161
trace add variable sha1string write sha1change
21622162
pack $sha1entry -side left -pady 2
21632163

2164-
image create bitmap bm-left -data {
2164+
set bm_left_data {
21652165
#define left_width 16
21662166
#define left_height 16
21672167
static unsigned char left_bits[] = {
21682168
0x00, 0x00, 0xc0, 0x01, 0xe0, 0x00, 0x70, 0x00, 0x38, 0x00, 0x1c, 0x00,
21692169
0x0e, 0x00, 0xff, 0x7f, 0xff, 0x7f, 0xff, 0x7f, 0x0e, 0x00, 0x1c, 0x00,
21702170
0x38, 0x00, 0x70, 0x00, 0xe0, 0x00, 0xc0, 0x01};
21712171
}
2172-
image create bitmap bm-right -data {
2172+
set bm_right_data {
21732173
#define right_width 16
21742174
#define right_height 16
21752175
static unsigned char right_bits[] = {
21762176
0x00, 0x00, 0xc0, 0x01, 0x80, 0x03, 0x00, 0x07, 0x00, 0x0e, 0x00, 0x1c,
21772177
0x00, 0x38, 0xff, 0x7f, 0xff, 0x7f, 0xff, 0x7f, 0x00, 0x38, 0x00, 0x1c,
21782178
0x00, 0x0e, 0x00, 0x07, 0x80, 0x03, 0xc0, 0x01};
21792179
}
2180-
${NS}::button .tf.bar.leftbut -image bm-left -command goback \
2181-
-state disabled -width 26
2180+
image create bitmap bm-left -data $bm_left_data
2181+
image create bitmap bm-left-gray -data $bm_left_data -foreground "#999"
2182+
image create bitmap bm-right -data $bm_right_data
2183+
image create bitmap bm-right-gray -data $bm_right_data -foreground "#999"
2184+
2185+
${NS}::button .tf.bar.leftbut -image [list bm-left disabled bm-left-gray] \
2186+
-command goback -state disabled -width 26
21822187
pack .tf.bar.leftbut -side left -fill y
2183-
${NS}::button .tf.bar.rightbut -image bm-right -command goforw \
2184-
-state disabled -width 26
2188+
${NS}::button .tf.bar.rightbut -image [list bm-right disabled bm-right-gray] \
2189+
-command goforw -state disabled -width 26
21852190
pack .tf.bar.rightbut -side left -fill y
21862191

21872192
${NS}::label .tf.bar.rowlabel -text [mc "Row"]

0 commit comments

Comments
 (0)