Tk Source Code

View Ticket
Login
Ticket UUID: f20f46b90ac6fa9d6e4fd1ea8ab2412078a29206
Title: following widgets need scaling: checkbutton, radiobutton, alt theme: ttk::checkbutton, ttk::radiobutton, ttk::sizegrip (all themes)
Type: Bug Version: main
Submitter: oehhar Created on: 2022-12-22 17:25:22
Subsystem: 02. Appearance Assigned To: nobody
Priority: 5 Medium Severity: Minor
Status: Closed Last Modified: 2023-02-11 20:01:01
Resolution: Fixed Closed By: nemethi
    Closed on: 2023-02-11 20:01:01
Description: (text/x-fossil-wiki)
The following information by Csaba in [e9622302] is not solved.

So copy it to this ticket to not forget it. It is probably a long term bug for later fixing...

Csaba:

Unfortunately, the indicators of the Tk core checkbuttons and radiobuttons are not scalable.  Nor are the indicators of the ttk::checkbutton and ttk::radiobutton widgets of the alt theme.  This problem can only be solved by reworking the C code in such a way that the sizes of the indicators become dynamic (depending on [tk scaling]) or configurable via a new option, say, -indicatorsize (in which case the scaling could be implemented via Tcl code, like for the themes clam, classic, and default).

Same problem regarding the ttk::sizegrip widget.
User Comments: nemethi (claiming to be Csaba Nemethi) added on 2023-02-11 20:01:01:
IMHO, this bug is now fixed.  Closing the ticket.

