After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 452225 - check and option mark drawing is a mess of inconsistency
check and option mark drawing is a mess of inconsistency
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: Other
2.10.x
Other All
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2007-06-29 12:28 UTC by Tommi Komulainen
Modified: 2007-07-27 12:12 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch fixing the bug (2.56 KB, patch)
2007-06-29 13:04 UTC, Michael Natterer
committed Details | Review

Description Tommi Komulainen 2007-06-29 12:28:37 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.
Comment 1 Tommi Komulainen 2007-06-29 12:33:27 UTC
Correcting myself, it's not actually a style property but normal property.
Comment 2 Michael Natterer 2007-06-29 12:55:47 UTC
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.
Comment 3 Michael Natterer 2007-06-29 13:04:07 UTC
Created attachment 90859 [details] [review]
Patch fixing the bug
Comment 4 Michael Natterer 2007-06-29 13:07:09 UTC
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.
Comment 5 Tim Janik 2007-07-04 11:34:59 UTC
(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.
Comment 6 Michael Natterer 2007-07-27 12:12:49 UTC
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.