Amend tab ordering and text widget border and highlighting.

Tab order follows widget creation order (and Z-order) so amend this to match the layout more logically. For keyboard selection a highlight around the selected text widget is useful. Customized on Windows themed Tk to follow the native theme more closely with a custom EntryFrame style. Signed-off-by: Pat Thoyts <patthoyts@users.sourceforge.net>

Pat Thoyts committed Oct 2, 2016 at 00:13 UTC 30508bc4e347db474b04a392cd646672a56d43be
2 files changed +124 -31
git-gui.sh
+38 -30
@@ -3194,13 +3194,34 @@ if {$use_ttk} {
3194 }
3195 pack .vpane -anchor n -side top -fill both -expand 1
3196
3197 +# -- Working Directory File List
3198 +
3199 +textframe .vpane.files.workdir -height 100 -width 200
3200 +tlabel .vpane.files.workdir.title -text [mc "Unstaged Changes"] \
3201 + -background lightsalmon -foreground black
3202 +ttext $ui_workdir -background white -foreground black \
3203 + -borderwidth 0 \
3204 + -width 20 -height 10 \
3205 + -wrap none \
3206 + -takefocus 1 -highlightthickness 1\
3207 + -cursor $cursor_ptr \
3208 + -xscrollcommand {.vpane.files.workdir.sx set} \
3209 + -yscrollcommand {.vpane.files.workdir.sy set} \
3210 + -state disabled
3211 +${NS}::scrollbar .vpane.files.workdir.sx -orient h -command [list $ui_workdir xview]
3212 +${NS}::scrollbar .vpane.files.workdir.sy -orient v -command [list $ui_workdir yview]
3213 +pack .vpane.files.workdir.title -side top -fill x
3214 +pack .vpane.files.workdir.sx -side bottom -fill x
3215 +pack .vpane.files.workdir.sy -side right -fill y
3216 +pack $ui_workdir -side left -fill both -expand 1
3217 +
3218 # -- Index File List
3219 #
3199 -${NS}::frame .vpane.files.index -height 100 -width 200
3220 +textframe .vpane.files.index -height 100 -width 200
3221 tlabel .vpane.files.index.title \
3222 -text [mc "Staged Changes (Will Commit)"] \
3223 -background lightgreen -foreground black
3203 -text $ui_index -background white -foreground black \
3224 +ttext $ui_index -background white -foreground black \
3225 -borderwidth 0 \
3226 -width 20 -height 10 \
3227 -wrap none \
@@ -3216,27 +3237,8 @@ pack .vpane.files.index.sx -side bottom -fill x
3237 pack .vpane.files.index.sy -side right -fill y
3238 pack $ui_index -side left -fill both -expand 1
3239
3219 -# -- Working Directory File List
3240 +# -- Insert the workdir and index into the panes
3241 #
3221 -${NS}::frame .vpane.files.workdir -height 100 -width 200
3222 -tlabel .vpane.files.workdir.title -text [mc "Unstaged Changes"] \
3223 - -background lightsalmon -foreground black
3224 -text $ui_workdir -background white -foreground black \
3225 - -borderwidth 0 \
3226 - -width 20 -height 10 \
3227 - -wrap none \
3228 - -takefocus 1 -highlightthickness 1\
3229 - -cursor $cursor_ptr \
3230 - -xscrollcommand {.vpane.files.workdir.sx set} \
3231 - -yscrollcommand {.vpane.files.workdir.sy set} \
3232 - -state disabled
3233 -${NS}::scrollbar .vpane.files.workdir.sx -orient h -command [list $ui_workdir xview]
3234 -${NS}::scrollbar .vpane.files.workdir.sy -orient v -command [list $ui_workdir yview]
3235 -pack .vpane.files.workdir.title -side top -fill x
3236 -pack .vpane.files.workdir.sx -side bottom -fill x
3237 -pack .vpane.files.workdir.sy -side right -fill y
3238 -pack $ui_workdir -side left -fill both -expand 1
3239 -
3242 .vpane.files add .vpane.files.workdir
3243 .vpane.files add .vpane.files.index
3244 if {!$use_ttk} {
@@ -3319,7 +3321,7 @@ if {![is_enabled nocommit]} {
3321 #
3322 ${NS}::frame .vpane.lower.commarea.buffer
3323 ${NS}::frame .vpane.lower.commarea.buffer.header
3322 -set ui_comm .vpane.lower.commarea.buffer.t
3324 +set ui_comm .vpane.lower.commarea.buffer.frame.t
3325 set ui_coml .vpane.lower.commarea.buffer.header.l
3326
3327 if {![is_enabled nocommit]} {
@@ -3362,20 +3364,25 @@ if {![is_enabled nocommit]} {
3364 pack .vpane.lower.commarea.buffer.header.new -side right
3365 }
3366
3365 -text $ui_comm -background white -foreground black \
3367 +textframe .vpane.lower.commarea.buffer.frame
3368 +ttext $ui_comm -background white -foreground black \
3369 -borderwidth 1 \
3370 -undo true \
3371 -maxundo 20 \
3372 -autoseparators true \
3373 + -takefocus 1 \
3374 + -highlightthickness 1 \
3375 -relief sunken \
3376 -width $repo_config(gui.commitmsgwidth) -height 9 -wrap none \
3377 -font font_diff \
3373 - -yscrollcommand {.vpane.lower.commarea.buffer.sby set}
3374 -${NS}::scrollbar .vpane.lower.commarea.buffer.sby \
3378 + -yscrollcommand {.vpane.lower.commarea.buffer.frame.sby set}
3379 +${NS}::scrollbar .vpane.lower.commarea.buffer.frame.sby \
3380 -command [list $ui_comm yview]
3376 -pack .vpane.lower.commarea.buffer.header -side top -fill x
3377 -pack .vpane.lower.commarea.buffer.sby -side right -fill y
3381 +
3382 +pack .vpane.lower.commarea.buffer.frame.sby -side right -fill y
3383 pack $ui_comm -side left -fill y
3384 +pack .vpane.lower.commarea.buffer.header -side top -fill x
3385 +pack .vpane.lower.commarea.buffer.frame -side left -fill y
3386 pack .vpane.lower.commarea.buffer -side left -fill y
3387
3388 # -- Commit Message Buffer Context Menu
@@ -3473,12 +3480,13 @@ bind_button3 .vpane.lower.diff.header.path "tk_popup $ctxm %X %Y"
3480
3481 # -- Diff Body
3482 #
3476 -${NS}::frame .vpane.lower.diff.body
3483 +textframe .vpane.lower.diff.body
3484 set ui_diff .vpane.lower.diff.body.t
3478 -text $ui_diff -background white -foreground black \
3485 +ttext $ui_diff -background white -foreground black \
3486 -borderwidth 0 \
3487 -width 80 -height 5 -wrap none \
3488 -font font_diff \
3489 + -takefocus 1 -highlightthickness 1 \
3490 -xscrollcommand {.vpane.lower.diff.body.sbx set} \
3491 -yscrollcommand {.vpane.lower.diff.body.sby set} \
3492 -state disabled
lib/themed.tcl
+86 -1
@@ -78,6 +78,57 @@ proc InitTheme {} {
78 }
79 }
80
81 +# Define a style used for the surround of text widgets.
82 +proc InitEntryFrame {} {
83 + ttk::style theme settings default {
84 + ttk::style layout EntryFrame {
85 + EntryFrame.field -sticky nswe -border 0 -children {
86 + EntryFrame.fill -sticky nswe -children {
87 + EntryFrame.padding -sticky nswe
88 + }
89 + }
90 + }
91 + ttk::style configure EntryFrame -padding 1 -relief sunken
92 + ttk::style map EntryFrame -background {}
93 + }
94 + ttk::style theme settings classic {
95 + ttk::style configure EntryFrame -padding 2 -relief sunken
96 + ttk::style map EntryFrame -background {}
97 + }
98 + ttk::style theme settings alt {
99 + ttk::style configure EntryFrame -padding 2
100 + ttk::style map EntryFrame -background {}
101 + }
102 + ttk::style theme settings clam {
103 + ttk::style configure EntryFrame -padding 2
104 + ttk::style map EntryFrame -background {}
105 + }
106 +
107 + # Ignore errors for missing native themes
108 + catch {
109 + ttk::style theme settings winnative {
110 + ttk::style configure EntryFrame -padding 2
111 + }
112 + ttk::style theme settings xpnative {
113 + ttk::style configure EntryFrame -padding 1
114 + ttk::style element create EntryFrame.field vsapi \
115 + EDIT 1 {disabled 4 focus 3 active 2 {} 1} -padding 1
116 + }
117 + ttk::style theme settings vista {
118 + ttk::style configure EntryFrame -padding 2
119 + ttk::style element create EntryFrame.field vsapi \
120 + EDIT 6 {disabled 4 focus 3 active 2 {} 1} -padding 2
121 + }
122 + }
123 +
124 + bind EntryFrame <Enter> {%W instate !disabled {%W state active}}
125 + bind EntryFrame <Leave> {%W state !active}
126 + bind EntryFrame <<ThemeChanged>> {
127 + set pad [ttk::style lookup EntryFrame -padding]
128 + %W configure -padding [expr {$pad eq {} ? 1 : $pad}]
129 + }
130 +}
131 +
132 proc gold_frame {w args} {
133 global use_ttk
134 if {$use_ttk} {
@@ -123,7 +174,7 @@ proc paddedlabel {w args} {
174 # place a themed frame over the surface.
175 proc Dialog {w args} {
176 eval [linsert $args 0 toplevel $w -class Dialog]
126 - catch {wm attributes $w -type dialog}
177 + catch {wm attributes $w -type dialog}
178 pave_toplevel $w
179 return $w
180 }
@@ -193,6 +244,40 @@ proc tspinbox {w args} {
244 }
245 }
246
247 +# Create a text widget with any theme specific properties.
248 +proc ttext {w args} {
249 + global use_ttk
250 + if {$use_ttk} {
251 + switch -- [ttk::style theme use] {
252 + "vista" - "xpnative" {
253 + lappend args -highlightthickness 0 -borderwidth 0
254 + }
255 + }
256 + }
257 + set w [eval [linsert $args 0 text $w]]
258 + if {$use_ttk} {
259 + if {[winfo class [winfo parent $w]] eq "EntryFrame"} {
260 + bind $w <FocusIn> {[winfo parent %W] state focus}
261 + bind $w <FocusOut> {[winfo parent %W] state !focus}
262 + }
263 + }
264 + return $w
265 +}
266 +
267 +# themed frame suitable for surrounding a text field.
268 +proc textframe {w args} {
269 + global use_ttk
270 + if {$use_ttk} {
271 + if {[catch {ttk::style layout EntryFrame}]} {
272 + InitEntryFrame
273 + }
274 + eval [linsert $args 0 ttk::frame $w -class EntryFrame -style EntryFrame]
275 + } else {
276 + eval [linsert $args 0 frame $w]
277 + }
278 + return $w
279 +}
280 +
281 proc tentry {w args} {
282 global use_ttk
283 if {$use_ttk} {