Merge lp:~tpeeters/ubuntu-ui-toolkit/doc-flickable into lp:ubuntu-ui-toolkit

Proposed by Tim Peeters
Status: Merged
Approved by: Zsombor Egri
Approved revision: 558
Merged at revision: 567
Proposed branch: lp:~tpeeters/ubuntu-ui-toolkit/doc-flickable
Merge into: lp:ubuntu-ui-toolkit
Diff against target: 133 lines (+51/-4)
4 files modified
CHANGES (+1/-0)
modules/Ubuntu/Components/Header.qml (+8/-0)
modules/Ubuntu/Components/Page.qml (+39/-4)
tests/unit/tst_components/tst_tabs.qml (+3/-0)
To merge this branch: bzr merge lp:~tpeeters/ubuntu-ui-toolkit/doc-flickable
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Zsombor Egri Approve
Review via email: mp+170376@code.launchpad.net

Commit message

Update header behavior:
- Do not automatically hide the header when scrolling in a flickable that is not anchored to the top of the page.
- Automatically show the header when flickable's contentHeight becomes less than flickable.height.
- Update documentation for Page.flickable.

Description of the change

Update header behavior:
- Do not automatically hide the header when scrolling in a flickable that is not anchored to the top of the page.
- Automatically show the header when flickable's contentHeight becomes less than flickable.height.
- Update documentation for Page.flickable.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
557. By Tim Peeters

update tests

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
558. By Tim Peeters

merge trunk

Revision history for this message
Zsombor Egri (zsombi) wrote :

looks good

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CHANGES'
2--- CHANGES 2013-06-19 09:46:09 +0000
3+++ CHANGES 2013-07-01 11:22:42 +0000
4@@ -43,6 +43,7 @@
5
6 - CHANGED IN Tabs: Automatically show the header when the title of the active tab changes
7 - CHANGED IN Page/MainView: Only enable auto-hide behavior of header when the Page's flickable can be flicked vertically, so that manual setting of anchors is no longer needed for flickables that only flick horizontally
8+- CHANGED IN Page: Automatic detection of flickable inside a Page to control the header is now limited to Flickables that are anchored to the top of the Page or fill the Page. Header automatically shows when flickable.contentHeight becomes <= flickable.height.
9
10 SDK 0.1.46
11 ##########
12
13=== modified file 'modules/Ubuntu/Components/Header.qml'
14--- modules/Ubuntu/Components/Header.qml 2013-05-14 13:33:39 +0000
15+++ modules/Ubuntu/Components/Header.qml 2013-07-01 11:22:42 +0000
16@@ -116,6 +116,7 @@
17 flickable.contentYChanged.connect(internal.scrollContents);
18 flickable.movementEnded.connect(internal.movementEnded);
19 flickable.interactiveChanged.connect(internal.interactiveChanged);
20+ flickable.contentHeightChanged.connect(internal.contentHeightChanged);
21 }
22 previousFlickable = flickable;
23 }
24@@ -143,6 +144,13 @@
25 }
26
27 /*
28+ Content height of flickable changed
29+ */
30+ function contentHeightChanged() {
31+ if (flickable && flickable.height >= flickable.contentHeight) header.show();
32+ }
33+
34+ /*
35 Flickable became interactive or non-interactive.
36 */
37 function interactiveChanged() {
38
39=== modified file 'modules/Ubuntu/Components/Page.qml'
40--- modules/Ubuntu/Components/Page.qml 2013-06-14 16:28:04 +0000
41+++ modules/Ubuntu/Components/Page.qml 2013-07-01 11:22:42 +0000
42@@ -85,8 +85,38 @@
43
44 /*!
45 Optional flickable that controls the header. This property
46- is automatically set if the Flickable is one of the Page's direct children.
47- May be set to null to avoid the header from hiding.
48+ is automatically set to the first child of the page that is Flickable
49+ and anchors to the top of the page or fills the page. For example:
50+ \qml
51+ import QtQuick 2.0
52+ import Ubuntu.Components 0.1
53+
54+ MainView {
55+ width: units.gu(30)
56+ height: units.gu(50)
57+ Page {
58+ id: page
59+ title: "example"
60+ //flickable: null // uncomment to disable hiding of the header
61+ Flickable {
62+ id: content
63+ anchors.fill: parent
64+ contentHeight: units.gu(70)
65+ Label {
66+ text: "hello"
67+ anchors.centerIn: parent
68+ }
69+ }
70+ }
71+ }
72+ \endqml
73+ In this example, page.flickable will automatically be set to content because it is
74+ a Flickable and it fills its parent. Thus, scrolling down in the Flickable will automatically
75+ hide the header.
76+
77+ This property be set to null to avoid automatic flickable detection, which disables hiding
78+ of the header by scrolling in the Flickable. In cases where a flickable should control the header,
79+ but it is not automatically detected, the flickable property can be set.
80 */
81 property Flickable flickable: internal.getFlickableChild(page)
82
83@@ -136,7 +166,7 @@
84 function isVerticalFlickable(object) {
85 if (object && object.hasOwnProperty("flickableDirection") && object.hasOwnProperty("contentHeight")) {
86 var direction = object.flickableDirection;
87- if ( (direction === Flickable.AutoFlickDirection && (object.contentHeight !== object.height))
88+ if ( ((direction === Flickable.AutoFlickDirection) && (object.contentHeight !== object.height) )
89 || direction === Flickable.VerticalFlick
90 || direction === Flickable.HorizontalAndVerticalFlick) {
91 return true;
92@@ -151,7 +181,12 @@
93 function getFlickableChild(item) {
94 if (item && item.hasOwnProperty("children")) {
95 for (var i=0; i < item.children.length; i++) {
96- if (internal.isVerticalFlickable(item.children[i])) return item.children[i];
97+ var child = item.children[i];
98+ if (internal.isVerticalFlickable(child)) {
99+ if (child.anchors.top === page.top || child.anchors.fill === page) {
100+ return item.children[i];
101+ }
102+ }
103 }
104 }
105 return null;
106
107=== modified file 'tests/unit/tst_components/tst_tabs.qml'
108--- tests/unit/tst_components/tst_tabs.qml 2013-05-22 09:38:09 +0000
109+++ tests/unit/tst_components/tst_tabs.qml 2013-07-01 11:22:42 +0000
110@@ -115,6 +115,7 @@
111 page: Page {
112 Flickable {
113 id: flickable1
114+ anchors.fill: parent
115 }
116 }
117 }
118@@ -123,6 +124,7 @@
119 page: Page {
120 Flickable {
121 id: flickable2
122+ anchors.fill: parent
123 }
124 }
125 }
126@@ -142,6 +144,7 @@
127 property Flickable flick: loadedFlickable
128 Flickable {
129 id: loadedFlickable
130+ anchors.fill: parent
131 contentHeight: 1000
132 }
133 }

Subscribers

People subscribed via source and target branches

to status/vote changes: