Tk Source Code

Check-in [83c7e670]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fix [3003895fff] and [1899040fff] with a different fix, this time it does not resurrect [220665ffff] or duplicates [220265ffff] [779559ffff]. All scale.test tests do pass now.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | bug-3003895fff | bug-1899040fff
Files: files | file ages | folders
SHA3-256:83c7e670313b24eaa95c706534a29ab099914856e50953317752353d0075e2e7
User & Date: fvogel 2019-01-13 14:35:13
References
2019-01-13
14:37 Ticket [3003895f] improved range for Scale widget status still Open with 5 other changes artifact: 4a28c8db user: fvogel
Context
2019-01-26
13:30
Fix [3003895fff] and [1899040fff]: TkRoundToResolution doesn't account for -from check-in: 194e4313 user: fvogel tags: core-8-6-branch
2019-01-13
14:35
Fix [3003895fff] and [1899040fff] with a different fix, this time it does not resurrect [220665ffff] or duplicates [220265ffff] [779559ffff]. All scale.test tests do pass now. Closed-Leaf check-in: 83c7e670 user: fvogel tags: bug-3003895fff, bug-1899040fff
2019-01-09
21:58
Add new test scale-14.13 to guard against regressions with [220665ffff], and duplicates [220265ffff] and [779559ffff]. This test currently fails in the present bugfix branch but passes in core-8-6-branch check-in: 497ab896 user: fvogel tags: bug-3003895fff, bug-1899040fff
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to generic/tkScale.c.

1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168


1169
1170

1171

1172




1173
1174
1175
1176
1177
1178
1179
 */

double
TkRoundValueToResolution(
    TkScale *scalePtr,		/* Information about scale widget. */
    double value)		/* Value to round. */
{
    double rem, start;

    if (scalePtr->resolution <= 0) {
	return value;
    }
    start = fmod(scalePtr->fromValue, scalePtr->resolution);
    rem = fmod(value - start + scalePtr->resolution/2, scalePtr->resolution);
    if (rem < 0) {
        rem += scalePtr->resolution;
    }
    return value + scalePtr->resolution/2 - rem;
}

double
TkRoundIntervalToResolution(
    TkScale *scalePtr,		/* Information about scale widget. */
    double value)		/* Value to round. */
{
    double rem;

    if (scalePtr->resolution <= 0) {
	return value;
    }
    rem = fmod(value + scalePtr->resolution/2, scalePtr->resolution);


    if (rem < 0) {
        rem += scalePtr->resolution;

    }

    return value + scalePtr->resolution/2 - rem;




}
 
/*
 *----------------------------------------------------------------------
 *
 * ScaleVarProc --
 *







|
<
<
<
<
|
<
<
<
<
<







|




|
>
>

|
>
|
>
|
>
>
>
>







1138
1139
1140
1141
1142
1143
1144
1145




1146





1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
 */

double
TkRoundValueToResolution(
    TkScale *scalePtr,		/* Information about scale widget. */
    double value)		/* Value to round. */
{
    return TkRoundIntervalToResolution(scalePtr, value - scalePtr->fromValue)




            + scalePtr->fromValue;





}

double
TkRoundIntervalToResolution(
    TkScale *scalePtr,		/* Information about scale widget. */
    double value)		/* Value to round. */
{
    double rem, rounded, tick;

    if (scalePtr->resolution <= 0) {
	return value;
    }
    tick = floor(value/scalePtr->resolution);
    rounded = scalePtr->resolution * tick;
    rem = value - rounded;
    if (rem < 0) {
        if (rem <= -scalePtr->resolution/2) {
            rounded = (tick - 1.0) * scalePtr->resolution;
        }
    } else {
        if (rem >= scalePtr->resolution/2) {
            rounded = (tick + 1.0) * scalePtr->resolution;
        }
    }
    return rounded;
}
 
/*
 *----------------------------------------------------------------------
 *
 * ScaleVarProc --
 *