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 650424 - treeview: expander is not easily themable
treeview: expander is not easily themable
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: GtkTreeView
3.6.x
Other All
: Normal normal
: ---
Assigned To: gtktreeview-bugs
gtktreeview-bugs
: 653027 (view as bug list)
Depends on:
Blocks: 685416
 
 
Reported: 2011-05-17 18:30 UTC by Cosimo Cecchi
Modified: 2013-03-01 19:09 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
treeview: render a frame around the rows, after drawing their background (1.05 KB, patch)
2011-05-17 18:30 UTC, Cosimo Cecchi
committed Details | Review
treeview: don't arbitrairly add 2 to the expander size (948 bytes, patch)
2011-05-17 18:30 UTC, Cosimo Cecchi
committed Details | Review
treeview: center the expander in the horizontal separator allocation (1.38 KB, patch)
2011-05-17 18:30 UTC, Cosimo Cecchi
reviewed Details | Review
treeview: remove extra padding handling (1.48 KB, patch)
2013-02-23 00:54 UTC, Cosimo Cecchi
committed Details | Review
treeview: properly calculate the treeview expander size (3.46 KB, patch)
2013-02-23 00:55 UTC, Cosimo Cecchi
none Details | Review
treeview: properly calculate the treeview expander size (3.46 KB, patch)
2013-02-23 00:59 UTC, Cosimo Cecchi
committed Details | Review
treeview: center expander allocated space (812 bytes, patch)
2013-02-23 00:59 UTC, Cosimo Cecchi
committed Details | Review

Description Cosimo Cecchi 2011-05-17 18:30:04 UTC
This is a small patchset that fixes some theming glitches with GtkTreeView.
- first patch renders a frame around the rows, in addition to the background, which is already rendered. Theming engines (Adwaita) currently have to workaround this bug by setting a gradient with fake tiny color-stops as background-image.
- second patch removes an arbitrary +2 in the rendered expander size; this ensures the size specified by the "expander-size" style property is the one actually reaching the theming engine for rendering.
- third patch centers the expander in the spacing provided by the "horizontal-separator" style property. Expanders in list views currently look bad (e.g. Nautilus) because they have no spacing from the left treeview side. Padding in the tree view is only specified by the "horizontal-separator" and "vertical-separator" style properties, so it makes sense to use the horizontal padding to center the expander in it.
Comment 1 Cosimo Cecchi 2011-05-17 18:30:07 UTC
Created attachment 187982 [details] [review]
treeview: render a frame around the rows, after drawing their background
Comment 2 Cosimo Cecchi 2011-05-17 18:30:15 UTC
Created attachment 187983 [details] [review]
treeview: don't arbitrairly add 2 to the expander size
Comment 3 Cosimo Cecchi 2011-05-17 18:30:18 UTC
Created attachment 187984 [details] [review]
treeview: center the expander in the horizontal separator allocation

This fixes the expander looking bad in list views.
Comment 4 Matthias Clasen 2011-05-18 14:05:49 UTC
Review of attachment 187982 [details] [review]:

It feel like we should really have a better defined set of 'things the theme will draw' like the css box drawing model, but until then, this is probably ok...
Comment 5 Matthias Clasen 2011-05-18 14:06:39 UTC
Review of attachment 187983 [details] [review]:

Sure, if it works. Do we need to bump the default expander size to compensate ?
Comment 6 Matthias Clasen 2011-05-18 14:07:19 UTC
Review of attachment 187984 [details] [review]:

Is the default value for horizontal-separator nonzero ?
Comment 7 Matthias Clasen 2011-05-18 14:07:49 UTC
Review of attachment 187984 [details] [review]:

Is the default value for horizontal-separator nonzero ? Where else is the horizontal-separator used, and might this has unintended side-effects ?
Comment 8 Cosimo Cecchi 2011-05-18 15:28:27 UTC
(In reply to comment #7)

Thanks for the reviews; I pushed the first two patches to master, along with a 2px bump of the default expander size.

> Is the default value for horizontal-separator nonzero ? Where else is the
> horizontal-separator used, and might this has unintended side-effects ?

Yes, the default value is 2px. The horizontal separator is used between every pair of columns - it's basically a padding between the columns; each column takes up half of the separator space, which is centered on the separator line in the header.

I don't think the patch has any side effects, as GtkTreeView seems to consistently use gtk_tree_view_get_arrow_xrange() to calculate the expander position; testing doesn't reveal anything strange going on, but you know you can never be 100% sure with the tree view :)

