From dc3a071d220482ed8cccb89da7870de15a527d88 Mon Sep 17 00:00:00 2001 From: csaba Date: Fri, 6 Oct 2023 17:03:54 +0000 Subject: Visual improvements regarding the focus ring around the ttk::combobox and ttk::spinbox widgets of the themes "alt" and "clam". --- generic/ttk/ttkDefaultTheme.c | 25 ++++++++++++++++++++----- generic/ttk/ttkElements.c | 7 +++++++ library/ttk/clamTheme.tcl | 4 ++-- 3 files changed, 29 insertions(+), 7 deletions(-) diff --git a/generic/ttk/ttkDefaultTheme.c b/generic/ttk/ttkDefaultTheme.c index f4795c8..e9f001a 100644 --- a/generic/ttk/ttkDefaultTheme.c +++ b/generic/ttk/ttkDefaultTheme.c @@ -377,21 +377,36 @@ static void FieldElementDraw( int y1 = b.y, y2 = b.y + b.height - 1; int w = WIN32_XDRAWLINE_HACK; + /* + * Draw the outer rounded rectangle + */ XDrawLine(disp, d, focusGC, x1+1, y1, x2-1+w, y1); /* N */ XDrawLine(disp, d, focusGC, x1+1, y2, x2-1+w, y2); /* S */ XDrawLine(disp, d, focusGC, x1, y1+1, x1, y2-1+w); /* W */ XDrawLine(disp, d, focusGC, x2, y1+1, x2, y2-1+w); /* E */ + + /* + * Draw the inner rectangle + */ + b.x += 1; b.y += 1; b.width -= 2; b.height -= 2; + XDrawRectangle(disp, d, focusGC, b.x, b.y, b.width-1, b.height-1); } else { + /* + * Draw the outer rectangle + */ + XDrawRectangle(disp, d, focusGC, b.x, b.y, b.width-1, b.height-1); + + /* + * Draw the inner border + */ GC borderGC = Tk_GCForColor(borderColor, d); + b.x += 1; b.y += 1; b.width -= 2; b.height -= 2; DrawCorner(tkwin, d, border, borderGC, - b.x, b.y, b.width, b.height, 0, DARK); + b.x, b.y, b.width, b.height, 0, BRDR); DrawCorner(tkwin, d, border, borderGC, - b.x, b.y, b.width, b.height, 1, DARK); + b.x, b.y, b.width, b.height, 1, LITE); } - b.x += 1; b.y += 1; b.width -= 2; b.height -= 2; - XDrawRectangle(disp, d, focusGC, b.x, b.y, b.width-1, b.height-1); - GC bgGC = Tk_3DBorderGC(tkwin, border, TK_3D_FLAT_GC); XFillRectangle(disp, d, bgGC, b.x+1, b.y+1, b.width-2, b.height-2); } else { diff --git a/generic/ttk/ttkElements.c b/generic/ttk/ttkElements.c index 0cb34a4..bbe5a95 100644 --- a/generic/ttk/ttkElements.c +++ b/generic/ttk/ttkElements.c @@ -247,6 +247,9 @@ static void FieldElementDraw( int y1 = b.y, y2 = b.y + b.height - 1; int w = WIN32_XDRAWLINE_HACK; + /* + * Draw the outer rounded rectangle + */ XDrawLine(disp, d, focusGC, x1+1, y1, x2-1+w, y1); /* N */ XDrawLine(disp, d, focusGC, x1+1, y2, x2-1+w, y2); /* S */ XDrawLine(disp, d, focusGC, x1, y1+1, x1, y2-1+w); /* W */ @@ -255,6 +258,10 @@ static void FieldElementDraw( b.x += 1; b.y += 1; b.width -= 2; b.height -= 2; } + /* + * If focusWidth > 1 then draw the inner rectangle, + * else the only one replacing the (outer) border + */ XDrawRectangle(disp, d, focusGC, b.x, b.y, b.width-1, b.height-1); GC bgGC = Tk_3DBorderGC(tkwin, border, TK_3D_FLAT_GC); diff --git a/library/ttk/clamTheme.tcl b/library/ttk/clamTheme.tcl index 800deb9..efe98b0 100644 --- a/library/ttk/clamTheme.tcl +++ b/library/ttk/clamTheme.tcl @@ -110,7 +110,7 @@ namespace eval ttk::theme::clam { readonly $colors(-frame)] \ -foreground [list {readonly focus} $colors(-selectfg)] \ -arrowcolor [list disabled $colors(-disabledfg)] \ - -fieldlightcolor [list focus $colors(-selectbg)] + -bordercolor [list focus $colors(-selectbg)] ttk::style configure ComboboxPopdownFrame \ -relief solid -borderwidth 1 @@ -118,7 +118,7 @@ namespace eval ttk::theme::clam { ttk::style map TSpinbox \ -background [list readonly $colors(-frame)] \ -arrowcolor [list disabled $colors(-disabledfg)] \ - -fieldlightcolor [list focus $colors(-selectbg)] + -bordercolor [list focus $colors(-selectbg)] ttk::style configure TNotebook.Tab -padding {4.5p 1.5p 4.5p 1.5p} ttk::style map TNotebook.Tab \ -- cgit v0.12