Skip to content

Commit 78d87c0

Browse files
committed
gitk: on themed tk, use uicolor to draw a sash between panes
Add a custom sash (grab/resize handle) where the window is split into panes when using themed Tk as. Other than native Tk which draws sashes by default, themed Tk does not, by default, render such handles leaving users to guess where to click to start resizing window panes. The color used for drawing these is uicolor, which is not needed on themed Tk, allowing the user to make these elements as pronounced or as invisible as desired. Signed-off-by: Christoph Sommer <[email protected]>
1 parent abe9230 commit 78d87c0

File tree

1 file changed

+45
-3
lines changed

1 file changed

+45
-3
lines changed

gitk-git/gitk

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2133,7 +2133,31 @@ proc setoptions {} {
21332133
option add *Listbox.font mainfont startupFile
21342134
}
21352135
2136+
proc createttkimages {} {
2137+
global uicolor
2138+
2139+
image create bitmap img:myVerticalSash -foreground $uicolor -data {
2140+
#define xbm_width 5
2141+
#define xbm_height 47
2142+
static unsigned char xbm_bits[] = {
2143+
0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
2144+
0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x0e,
2145+
0x00, 0x00, 0x0e, 0x00, 0x00, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
2146+
0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04 };
2147+
}
2148+
2149+
image create bitmap img:myHorizontalSash -foreground $uicolor -data {
2150+
#define xbm_width 47
2151+
#define xbm_height 5
2152+
static unsigned char xbm_bits[] = {
2153+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x90, 0x04, 0x00, 0x00,
2154+
0xff, 0xff, 0x93, 0xe4, 0xff, 0x7f, 0x00, 0x00, 0x90, 0x04, 0x00, 0x00,
2155+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
2156+
}
2157+
}
2158+
21362159
proc setttkstyle {} {
2160+
21372161
eval font configure TkDefaultFont [fontflags mainfont]
21382162
eval font configure TkTextFont [fontflags textfont]
21392163
eval font configure TkHeadingFont [fontflags mainfont]
@@ -2143,6 +2167,16 @@ proc setttkstyle {} {
21432167
eval font configure TkIconFont [fontflags uifont]
21442168
eval font configure TkMenuFont [fontflags uifont]
21452169
eval font configure TkSmallCaptionFont [fontflags uifont]
2170+
2171+
createttkimages
2172+
2173+
ttk::style element create myVerticalSash image img:myVerticalSash -sticky ew
2174+
2175+
ttk::style element create myHorizontalSash image img:myHorizontalSash -sticky ns
2176+
2177+
ttk::style layout Vertical.Sash { myVerticalSash }
2178+
2179+
ttk::style layout Horizontal.Sash { myHorizontalSash }
21462180
}
21472181
21482182
# Make a menu and submenus.
@@ -11825,7 +11859,7 @@ proc prefspage_colors {notebook} {
1182511859
grid $page.cdisp - -sticky w -pady 10
1182611860
label $page.ui -padx 40 -relief sunk -background $uicolor
1182711861
${NS}::button $page.uibut -text [mc "Interface"] \
11828-
-command [list choosecolor uicolor {} $page.ui [mc "interface"] setui]
11862+
-command [list choosecolor uicolor {} $page.ui [mc "interface"] setui_dialog]
1182911863
grid x $page.uibut $page.ui -sticky w
1183011864
label $page.bg -padx 40 -relief sunk -background $bgcolor
1183111865
${NS}::button $page.bgbut -text [mc "Background"] \
@@ -12006,6 +12040,14 @@ proc setui {c} {
1200612040
tk_setPalette background $c selectColor $selc
1200712041
}
1200812042
12043+
proc setui_dialog {c} {
12044+
global uicolor
12045+
12046+
setui $c
12047+
12048+
createttkimages
12049+
}
12050+
1200912051
proc setbg {c} {
1201012052
global bglist
1201112053
@@ -12706,8 +12748,6 @@ eval font create textfontbold [fontflags textfont 1]
1270612748
parsefont uifont $uifont
1270712749
eval font create uifont [fontflags uifont]
1270812750
12709-
setui $uicolor
12710-
1271112751
setoptions
1271212752
1271312753
# check that we can find a .git directory somewhere...
@@ -12788,6 +12828,8 @@ if {![info exists have_ttk]} {
1278812828
set use_ttk [expr {$have_ttk && $want_ttk}]
1278912829
set NS [expr {$use_ttk ? "ttk" : ""}]
1279012830
12831+
setui $uicolor
12832+
1279112833
if {$use_ttk} {
1279212834
setttkstyle
1279312835
}

0 commit comments

Comments
 (0)