Long-term, I think we should really deprecate all these pseudo-padding style properties (other widgets have a few more) and use 'padding' (and 'margin') consistently, but this is non trivial with the treeview, (and the cell renderers are not widgets, so they don't follow the usual approach).
Comment 9 Kristian Rietveld 2011-05-22 10:35:21 UTC
Could tree view bugs *please* be filed in the GtkTreeView component next time?  Otherwise I won't see them.  I will review these patches later on, there's a couple of things I am not sure about.
Comment 10 Kristian Rietveld 2011-05-22 10:35:55 UTC
Moving to correct component.
Comment 11 Kristian Rietveld 2011-05-22 14:13:27 UTC
(In reply to comment #8)
> (In reply to comment #7)
> 
> Thanks for the reviews; I pushed the first two patches to master, along with a
> 2px bump of the default expander size.

I can see why you would want to remove the arbitrary + 2 (it has been there since 2001 and I assume nobody knows why).  I am a bit divided on raising the default expander size with 2px, because this has raised the default minimum row height with 2px as well.


> > Is the default value for horizontal-separator nonzero ? Where else is the
> > horizontal-separator used, and might this has unintended side-effects ?
> 
> Yes, the default value is 2px. The horizontal separator is used between every
> pair of columns - it's basically a padding between the columns; each column
> takes up half of the separator space, which is centered on the separator line
> in the header.

It's not padding between columns, it is padding around the cells in a column.  For the horizontal separator, there's 1/2 before the cells in the column and 1/2 after.  See docs/tree-column-sizing.png.

From this same image, we can actually see that the expander is meant to be within the padding, which means that indeed 1/2 horizontal-separator would have to be added, but focus-line-width as well.
Comment 12 Kristian Rietveld 2011-05-22 14:19:16 UTC
(In reply to comment #11)
> I can see why you would want to remove the arbitrary + 2 (it has been there
> since 2001 and I assume nobody knows why).  I am a bit divided on raising the
> default expander size with 2px, because this has raised the default minimum row
> height with 2px as well.

Perhaps we can actually solve the expander size problems for real by looking at the same image.  Currently, in the style updated handler, EXPANDER_EXTRA_PADDING is added to expander size.  Subsequently, expander_size + EXPANDER_EXTRA_PADDING is used in various calculations, including when checking whether a row size is expander_size + EXPANDER_EXTRA_PADDING at minimum.  This EXPANDER_EXTRA_PADDING can also be considered arbitrary.  Also observe how EXPANDER_EXTRA_PADDING is subtracted from expander_size in gtk_tree_view_draw_arrow().

So indeed, when drawing the arrow we need to use expander_size as size.  However, I think that EXPANDER_EXTRA_PADDING should simply be replaced with a proper calculation: add vertical_separator + 2 * focus-line-width to the expander_size instead.  And perhaps also rename the variable to expander_size_with_padding?

That way all arbitrary values in expander size calculation should be gone :)
Comment 13 Paolo Borelli 2011-06-20 17:08:52 UTC
*** Bug 653027 has been marked as a duplicate of this bug. ***
Comment 14 Cosimo Cecchi 2012-10-03 16:54:24 UTC
Renaming this bug; the only part that still applies is that the expander padding and positioning are not easily themable.
We currently have a hack in place in Adwaita to workaround this, but I would like to get rid of it and fix it properly for the next cycle.
Comment 15 Cosimo Cecchi 2013-02-23 00:54:51 UTC
Created attachment 237223 [details] [review]
treeview: remove extra padding handling

We'll replace this with a proper calculation.
Comment 16 Cosimo Cecchi 2013-02-23 00:55:04 UTC
Created attachment 237224 [details] [review]
treeview: properly calculate the treeview expander size

It should be expander-size + horizontal-separator / 2. Rework code
calculating the render position of the arrow to account for the larger
size.
Comment 17 Cosimo Cecchi 2013-02-23 00:59:45 UTC
Created attachment 237225 [details] [review]
treeview: properly calculate the treeview expander size

It should be expander-size + horizontal-separator / 2. Rework code
calculating the render position of the arrow to account for the larger
size.
Comment 18 Cosimo Cecchi 2013-02-23 00:59:58 UTC
Created attachment 237226 [details] [review]
treeview: center expander allocated space

This patch centers the expander in the extra space allocated by the
horizontal-separator style property.
Comment 19 Cosimo Cecchi 2013-02-23 01:03:02 UTC
Attached patchset should implement pretty much what is proposed in comment #11 and comment #12.
Comment 20 Matthias Clasen 2013-03-01 04:29:03 UTC
Review of attachment 237223 [details] [review]:

Looks good to me
Comment 21 Matthias Clasen 2013-03-01 04:29:23 UTC
Review of attachment 237225 [details] [review]:

ok
Comment 22 Matthias Clasen 2013-03-01 04:29:37 UTC
Review of attachment 237226 [details] [review]:

ok
Comment 23 Cosimo Cecchi 2013-03-01 19:09:04 UTC
Attachment 237223 [details] pushed as 32bd10b - treeview: remove extra padding handling
Attachment 237225 [details] pushed as d0895d6 - treeview: properly calculate the treeview expander size
Attachment 237226 [details] pushed as 50065b7 - treeview: center expander allocated space