Tk Source Code

View Ticket
Login
Ticket UUID: 3003895
Title: improved range for Scale widget
Type: Bug Version: None
Submitter: ttischler Created on: 2010-05-19 07:41:28
Subsystem: 15. [scale] Assigned To: fvogel
Priority: 5 Medium Severity: Minor
Status: Closed Last Modified: 2019-01-26 13:34:26
Resolution: Fixed Closed By: fvogel
    Closed on: 2019-01-26 13:34:26
Description:
The current Scale widget isn't able to display a range starting with 1 and having a resolution of 2. Instead the "-from" value is rounded to be a multiple of the "-resolution".

Example:
pack [scale .s -orient hor -from 1 -to 9 -resolution 2 -tickinterval 1] -fill x

The attached diffs contain all changes necessary to fix this odd behaviour. It's a diff for Tk 8.5.8, tkScale.c and tkScale.h.
The "TkRoundToResolution" function has to be updated and "TkRoundTickToResolution" is introduced. The first one now refers to the "-from" value, too, and the latter is needed to round the "-tickinterval" without any reference to this value.
User Comments: fvogel added on 2019-01-26 13:34:26:
Merged to core-8-6-branch and trunk.

fvogel added on 2019-01-13 14:37:45:

Better fix committed [83c7e670]. All tests now pass in the bugfix branch.


fvogel added on 2019-01-09 22:10:47:

Should probably study [5e295d879b98ead5] (the changes in scale.c)


fvogel added on 2019-01-09 22:04:31:

Test scale-14.13 that I have just added reveals that the proposed fix unfortunately resurrects [220665ffff], and duplicates [220265ffff] and [779559ffff].

This needs further work.


fvogel added on 2019-01-06 09:38:14:
The completed scale.test passes 100% OK on Linux Debian 8 and macOS 10.14.2 Mojave as well as on Windows Vista.

fvogel added on 2019-01-05 21:00:37:

I have committed a fix in a bugfix branch that is largely inspired by your proposal, and I have added two new tests.

This all passes scale.test 100% OK (tested on Windows).


ttischler added on 2010-05-19 14:45:31:
Because I couldn't find a way to upload a second file, here's the diff-content for the header file.

--- tkScale.h2005-11-26 20:36:14.000000000 +0100
+++ tkScale.h2010-05-18 15:40:33.281250000 +0200
@@ -233,6 +233,7 @@
 
 MODULE_SCOPE voidTkEventuallyRedrawScale(TkScale *scalePtr, int what);
 MODULE_SCOPE doubleTkRoundToResolution(TkScale *scalePtr, double value);
+MODULE_SCOPE doubleTkRoundTickToResolution(TkScale *scalePtr, double value);
 MODULE_SCOPE TkScale *TkpCreateScale(Tk_Window tkwin);
 MODULE_SCOPE voidTkpDestroyScale(TkScale *scalePtr);
 MODULE_SCOPE voidTkpDisplayScale(ClientData clientData);

ttischler added on 2010-05-19 14:41:28:

File Added - 374397: tkScale.c.diff

Attachments: