| Ticket UUID: | 3217462 | |||
| Title: | Tri-state buttons not working for non-native themes | |||
| Type: | Bug | Version: | None | |
| Submitter: | auriocus | Created on: | 2011-03-16 21:33:53 | |
| Subsystem: | 88. Themed Tk | Assigned To: | fvogel | |
| Priority: | 6 | Severity: | Minor | |
| Status: | Closed | Last Modified: | 2016-10-12 19:31:59 | |
| Resolution: | Fixed | Closed By: | fvogel | |
| Closed on: | 2016-10-12 19:31:59 | |||
| Description: |
ttk::checkbutton and ttk::radiobutton are supposed to show an undetermined state, when the associated variable is unset. For native themes under windows and macosx, this works fine. For non-native themes, the buttons switch to the alternate state, but there is no visual difference. On X11, every possible theme is affected (all are non-native). The attached script shows the problem | |||
| User Comments: |
fvogel added on 2016-10-12 19:31:59:
Merged in core-8-6-branch and trunk. fvogel added on 2016-10-07 17:49:18: Thanks for having checked. That's great! I'll merge to 8.6 and trunk branches in a few days, so that other people can still chime in if they want to. For the records I have attached a snapshot of the quadstate demo script running on Windows Seven. anonymous (claiming to be auriocus) added on 2016-10-06 20:34:44: The latest checkin seems to resolve all problems. Here is a screenshot of the demo script running on OSX. fvogel added on 2016-10-05 15:49:39: Latest changes are as follows, taking your comments into account (please state whether you believe it's OK this time): 'classic' and 'default': changed according to your feedback below. The 'alternate' (aka '3state') state is visually different from the 'selected' (aka 'on') and 'off' states. Also 'alternate' and 'alternate selected' now render the same. Done through [ba987ba676]. xpnative, vista: for radiobuttons only, 'alternate on' (aka 'alternate selected') changed to be identical to 'alternate' (and off), as requested. Done through [1d812ee94d]. Note: 'aqua' should now also be OK by this latter change but I cannot check since I don't have a hand on that platform. winnative: yes, alternate looks like 'disabled on', but it's easy to make the difference between them because the font of the label is greyed outfor disabled, which is not the case for the enabled state. So no change needed here. clam: changed for a darker blue for the inside of the box in alternate state, as requested. Done through [fb6dac09bb]. alt: no change made, I think it is good enough. alt,clam: yes, the checkbox is drawn from C code. This is done by CheckIndicatorElementDraw() in generic\ttk\ttkClamTheme.c for the 'clam' theme, and by IndicatorElementDraw() in generic\ttk\ttkDefaultTheme.c for the 'alt' theme. I didn't make any changes in the way these checkboxes are drawn. fvogel added on 2016-10-05 06:16:26: Snapshot of each theme rendered on Vista, as generated by source dated 29 Sept. 2016, now attached to this ticket: see ThemeSnapsVista160929.png Comments on this from Christian are as follows (from tcl-core list), I think they describe the remaining work to do on this: Christian Gollwitzer a écrit le 04/10/2016 à 15:33 : > Am 29.09.16 um 08:12 schrieb Francois Vogel: >> Christian Gollwitzer a écrit le 27/09/2016 à 23:38 : >>> With the attached script you can see all 8 possible states composed by >>> the combination of selected, alternate, disabled. On aqua, "selected >>> 3state" and "3state" look identical, which is - I think - the correct >>> behaviour. So please check using that script, that it works with your >>> fixes now as expected. >> >> It's not the case for me, at least not on Vista and for all "non-native" >> themes, i.e. classic, default, clam, alt. So the spec is: "'3state' and >> '3state selected' shall look the same for all themes (and no change for >> the rest of the states)" ? >> >> Not sure it's so clear. > > Well at least all other toolkits/UIs only have one "alternate" state and > do not distinguish between alternate/selected and alternate/!selected, > as ttk does. It is definitely wrong, if one of the alternate states > looks the same as one of the !altenate states, as is the case in your > screenshot: > > classic: "alternate on" looks like "on" > > default: all are different, but "alternate on" looks wrong to me (should > be depressed and light blue) > > xpnative, vista, (& aqua on my system): Both alternate look the same, > but different from on or off, whch is OK for me, since the native > toolkits do not provide a difference for on/off in alternate state. The > radio buttons are wrong, though: If they can't be drawn in an alternate > state, then all radios of a group should be deselected - alternate > selected should show as "not selected" > > winnative: alternate looks like disabled/on, maybe this is it in this > design. It's an old theme that shouldn't be used anyway IMHO > > alt, clam: Shows different states for all, and basically looks good to > me, if only the checkmark could be lighter in the alternate state. It > may be hard to spot the blue background when the checkmark is there. > Maybe a slightly daker blue would do. How is the checkmark drawn? It is > not clear to me. Is this in the C code? fvogel added on 2016-09-28 19:20:52: Test file "quadstate.tcl" from the OP now attached to this ticket. fvogel added on 2016-09-25 19:22:45: I have made a proposal for the alt and classic themes, see [32275e17] (and how it renders using the 'tristate.tcl' demo script attached to the present ticket. fvogel added on 2016-09-24 21:40:08: Many thanks for the clear explanation. So we simply can't have a fix (i.e. we can't make the off and 3state of radiobuttons look visually different) for the "xpnative" and "vista" themes. Last remaining thing to do then is to propagate the now existing fix for the "clam" and "default" themes to the "alt" and "classic" themes. I would happily proceed as soon as someone tells me what colors I should use: patthoyts added on 2016-09-24 20:50:16: The windows native themes 'xpnative' and 'vista' draw widgets using elements provided by the Windows Styles theming engine. So for a checkbutton for instance, we ask the native theme engine to draw its visual element with appropriate flags to specify the state, at the given location. So for these themes, selecting the unselected checkbutton state is a matter of passing the correct state flag. This mapping of ttk element state to Windows Styles flags is done in ttkWinXPTheme.c and may be overridden in the library tcl files by creating vsapi elements. (We added the vsapi element engine later, so the xp theme still is defined in C rather than in tcl). See the checkbox_statemap. For checkbuttons, we have CBS_MIXEDNORMAL and friends so possibly we should be using some RBS_MIXED* flags in the radio button case. However, I can see why we didn't add this at the time as the old TmsSchema.h file from Microsoft has the following definitions for checkboxes and radiobutton elements. In more recent releases its defined in vssym32.h I think.
BEGIN_TM_PART_STATES(RADIOBUTTON)
TM_STATE(1, RBS, UNCHECKEDNORMAL)
TM_STATE(2, RBS, UNCHECKEDHOT)
TM_STATE(3, RBS, UNCHECKEDPRESSED)
TM_STATE(4, RBS, UNCHECKEDDISABLED)
TM_STATE(5, RBS, CHECKEDNORMAL)
TM_STATE(6, RBS, CHECKEDHOT)
TM_STATE(7, RBS, CHECKEDPRESSED)
TM_STATE(8, RBS, CHECKEDDISABLED)
END_TM_PART_STATES()
BEGIN_TM_PART_STATES(CHECKBOX)
TM_STATE(1, CBS, UNCHECKEDNORMAL)
TM_STATE(2, CBS, UNCHECKEDHOT)
TM_STATE(3, CBS, UNCHECKEDPRESSED)
TM_STATE(4, CBS, UNCHECKEDDISABLED)
TM_STATE(5, CBS, CHECKEDNORMAL)
TM_STATE(6, CBS, CHECKEDHOT)
TM_STATE(7, CBS, CHECKEDPRESSED)
TM_STATE(8, CBS, CHECKEDDISABLED)
TM_STATE(9, CBS, MIXEDNORMAL)
TM_STATE(10, CBS, MIXEDHOT)
TM_STATE(11, CBS, MIXEDPRESSED)
TM_STATE(12, CBS, MIXEDDISABLED)
END_TM_PART_STATES()
'winnative' is similar but doesn't use the Windows Styles API but uses the old GDI functions to draw frames etc. This is still the native drawing methods but the really old set that are unthemed.
fvogel added on 2016-09-24 18:46:03:
Remaining TODOs:
fvogel added on 2016-09-24 18:33:40: The problem you had, Christian, is that you overlooked that tiny line in the ttk::style map man page: Each statespec / value pair is examined in order; the value corresponding to the first matching statespec is used. In this very good ttk tutorial, there is a note clarifying even more: Because widget states can contain multiple flags, it's possible that more than one state will match for an option (e.g. "pressed" and "pressed !disabled" will both match if the widget's "pressed" state flag is set). The list of states is evaluated in the order you provide in the map command, with the first state in the list that matches being used. I have changed the order and it works now for clam, see [3a56e2e3]. fvogel added on 2016-09-24 06:59:16: Here is the status theme by theme, based on the script 'tristate.tcl' provided as an attachement to this ticket. Status with the patch [71c6b472] in branch [bug-3217462], as I see it on my Windows Vista box: xpnative and vista: all items in the dialog are visually different, except the following which look identical: "Radio off" same as "Radio 3state" "Radio disabled off" same as "Radio disabled 3state" winnative, default: all different --> OK classic, alt: all different, except: "Check off" same as "Check 3state" "Check disabled off" same as "Check disabled 3state" "Radio off" same as "Radio 3state" "Radio disabled off" same as "Radio disabled 3state" clam: all different, except: "Check disabled off" same as "Check disabled 3state" "Radio disabled off" same as "Radio disabled 3state" So it seems there is still quite some work to do before fully fixing that bug. patthoyts added on 2016-09-22 15:32:12: Patch [71c6b472] fixes clam and default but 'alt' and 'classic' also need the same sort of fix. 'winnative','vista' and 'xpnative' are ok. oehhar added on 2016-09-21 08:34:58: The original ticket on sourceforge has the ticket number 2887: https://sourceforge.net/p/tktoolkit/bugs/2887/ oehhar added on 2016-09-21 08:33:35: Patch by commit [71c6b472] in branch [bug-3217462] auriocus added on 2012-11-24 18:08:50: I have made a patch to implement the changes as suggested by Jeff Hobbs. The test script was also updated to show all 6 possible widget states: Checkeed, unchecked, and alternate state, at both enabled and disabled states. All of these are cleary distinguishable under the native aqua theme, but fail to be distinguished under the Tk drawn themes, For the default theme, I'm pretty confident with the solution as-is. But for clam, I was not able to set a different style for the disabled alternate state. Moreover, I could not understand how the checkmark is drawn - I expected to see some bitmap embedded in the style code. This way, one could draw a different symbol analogous to aqua for the themes with checkmarks, i.e. alt and clam. auriocus added on 2012-11-24 18:04:37: File Added - 456935: screenshot-patched.png auriocus added on 2012-11-24 18:03:57: File Added - 456934: patch3state-default-and-clam.patch auriocus added on 2012-11-24 18:03:33: File Added - 456933: tristate.tcl auriocus added on 2011-03-17 04:45:23: File Added - 404562: screenshot-osx.png auriocus added on 2011-03-17 04:33:54: File Added - 404560: tristate.tcl | |||
Attachments:
- ThemeSnapsSeven161007.png [download] added by fvogel on 2016-10-07 17:52:13. [details]
- Screenshot-1d812ee9-OSX.png [download] added by anonymous on 2016-10-06 20:36:14. [details]
- ThemeSnapsVista160929.png [download] added by fvogel on 2016-10-05 06:11:20. [details]
- quadstate.tcl [download] added by fvogel on 2016-09-28 19:20:21. [details]
- screenshot-patched.png [download] added by oehhar on 2016-09-22 15:57:39. [details]
- screenshot-osx.png [download] added by oehhar on 2016-09-22 15:56:56. [details]
- patch3state-default-and-clam.patch [download] added by auriocus on 2012-11-24 18:03:57. [details]
- tristate.tcl [download] added by auriocus on 2012-11-24 18:03:33. [details]
