Skip to content

Commit

Permalink
Change the -elementborderwidth default (for scrollbar) from -1 to {}.…
Browse files Browse the repository at this point in the history
… Move sanity check from platform-code to generic. See TIP #577.
  • Loading branch information
jan.nijtmans committed Jun 17, 2024
1 parent a57ef5a commit b8b8de5
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 15 deletions.
4 changes: 2 additions & 2 deletions doc/scrollbar.n
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ as described in \fBSCROLLING COMMANDS\fR below.
Specifies the width of borders drawn around the internal elements
of the scrollbar (the two arrows and the slider). The value may
have any of the forms acceptable to \fBTk_GetPixels\fR.
If this value is less than zero, the value of the \fB\-borderwidth\fR
option is used in its place.
If this value is the empth string (the default), the value of
the \fB\-borderwidth\fR option is used in its place.
.OP \-width width Width
Specifies the desired narrow dimension of the scrollbar window,
not including 3-D border, if any. For vertical
Expand Down
8 changes: 7 additions & 1 deletion generic/tkScrollbar.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ Tk_ScrollbarObjCmd(
scrollPtr->highlightBgColorPtr = NULL;
scrollPtr->highlightColorPtr = NULL;
scrollPtr->inset = 0;
scrollPtr->elementBorderWidth = -1;
scrollPtr->elementBorderWidth = INT_MIN;
scrollPtr->arrowLength = 0;
scrollPtr->sliderFirst = 0;
scrollPtr->sliderLast = 0;
Expand Down Expand Up @@ -487,6 +487,12 @@ ConfigureScrollbar(
} else {
scrollPtr->commandSize = 0;
}
if (scrollPtr->highlightWidth < 0) {
scrollPtr->highlightWidth = 0;
}
if (scrollPtr->elementBorderWidth < 0) {
scrollPtr->elementBorderWidth = INT_MIN;
}

/*
* Configure platform specific options.
Expand Down
2 changes: 1 addition & 1 deletion macosx/tkMacOSXDefault.h
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@
#define DEF_SCROLLBAR_BORDER_WIDTH "0"
#define DEF_SCROLLBAR_COMMAND ""
#define DEF_SCROLLBAR_CURSOR ""
#define DEF_SCROLLBAR_EL_BORDER_WIDTH "-1"
#define DEF_SCROLLBAR_EL_BORDER_WIDTH NULL
#define DEF_SCROLLBAR_HIGHLIGHT_BG NORMAL_BG
#define DEF_SCROLLBAR_HIGHLIGHT NORMAL_FG
#define DEF_SCROLLBAR_HIGHLIGHT_WIDTH "0"
Expand Down
4 changes: 2 additions & 2 deletions macosx/tkMacOSXScrlbr.c
Original file line number Diff line number Diff line change
Expand Up @@ -649,8 +649,8 @@ UpdateControlValues(
|| height <= metrics.minHeight) {
msPtr->info.enableState = kThemeTrackHideTrack;
} else {
msPtr->info.enableState = kThemeTrackActive;
msPtr->info.attributes =
msPtr->info.enableState = kThemeTrackActive;
msPtr->info.attributes =
kThemeTrackShowThumb | kThemeTrackThumbRgnIsNotGhost;
}
}
Expand Down
2 changes: 1 addition & 1 deletion unix/tkUnixDefault.h
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@
#define DEF_SCROLLBAR_BORDER_WIDTH "1"
#define DEF_SCROLLBAR_COMMAND ""
#define DEF_SCROLLBAR_CURSOR ""
#define DEF_SCROLLBAR_EL_BORDER_WIDTH "-1"
#define DEF_SCROLLBAR_EL_BORDER_WIDTH NULL
#define DEF_SCROLLBAR_HIGHLIGHT_BG NORMAL_BG
#define DEF_SCROLLBAR_HIGHLIGHT BLACK
#define DEF_SCROLLBAR_HIGHLIGHT_WIDTH "0"
Expand Down
3 changes: 0 additions & 3 deletions unix/tkUnixScrlbr.c
Original file line number Diff line number Diff line change
Expand Up @@ -283,9 +283,6 @@ TkpComputeScrollbarGeometry(
{
int width, fieldLength;

if (scrollPtr->highlightWidth < 0) {
scrollPtr->highlightWidth = 0;
}
scrollPtr->inset = scrollPtr->highlightWidth + scrollPtr->borderWidth;
width = (scrollPtr->vertical) ? Tk_Width(scrollPtr->tkwin)
: Tk_Height(scrollPtr->tkwin);
Expand Down
2 changes: 1 addition & 1 deletion win/tkWinDefault.h
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@
#define DEF_SCROLLBAR_BORDER_WIDTH "0"
#define DEF_SCROLLBAR_COMMAND ""
#define DEF_SCROLLBAR_CURSOR ""
#define DEF_SCROLLBAR_EL_BORDER_WIDTH "-1"
#define DEF_SCROLLBAR_EL_BORDER_WIDTH NULL
#define DEF_SCROLLBAR_HIGHLIGHT_BG NORMAL_BG
#define DEF_SCROLLBAR_HIGHLIGHT HIGHLIGHT
#define DEF_SCROLLBAR_HIGHLIGHT_WIDTH "0"
Expand Down
4 changes: 0 additions & 4 deletions win/tkWinScrlbr.c
Original file line number Diff line number Diff line change
Expand Up @@ -394,10 +394,6 @@ TkpComputeScrollbarGeometry(
* basic sanity checks to appease backwards compatibility.
*/

if (scrollPtr->highlightWidth < 0) {
scrollPtr->highlightWidth = 0;
}

if (scrollPtr->vertical) {
scrollPtr->arrowLength = vArrowHeight;
fieldLength = Tk_Height(scrollPtr->tkwin);
Expand Down

0 comments on commit b8b8de5

Please sign in to comment.