Merge lp:~victored/noise/lp-1315460 into lp:~elementary-apps/noise/trunk

Proposed by Victor Martinez
Status: Merged
Approved by: Victor Martinez
Approved revision: 1604
Merged at revision: 1600
Proposed branch: lp:~victored/noise/lp-1315460
Merge into: lp:~elementary-apps/noise/trunk
Diff against target: 55 lines (+33/-0)
1 file modified
src/Widgets/FastView/TileView/TileView.vala (+33/-0)
To merge this branch: bzr merge lp:~victored/noise/lp-1315460
Reviewer Review Type Date Requested Status
Victor Martinez (community) Approve
Corentin Noël Approve
elementary UX Pending
Review via email: mp+218175@code.launchpad.net

Commit message

Space album view items evenly. Fixes lp:1315460

Description of the change

Space album view items evenly. Fixes lp:1315460

To post a comment you must log in.
Revision history for this message
Corentin Noël (tintou) wrote :

It's also resizing the top and bottom margin, I don't think that it should be the case.

review: Needs Fixing
Revision history for this message
Victor Martinez (victored) wrote :

Indeed, I'm not a big fan of that either.

There's a technical limitation though. here 'margin' refers to gtk_icon_view_set_margin, and not gtk_widget_set_margin, so we can't do things like margin_left, margin_top, etc.

See: http://bazaar.launchpad.net/~vcs-imports/gtk/trunk/view/head:/gtk/gtkiconview.c#L5973

A solution could be to have a fixed margin, say 24 px, and only compute the spacing between items. I won't be 'even' spacing anymore, but at least it'd be symmetrical

lp:~victored/noise/lp-1315460 updated
1601. By Victor Martinez

Use fixed vertical and horizontal margin. Only scale spacing between items.

Revision history for this message
Victor Martinez (victored) wrote :

I've modified the implementation to use a fixed 'margin'. See lp:~victored/noise/album-view-spacing

I'm not sure which one to go with tbh.

Revision history for this message
Danielle Foré (danrabbit) wrote :

Having a fixed outside margin and adjusting spacing between albums sounds solid to me

Revision history for this message
Victor Martinez (victored) wrote :

I've deleted the new 'album-view-spacing' branch and pushed the changes here.

The view currently uses a fixed margin of 24px (top margin appears larger due to item shadow rendering), and only modifies the spacing between items.

Please test again.

lp:~victored/noise/lp-1315460 updated
1602. By Victor Martinez

update comment

Revision history for this message
Corentin Noël (tintou) wrote :

This one is better,
To me the row_spacing = ideal_spacing / 2; should be removed

lp:~victored/noise/lp-1315460 updated
1603. By Victor Martinez

Only resize horizontally. Use fixed vertical spacing

Revision history for this message
Victor Martinez (victored) wrote :

Good call.

I agree only re-flowing horizontally looks better. I modified the default vertical spacing to be 12px instead of the default 6px, which makes the view look cluttered with larger horizontal spacing.

Please test / review again.

Revision history for this message
Corentin Noël (tintou) wrote :

Yes, I think it's good like this

review: Approve
lp:~victored/noise/lp-1315460 updated
1604. By Victor Martinez

get rid of unneeded variable

Revision history for this message
Victor Martinez (victored) wrote :

Let's go with this then. If you have any suggestions regarding the size of the margin and such, let me know so I can change it.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/Widgets/FastView/TileView/TileView.vala'
2--- src/Widgets/FastView/TileView/TileView.vala 2013-08-17 04:38:12 +0000
3+++ src/Widgets/FastView/TileView/TileView.vala 2014-05-03 20:26:10 +0000
4@@ -6,6 +6,8 @@
5 */
6
7 public class Noise.Widgets.TileView : Gtk.IconView {
8+ private const int MIN_HORIZONTAL_SPACING = 12;
9+
10 private const string STYLESHEET = """
11 /* general background color and texture */
12 .tile-view {
13@@ -60,6 +62,13 @@
14 public TileView () {
15 pack_start (cell_renderer, false);
16 apply_default_theme ();
17+
18+ // padding needs to be 0 for pixel-perfect even spacing
19+ item_padding = 0;
20+
21+ // use fixed vertical and horizontal margin
22+ margin = 24;
23+ row_spacing = 12;
24 }
25
26 private void apply_default_theme () {
27@@ -67,4 +76,28 @@
28 Granite.Widgets.Utils.set_theming (this, STYLESHEET, "tile-view",
29 Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
30 }
31+
32+ public override void size_allocate (Gtk.Allocation alloc) {
33+ // This assumes that the width of the sample is the width of every item
34+ Gtk.Requisition minimum_size, natural_size;
35+ cell_renderer.get_preferred_size (this, out minimum_size, out natural_size);
36+ int item_width = minimum_size.width;
37+
38+ if (item_width <= 0)
39+ base.size_allocate (alloc);
40+
41+ int total_width = alloc.width;
42+
43+ // Find out how many items fit in a single row
44+ double num = total_width + MIN_HORIZONTAL_SPACING - 2 * margin;
45+ double denom = item_width + MIN_HORIZONTAL_SPACING;
46+ columns = (int) (num / denom);
47+
48+ // Find ideal column spacing
49+ num = total_width - columns * item_width - 2 * margin;
50+ denom = columns - 1;
51+ column_spacing = (int) (num / denom);
52+
53+ base.size_allocate (alloc);
54+ }
55 }

Subscribers

People subscribed via source and target branches