on xenial help sign in
Small fixes:
952e11aAlbert Astals
qml/Components/ResponsiveVerticalJournal.qml+24−29
@@ -19,23 +19,26 @@ import Ubuntu.Components 0.1
19import "../Components"
19import "../Components"
20import Dash 0.1
20import Dash 0.1
21
21
22−// A VerticalJournal. Based on defined column width,
22+/*!
23+ \brief A responsive wrapper around VerticalJournal.
24+
23−// delegates are layouted in columns following
25+ Based on defined column width, delegates are laid out in columns following
24−// a top-left most position rule.
26+ a top-left most position rule.
25−//
27+
26−// Example:
28+ Example:
27−//
29+
28−// +-----+ +-----+ +-----+
30+ +-----+ +-----+ +-----+
29−// | | | 2 | | |
31+ | | | 2 | | |
30−// | | | | | |
32+ | | | | | |
31−// | 1 | +-----+ | 3 |
33+ | 1 | +-----+ | 3 |
32−// | | +-----+ | |
34+ | | +-----+ | |
33−// | | | | +-----+
35+ | | | | +-----+
34−// +-----+ | 4 | +-----+
36+ +-----+ | 4 | +-----+
35−// +-----+ | | | 5 |
37+ +-----+ | | | 5 |
36−// | 6 | +-----+ | |
38+ | 6 | +-----+ | |
37−// | | +-----+
39+ | | +-----+
38−// +-----+
40+ +-----+
41+*/
39Item {
42Item {
40 property int minimumColumnSpacing: units.gu(1)
43 property int minimumColumnSpacing: units.gu(1)
41
44
@@ -63,18 +66,10 @@ Item {
63 return Math.floor(pixels / units.gu(1))
66 return Math.floor(pixels / units.gu(1))
64 }
67 }
65
68
66− function columnsForSpacing(spacing) {
69+ columnSpacing: {
67− // parent.width = columns * columnWidth +
70+ // parent.width = columns * columnWidth + (columns-1) * spacing + spacing(margins)
68− // (columns-1) * spacing + spacing(margins)
69− return Math.max(1, Math.floor(parent.width / (columnWidth + spacing)))
71+ var expectedColumns = Math.max(1, Math.floor(parent.width / (columnWidth + minimumColumnSpacing)));
72+ Math.floor((parent.width - expectedColumns * columnWidth) / expectedColumns);
70 }
73 }
71−
72− function spacingForColumns(columns) {
73− var spacingGU = px2gu((parent.width - columns * columnWidth) / columns)
74− return units.gu(spacingGU)
75− }
76−
77− readonly property int expectedColumns: columnsForSpacing(minimumColumnSpacing)
78− columnSpacing: spacingForColumns(expectedColumns)
79 }
74 }
80}
75}
tests/qmltests/Components/tst_ResponsiveVerticalJournal.qml+2−2
@@ -24,7 +24,7 @@ import Utils 0.1
24import Unity.Test 0.1 as UT
24import Unity.Test 0.1 as UT
25
25
26Item {
26Item {
27− width: journalRect.width + controls.width
27+ width: units.gu(80) + controls.width
28 height: units.gu(80)
28 height: units.gu(80)
29
29
30 Column {
30 Column {
@@ -86,11 +86,11 @@ Item {
86
86
87 Rectangle {
87 Rectangle {
88 id: journalRect
88 id: journalRect
89− width: units.gu(80)
90 height: parent.height
89 height: parent.height
91 color: "grey"
90 color: "grey"
92 anchors.top: parent.top
91 anchors.top: parent.top
93 anchors.left: parent.left
92 anchors.left: parent.left
93+ anchors.right: controls.left
94
94
95 ResponsiveVerticalJournal {
95 ResponsiveVerticalJournal {
96 id: journal
96 id: journal