nemethi (claiming to be Csaba Nemethi) added on 2023-02-09 14:27:42:
UPDATE: After merging the branch "scaling-aware-classic-simple" into trunk, I have found a visual artifact related to the winnative theme.  This is now eliminated.  In addition, the ttk::sizegrip widget is now scaling-aware (it will scale automatically according to the display's scaling percentage).

nemethi (claiming to be Csaba Nemethi) added on 2023-02-07 09:17:05:
UPDATE regarding the branch "scaling-aware-classic-simple":

1. In the file library/scaling.tcl the variable ::tk::scalingPct is no longer read-only (thanks to Brian for discussions on this subject).

2. The Tk core checkbutton and radiobutton indicators on Windows and the ones of the winnative theme are now scaling-aware.

IMHO, the work on the scalability of the GUI in Tk 8.7 can now be viewed as completed.  Many thanks again to Brian and Jan for the fruitful collaboration!  The only remaining step is to merge this branch into trunk.  Being that all the tests on github have been successful, I think now it is time for this finishing step.  I am going to do the merge very soon.

nemethi (claiming to be Csaba Nemethi) added on 2023-02-02 15:27:48:
UPDATE: As a result of merging trunk into this branch, the file unix/tkUnixButton.c has become identical to its version in trunk, hence the SVG images used for the indicators of the Tk core checkbuttons and radiobuttons now have the same 3D look rather than the former "simple", solid border.

nemethi (claiming to be Csaba Nemethi) added on 2023-01-31 20:10:21:
UPDATE: In the branch "scaling-aware-classic-simple" the indicators of the ttk::checkbutton and ttk::radiobutton widgets of the alt theme (on all windowing systems) are now scaling-aware.  The version of the file generic/ttk/ttkDefaultTheme.c (!) just committed uses SVG images that preserve the alt theme specific 3D look of the indicators.

nemethi (claiming to be Csaba Nemethi) added on 2023-01-28 16:45:56:
The goal of that commit by Jan was to make  it possible to use screen distances  in points rather than [::tk::ScaleNum ...] invocations when making the Tk and Ttk widgets scaling-aware.  In the course of this action Jan has also fixed a very long-standing and annoying bug on macOS Aqua: one point was the same as one pixel, unlike on X11 and Windows, where on an unscaled, 96 DPI screen, one pixel corresponds to 0.75 points.  When doing this, he had to make a few changes in the file macosx/tkMacOSXFont.c, too.  Yes, the price of this bug-fix is a visual incompatibility between Tk 8.7b1 and earlier Tk versions on macOS Aqua.  This was surely not intended, but could not be avoided.  I am pretty sure that this cannot be viewed as transient until the work is finished.

fvogel added on 2023-01-28 08:19:20: (text/x-fossil-wiki)
We have a report [6354963816] about TkTextFont size changes having implications in the user application. These changes were triggered by [f7faa6e9d9] referring to the present ticket; this commit log says the work is not finished but nevertheless: was such a change intended? Is it perhaps transient until the work, precisely, is finished?

nemethi (claiming to be Csaba Nemethi) added on 2023-01-26 09:48:29:
CORRECTION: The indicators of the ttk::checkbutton and ttk::radiobutton widgets *of the alt theme* (on all windowing systems) are still not scaling-aware. ...

UPDATE: Brian has now merged the implementation of the Tk core checkbutton and radiobutton indicators and their counterparts for the menu entries from his branch "scaling-aware-classic-buttons" into trunk.  This is the same code as the one in the branch "scaling-aware-classic-simple", but Brian uses 3D indicator images, while mine are ones derived from some Bootstrap icons and have solid borders.  The common code logic is the result of an intensive and really fruitful collaboration between Brian and myself, for which I am very grateful.

nemethi (claiming to be Csaba Nemethi) added on 2023-01-24 13:31:56:
Brian was kind enough to open a new branch named "scaling-aware-classic-simple" and to push my version of unix/tkUnixButton.c to it, after carefully testing the implementation.  This file version makes the indicators of the ttk::checkbutton and ttk::radiobutton widgets as well as their counterparts for menu entries scaling-aware on X11.

My latest commit on this branch makes the following changes:

1. In the file library/scaling.tcl the variable ::tk::scalingPct is now read-only.  This makes the places in C modules where the value of this variable is being retrieved simpler, becouse they no longer need to check whether the variable exists and contains a positive integer (100, 125, 150, etc.).

2. In the file library/ttk/ttk.tcl the procedure ::ttk::SetTreeviewRowHeight was renamed to ::ttk::setTreeviewRowHeight and moved into the group of "Public API" procs (like ::ttk::themes and ::ttk::setTheme).  Its new placement has made it possible to invoke it in the files altTheme.tcl, clamTheme, etc. in the directory library/ttk.

3. The above-mentioned theme-settings files now contain an invocation of ::ttk::setTreeviewRowHeight and make a few further treeview-related styling options (like -indent, -indicatorsize/-diameter, and -indicatormargins) scaling-aware.

4. In the file generic/ttk/ttkTreeview.c the value of the -indent option is now retrieved via Tk_GetPixelsFromObj() rather than Tcl_GetIntFromObj().  This has made it possible to set the value of this styling option in points rather than pixels.

5. The file unix/tkUnixMenu.c now makes the cascade arrows of the menu entries on X11 scaling-aware if the variable ::tk::scalingPct exists.  Since this change is backwards-compatible, the new file version can be used not only in Tk 8.7 but also in Tk 8.6 and 8.5.


I think on X11 now pretty everything has become scaling-aware.

The indicators of the ttk::checkbutton and ttk::radiobutton widgets (on all windowing systems) are still not scaling-aware.  I have got a fully tested implementation that makes them scaling-aware, but haven't published it (yet), because it makes these indicators look just like their Tk core counterparts, and I am not sure whether this is allowed/accepted or not.

Last night Brian also made a commit, on the branch "scaling-aware-classic-buttons".  His implementation of Tk core checkbutton and radiobutton indicators is now basically identical to mine (in the "scaling-aware-classic-simple" branch), but his SVG images differ.

The Tk core checkbutton and radiobutton indicators on Windows and the ones of the winnative theme are still not scaling-aware.  Maybe someone more proficient in the Windows stuff can examine what could be done in this respect.

oehhar added on 2023-01-12 11:36:16: (text/x-fossil-wiki)
Please see related work in the following branches:

   *   Scaling classic check/radio buttons: Checkin [7936086d] Branch [scaling-aware-classic-buttons]
   *   Slider sash sizing is done by changing the -gripcount implying, that there are two pixels per count (line of 1 pixels size). It would be great to use -gripsize: Checkin [5e436848] Branch [gripsize].

Thanks to Brian and Jan for this great work !

nemethi (claiming to be Csaba Nemethi) added on 2022-12-22 20:16:15:
Update: The indicators of the ttk::checkbutton and ttk::radiobutton widgets of the winnative theme are not scalable either.