GNOME Bugzilla – Bug 452225
check and option mark drawing is a mess of inconsistency
Last modified: 2007-07-27 12:12:49 UTC
gtkcellrenderertoggle.c does roughly following: gtk_widget_style_get (widget, "indicator-size", &indicator_size, NULL); width = height = indicator_size; gtk_paint_option (..., width - 1, height -1); The '-1' here seems pretty nonsense. They were added in http://svn.gnome.org/viewcvs/gtk%2B?view=revision&revision=4840 with explanation of 'Change the way we calculate cell size.' This is quite annoying with bitmap theme where the size of the bitmap is exactly 'indicator-size' pixels, painting a smaller indicator will either clip or scale down very little causing artefacts.
Correcting myself, it's not actually a style property but normal property.
Seems drawing of check and radio indicators is off-by-unclear and inconsistent in weird ways: (all default values with default theme:) - GtkCheckButton uses a 13 indicator-size and gets a 13x13 indicator drawn. - GtkCheckMenuItem uses a 12 indicator-size and gets a 13x13 indicator drawn. - GtkCellRendererToggle uses a 12 indicator-size and gets a 11x11 indicator drawn. one might think removing the -1 from comment #0 might result in a 12x12 indicator for the toggle renderer, but instead results in a 13x13 one. gtkstyle.c (gtk_default_draw_check/option) share the following code: exterior_size = MIN (width, height); if (exterior_size % 2 == 0) /* Ensure odd */ exterior_size -= -1; looks as if they want to ensure an odd size by subtracting 1 if it's even... but wait... wtf is "-= -1" ? Seems like a typo to me that results in even indicators enlarged by one instead of shrinking them. Suggested fix for the mess: 1. change gtkstyle.c to do: exterior_size = MIN (width, height); if (exterior_size % 2 == 0) /* Ensure odd */ exterior_size -= 1; 2. remove the -1 from gtkcellrenderertoggle.c 3. change the default indicator size to 13 in GtkCheckMenuItem and GtkCellRendererToggle The only visible change from this would be that toggle renderers are by default two pixels larger than configured which 1. makes them easier clickable 2. makes them consistent with checkbuttons and menu items Patch to fix the mess follows.
Created attachment 90859 [details] [review] Patch fixing the bug
from comment #2: > The only visible change from this would be that toggle renderers are > by default two pixels larger than configured which That should read "...larger than before which:" of course.
(In reply to comment #2) > The only visible change from this would be that toggle renderers are > by default two pixels larger than configured which > > 1. makes them easier clickable > 2. makes them consistent with checkbuttons and menu items the analysis and sugegsted fix looks pretty sane to me, however if GtkCellRendererToggle::indicator-size is efefctively off by 1 compared to previous Gtk+ versions by this change, and appropriate note needs to be added to the release notes in README.
Fixed in trunk: 2007-07-27 Michael Natterer <mitch@imendio.com> Fix check/radio indicator drawing mess (bug #452225): * gtk/gtkstyle.c (gtk_default_draw_check): really decrease the indicator size by one to ensure odd size (don't say -= -1). * gtk/gtkcellrenderertoggle.c (gtk_cell_renderer_toggle_render): removed -1 adjustment from calls to gtk_paint_option(). Theme engines now get the actually configured size passed, not one pixel less. * gtk/gtkcellrenderertoggle.c * gtk/gtkcheckmenuitem.c: changed default indicator size from 12 to 13 so all widgets which draw check/option indicators have the same default size now (and render the same size after above changes). * README.in: mention above changes in the release notes.