Ticket UUID: | 58222c42b37d57f35c487ea569ffe89fc79ac832 | |||
Title: | Aqua Ttk entry: gray default field background under light mode | |||
Type: | Bug | Version: | 8.6.11 | |
Submitter: | chrstphrchvz | Created on: | 2021-02-27 03:25:57 | |
Subsystem: | 88. Themed Tk | Assigned To: | marc_culler | |
Priority: | 5 Medium | Severity: | Minor | |
Status: | Closed | Last Modified: | 2021-04-21 13:10:19 | |
Resolution: | Fixed | Closed By: | marc_culler | |
Closed on: | 2021-04-21 13:10:19 | |||
Description: |
As of [dbc4faf03f] the default field background of Ttk entry widgets under macOS Aqua is systemWindowBackgroundColor rather than systemTextBackgroundColor. This is only noticeable under light mode, where the Ttk entry field background is gray rather than white. The ttk::style configure . … command near the beginning of aquaTheme.tcl first sets -background to systemWindowBackgroundColor. Prior to [dbc4faf03f] a subsequent ttk::style configure TEntry … command would then set -background to systemTextBackgroundColor. For the aqua Ttk theme, -background is treated as the -fieldbackground when the latter is not set, and -fieldbackground is not set by default. Originally reported by a Tcl::pTk user: https://github.com/chrstphrchvz/perl-tcl-ptk/issues/21 | |||
User Comments: |
marc_culler (claiming to be Marc Culler) added on 2021-04-19 15:50:20:
Thank you Christoper. I think I incorporated all of your suggestions. I will try to think about what to do about the fieldbackground alias in 8.7. chrstphrchvz added on 2021-04-16 17:26:46:
My immediate suggestion remains to remove the couple of lines from aquaTheme.tcl which set -fieldbackground for TEntry and TSpinbox, so that only -background is set in those cases. I.e.: --- library/ttk/aquaTheme.tcl.orig +++ library/ttk/aquaTheme.tcl @@ -44,8 +44,7 @@ namespace eval ttk::theme::aqua { # Entry ttk::style configure TEntry \ -foreground systemTextColor \ - -background systemTextBackgroundColor \ - -fieldbackground systemTextBackgroundColor + -background systemTextBackgroundColor ttk::style map TEntry \ -foreground { disabled systemDisabledControlTextColor @@ -66,8 +65,7 @@ namespace eval ttk::theme::aqua { # Spinbox ttk::style configure TSpinbox \ -foreground systemTextColor \ - -background systemTextBackgroundColor \ - -fieldbackground systemTextBackgroundColor + -background systemTextBackgroundColor ttk::style map TSpinbox \ -foreground { disabled systemDisabledControlTextColor chrstphrchvz added on 2021-04-16 17:16:58: See patch in [3c69cab43f] for remaining highlight colors. I'm not sure whether I fully understand the concern over different appearance between platforms; I would appreciate if someone else can offer their understanding or help bridge ours. My immediate suggestion remains to remove the couple of lines from aquaTheme.tcl which set -fieldbackground for TEntry and TSpinbox, so that only -background is set in those cases. That way a program is free to set either -background or -fieldbackground, each achieving the same effect. Alternatively, to simplify things and reduce inconsistency with other themes, I think the -background compatibility alias for -fieldbackground should be disallowed in Tk 8.7. I personally would be fine with it being disallowed 8.6.12 as long as the documentation is updated to say that using -background instead of -fieldbackground is disallowed as of 8.6.12. marc_culler (claiming to be Marc Culler) added on 2021-04-08 21:01:13: Christopher, can you provide a patch for the other default values that you mentioned? marc_culler (claiming to be Marc Culler) added on 2021-04-08 16:07:23: Thank you Christopher. It was sloppy of me to neglect to deal with the defaults and the insert background change was an egregious mistake on my part. I have committed the changes you suggested for the defaults. Now I need you to explain what you think should be done with -fieldbackground. I really don't know. I don't like the idea of a code paradigm which produces something that looks fine and makes sense on some platforms but looks terrible on macOS. chrstphrchvz added on 2021-04-08 00:02:54: There are other DEF_*_HIGHLIGHT colors for other widgets currently hardcoded to BLACK which should probably be updated to NORMAL_FG as well. chrstphrchvz added on 2021-04-07 23:57:11: I appreciate the effort to get this resolved, but I am not completely satisfied with the changes that were merged. To reiterate my comment from 2021-03-06 07:17:28:
marc_culler (claiming to be Marc Culler) added on 2021-04-07 15:47:08: Hi Csaba, sorry for the slow response. I made the same change for the ttk::spinbox and merged the fix. I will close the ticket now. nemethi (claiming to be Csaba Nemethi) added on 2021-03-30 18:19:08: Any chance to see the bug-58222c42b3 branch merged (and this ticket closed) in the near future? Please recall that the proposed changes should be made for TSpinbox, too. marc_culler (claiming to be Marc Culler) added on 2021-03-23 18:37:06: Yes, you are right. I was confused. Sorry. bll added on 2021-03-23 18:30:27: And we're not asking for the background behind the entry box to be configurable. chrstphrchvz added on 2021-03-23 18:21:55: I think there is some confusion: I understand "field background color" as referring to the text field color, and not anything to do with buttons. Brad describes how a container background color is drawn first; my understanding of the documentation is that this color should not be configurable. So the clam theme -background behavior Csaba points out I believe contradicts documentation (which is what my earlier comment was based on); although the behavior was likely undocumented for a long time, and when documentation was added not too long ago, it overlooked this behavior. marc_culler (claiming to be Marc Culler) added on 2021-03-23 12:25:29: The Aqua theme cannot change the color of a button (which would seem to be what Tk calls the "field background color"). The native buttons are all the same color unless they are -default buttons, in which case they use the controlAccentColor. Since the Aqua buttons have rounded corners, the "background color" needs to match the color of the containing widget to avoid looking bad. The color of the containing widget is also not controllable for native widgets. It is nominally the windowBackgroundColor, but there are exceptions due the fact that the native notebook panes and labelframes have no border but are distinguished from their container by having a slightly darker (or lighter in dark mode) contrasting gray color. Currently the Aqua ttk widgets automatically handle matching the "background" to the color of the container, and ignore both options. But Tk widgets do not do this. If you want the background to match correctly for a Tk button, there are the systemWindowBackgroundColorN colors, where N is a digit indicating how deeply nested the button is within widgets which use a color that contrasts with the color of their container. This means that it is possible to do the matching, but it is up to the programmer to do so. You are free to use a red background with a Tk button, making a red rectangle that does not match the gray window background and which contains a button that has the standard Aqua button color(depending on whether light or dark mode is in effect). nemethi (claiming to be Csaba Nemethi) added on 2021-03-22 13:52:46: Another example is the clam theme. It has rounded corners, behind which the color specified as the value of the -background style configuration option can be seen. If you change this color to red then each corner will contain a red pixel. bll added on 2021-03-22 12:50:47: Marc Culler wrote: > An entry widget is drawn by filling a large rectangle with the fieldbackground > color and then drawing the text on top of that rectangle. The text consists > of rectangles of varying sizes, each filled with the background color and > containing a glyph drawn in the foreground color. > > I can't conceive of a context in which it would not look awful to have > different background and fieldbackground colors. But someone must have had > such a context in mind when the decision was made to provide all three of > these options. What could it have been? That may be what was implemented for the aqua themne, but that's not how background and field background are used in other implementations. (And why the older mac ttk entry box made life difficult). For non-aqua: the background is the overall background of the entire widget. This can be seen when using graphical entry boxes with rounded corners. The background color shows up behind the corners of the entry box. Drawn in order: background of the widget, the border/focus/highlight, the field background, the text. Graphical entry boxes supply the border/focus/highlight and field background. nemethi (claiming to be Csaba Nemethi) added on 2021-03-22 10:25:44: The ttk::spinbox widget has the same appearance problems as ttk::entry (light gray background rather than white). Consequently, the proposed changes should be made for TSpinbox, too. chrstphrchvz added on 2021-03-06 07:17:28: Comments regarding [cdbd93edca]: currently I think the only desirable thing to add back to aquaTheme.tcl is ttk::style configure TEntry \ -foreground systemTextColor \ -background systemTextBackgroundColor plus a comment explaining why -fieldbackground is not set by default: i.e. for the documented behavior to be preserved, the -fieldbackground should not be set by default, otherwise a program could not set a custom -background. It turns out that setting -foreground by default is desirable: currently systemLabelColor is being used instead, which is closer to gray than the correct color systemTextColor. I do not understand why changes are made to tkMacOSXDefault.h: the updated constants are not used by the Aqua Ttk entry widget. chrstphrchvz added on 2021-03-06 06:53:11: I'm not sure if this answers Marc's question, but there is no instance where both -background and -fieldbackground have an effect simultaneously. Both options correspond to the color used to draw the rectangle behind the text; I'm not aware that there is even a way to specify the "text background" color used when glyphs are being drawn. Other Ttk themes have only ever used -fieldbackground, and do not use -background. The aqua theme originally only had -background, instead of -fieldbackground as it should've had for consistency with other themes. Rather than renaming the -background option to -fieldbackground in the aqua theme, the backward-compatible behavior was added in [8dff92174e] where -background and -fieldbackground would act the same, but with -fieldbackground taking precedence (as currently documented). marc_culler (claiming to be Marc Culler) added on 2021-03-05 15:15:55: Here is something I need to know. What is an example of a context, Aqua or not, in which it would make sense for the text background color in an Entry widget to be different from the fieldbackground color? An entry widget is drawn by filling a large rectangle with the fieldbackground color and then drawing the text on top of that rectangle. The text consists of rectangles of varying sizes, each filled with the background color and containing a glyph drawn in the foreground color. I can't conceive of a context in which it would not look awful to have different background and fieldbackground colors. But someone must have had such a context in mind when the decision was made to provide all three of these options. What could it have been? chrstphrchvz added on 2021-03-05 14:00:00: To make the resolution to this issue and [e1e881b920] more consistent, I wonder if custom field background colors should be ignored in addition to custom foreground colors. chrstphrchvz added on 2021-03-05 13:55:26: Another user reported this issue on the MACTCL list: https://sourceforge.net/p/tcl/mailman/message/37233380/ Running ttk::style configure TEntry -background systemTextBackgroundColor should serve as a workaround. chrstphrchvz added on 2021-02-28 22:11:30: I am still quite unfamiliar with the details of Ttk (both configuration and implementation), so I am simply unaware whether there's a more proper solution than setting -background to systemTextBackgroundColor by default in aquaTheme.tcl as previously done. I don't think -fieldbackground can be set by default, since that causes a custom -background to be ignored, contradicting documentation: -background colorFor backwards compatibility, when using the aqua theme (for macOS), this option behaves as an alias for the -fieldbackground provided that no value is specified for -fieldbackground. Otherwise it is ignored. marc_culler (claiming to be Marc Culler) added on 2021-02-28 15:11:47: @chrstrchvz: from what you say it seems like the best solution would be to set the -fieldbackground of a Ttk Entry to systemTextBackgroundColor. Can you see a reason why that would not work? chrstphrchvz added on 2021-02-28 01:16:18: Not sure what should be done to address this; I don't know whether reinstating ttk::entry configure TEntry -background systemTextBackgroundColor is the correct approach. Also not aware whether other Ttk widgets are affected by similar issues. |