Merge lp:~tpeeters/ubuntu-ui-toolkit/numHeaderActions into lp:ubuntu-ui-toolkit/staging

Proposed by Tim Peeters
Status: Merged
Approved by: Cris Dywan
Approved revision: 1743
Merged at revision: 1752
Proposed branch: lp:~tpeeters/ubuntu-ui-toolkit/numHeaderActions
Merge into: lp:ubuntu-ui-toolkit/staging
Diff against target: 257 lines (+127/-10)
5 files modified
src/Ubuntu/Components/1.3/PageHeader.qml (+5/-1)
src/Ubuntu/Components/Themes/Ambiance/1.3/ActionBarStyle.qml (+49/-2)
src/Ubuntu/Components/Themes/Ambiance/1.3/IconButtonStyle.qml (+2/-2)
tests/unit_x11/tst_components/tst_actionbar.qml (+1/-1)
tests/unit_x11/tst_components/tst_pageheader.qml (+70/-4)
To merge this branch: bzr merge lp:~tpeeters/ubuntu-ui-toolkit/numHeaderActions
Reviewer Review Type Date Requested Status
Cris Dywan Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+280081@code.launchpad.net

Commit message

Implement header slot management for convergence:
- Adapt the number of action slots to the width of the view.
- When a new action appears, show a quick fade-in.
- Reverse the order of the actions in the header.
- Update icon width to 4GU.

Description of the change

Implement header slot management for convergence:

- Adapt the number of action slots in the PageHeader to the width of the view. See UX specs: https://docs.google.com/document/d/1nFm8xiYhKXXuEO_IvMXoD0lASbYzYXva1BWMVanU3iw/edit#heading=h.88faiaf1ywf2

- When a new action appears in the PageHeader due to resizing, show a quick fade-in. This was reviewed with Olga and Ben K at the sprint.

- Reverse the order of the actions in the header (first action on the right side). This change was reviewed at the sprint with Olga and Ben K.

- Icon width was updated from 5GU to 4GU. This was reviewed with Jouni at the sprint.

To post a comment you must log in.
1741. By Tim Peeters

clean

1742. By Tim Peeters

clean

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

fix actionbar custom delegate test

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

Looks good.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/Ubuntu/Components/1.3/PageHeader.qml'
--- src/Ubuntu/Components/1.3/PageHeader.qml 2015-11-27 15:37:14 +0000
+++ src/Ubuntu/Components/1.3/PageHeader.qml 2015-12-10 12:03:49 +0000
@@ -144,6 +144,7 @@
144 The default value of \l leadingActionBar actions is144 The default value of \l leadingActionBar actions is
145 \l navigationActions, but that value can be changed to show145 \l navigationActions, but that value can be changed to show
146 different actions in front of the title.146 different actions in front of the title.
147 The leading action bar has only one slot.
147 See \l ActionBar.148 See \l ActionBar.
148 */149 */
149 readonly property alias leadingActionBar: leading150 readonly property alias leadingActionBar: leading
@@ -189,6 +190,9 @@
189 }190 }
190 }191 }
191 \endqml192 \endqml
193 By default the trailing action bar automatically adapts
194 its number of slots to the available space in the range
195 from 3 to 6.
192 See \l ActionBar.196 See \l ActionBar.
193 */197 */
194 readonly property alias trailingActionBar: trailing198 readonly property alias trailingActionBar: trailing
@@ -200,7 +204,7 @@
200 rightMargin: units.gu(1)204 rightMargin: units.gu(1)
201 }205 }
202 height: header.__styleInstance.contentHeight206 height: header.__styleInstance.contentHeight
203 numberOfSlots: 3207 numberOfSlots: MathUtils.clamp(0.3*header.width/units.gu(4), 3, 6)
204 delegate: header.__styleInstance.defaultActionDelegate208 delegate: header.__styleInstance.defaultActionDelegate
205 visible: trailing.width > 0 // at least 1 visible action209 visible: trailing.width > 0 // at least 1 visible action
206 }210 }
207211
=== modified file 'src/Ubuntu/Components/Themes/Ambiance/1.3/ActionBarStyle.qml'
--- src/Ubuntu/Components/Themes/Ambiance/1.3/ActionBarStyle.qml 2015-10-21 19:33:28 +0000
+++ src/Ubuntu/Components/Themes/Ambiance/1.3/ActionBarStyle.qml 2015-12-10 12:03:49 +0000
@@ -41,6 +41,28 @@
4141
42 defaultNumberOfSlots: 342 defaultNumberOfSlots: 3
4343
44 Component {
45 id: fadeInComponent
46 SequentialAnimation {
47 id: fadeIn
48 property alias target: opacityAnimation.target
49 ScriptAction {
50 script: fadeIn.target.opacity = 0.0;
51 }
52 UbuntuNumberAnimation {
53 id: opacityAnimation
54 from: 0.0
55 to: 1.0
56 property: "opacity"
57 alwaysRunToEnd: true
58 duration: UbuntuAnimation.BriskDuration
59 }
60 ScriptAction {
61 script: fadeIn.destroy()
62 }
63 }
64 }
65
44 Row {66 Row {
45 id: actionsContainer67 id: actionsContainer
4668
@@ -55,9 +77,18 @@
55 }77 }
56 return visibleActionList;78 return visibleActionList;
57 }79 }
80 function getReversedActions(actions) {
81 var newlist = [];
82 for (var i=actions.length-1; i >= 0; i--) {
83 newlist.push(actions[i]);
84 }
85 return newlist;
86 }
87
88 property var directActions: getReversedActions(visibleActions.slice(0, numberOfSlots.used))
58 property var barActions: overflowAction.visible89 property var barActions: overflowAction.visible
59 ? visibleActions.slice(0, numberOfSlots.used).concat(overflowAction)90 ? directActions.concat(overflowAction)
60 : visibleActions.slice(0, numberOfSlots.used)91 : directActions
61 property var overflowActions: visibleActions.slice(numberOfSlots.used,92 property var overflowActions: visibleActions.slice(numberOfSlots.used,
62 numberOfSlots.requested)93 numberOfSlots.requested)
6394
@@ -81,6 +112,22 @@
81 objectName: "actions_repeater"112 objectName: "actions_repeater"
82 model: actionsContainer.barActions113 model: actionsContainer.barActions
83 delegate: styledItem.delegate114 delegate: styledItem.delegate
115 property int previousCount: count
116 onCountChanged: {
117 // after all itemAdded signals
118 previousCount = count;
119 }
120
121 function fadeIn(item) {
122 var fadeObject = fadeInComponent.createObject(actionBarStyle,
123 {"target": item});
124 fadeObject.target = item;
125 fadeObject.start();
126 }
127 onItemAdded: {
128 if (count <= previousCount) return; // no items added
129 if (index == 0) fadeIn(item);
130 }
84 }131 }
85132
86 Action {133 Action {
87134
=== modified file 'src/Ubuntu/Components/Themes/Ambiance/1.3/IconButtonStyle.qml'
--- src/Ubuntu/Components/Themes/Ambiance/1.3/IconButtonStyle.qml 2015-09-21 14:44:13 +0000
+++ src/Ubuntu/Components/Themes/Ambiance/1.3/IconButtonStyle.qml 2015-12-10 12:03:49 +0000
@@ -20,8 +20,8 @@
20Item {20Item {
21 id: iconButtonStyle21 id: iconButtonStyle
2222
23 implicitWidth: units.gu(5)23 implicitWidth: units.gu(4)
24 implicitHeight: units.gu(5)24 implicitHeight: units.gu(4)
2525
26 /*!26 /*!
27 The color of the icons.27 The color of the icons.
2828
=== modified file 'tests/unit_x11/tst_components/tst_actionbar.qml'
--- tests/unit_x11/tst_components/tst_actionbar.qml 2015-10-05 10:53:07 +0000
+++ tests/unit_x11/tst_components/tst_actionbar.qml 2015-12-10 12:03:49 +0000
@@ -271,7 +271,7 @@
271 var i = 0; var button; var n = shortActionList.length;271 var i = 0; var button; var n = shortActionList.length;
272 for (i = 0; i < n; i++) {272 for (i = 0; i < n; i++) {
273 button = findChild(customDelegateBar, "custom_delegate_button_"+i);273 button = findChild(customDelegateBar, "custom_delegate_button_"+i);
274 compare(button.text, shortActionList[i].text, "Incorrect custom button " + i);274 compare(button.text, shortActionList[n-1-i].text, "Incorrect custom button " + i);
275 }275 }
276 button = findChild(customDelegateBar, "custom_delegate_button_" + n);276 button = findChild(customDelegateBar, "custom_delegate_button_" + n);
277 compare(button, null, "Too many buttons.");277 compare(button, null, "Too many buttons.");
278278
=== modified file 'tests/unit_x11/tst_components/tst_pageheader.qml'
--- tests/unit_x11/tst_components/tst_pageheader.qml 2015-11-27 15:49:52 +0000
+++ tests/unit_x11/tst_components/tst_pageheader.qml 2015-12-10 12:03:49 +0000
@@ -18,16 +18,23 @@
18import Ubuntu.Components 1.318import Ubuntu.Components 1.3
19import Ubuntu.Test 1.019import Ubuntu.Test 1.0
2020
21Item {21Rectangle {
22 // Wrap the root Item to work around bug #1504755 which22 // Wrap the root Item to work around bug #1504755 which
23 // causes the OverflowPanel to open behind the PageHeader23 // causes the OverflowPanel to open behind the PageHeader
24 // without this wrapper Item.24 // without this wrapper Item.
25 id: wrapper25 id: wrapper
26 width: units.gu(50)26 width: units.gu(100)
27 height: units.gu(70)27 height: units.gu(70)
28 color: "darkgrey"
2829
29 Item {30 Rectangle {
30 anchors.fill: parent31 anchors {
32 top: parent.top
33 bottom: parent.bottom
34 left: parent.left
35 }
36 width: widthSwitch.checked ? parent.width : units.gu(40)
37 color: "white"
31 id: root38 id: root
3239
33 property real initialHeaderHeight: units.gu(6)40 property real initialHeaderHeight: units.gu(6)
@@ -64,16 +71,39 @@
64 iconName: "info"71 iconName: "info"
65 text: "second"72 text: "second"
66 onTriggered: print("Trigger second action")73 onTriggered: print("Trigger second action")
74 objectName: "two"
67 },75 },
68 Action {76 Action {
69 iconName: "search"77 iconName: "search"
70 text: "third"78 text: "third"
71 onTriggered: print("Trigger third action")79 onTriggered: print("Trigger third action")
80 objectName: "three"
72 },81 },
73 Action {82 Action {
74 iconName: "appointment"83 iconName: "appointment"
75 text: "fourth"84 text: "fourth"
76 onTriggered: print("Trigger fourth action")85 onTriggered: print("Trigger fourth action")
86 objectName: "four"
87 },
88 Action {
89 iconName: "attachment"
90 text: "Attach"
91 objectName: "five"
92 },
93 Action {
94 iconName: "contact"
95 text: "Contact"
96 objectName: "six"
97 },
98 Action {
99 iconName: "like"
100 text: "Like"
101 objectName: "seven"
102 },
103 Action {
104 iconName: "lock"
105 text: "Lock"
106 objectName: "eight"
77 }107 }
78 ]108 ]
79109
@@ -195,6 +225,14 @@
195 Label {225 Label {
196 text: "extension"226 text: "extension"
197 }227 }
228
229 Switch {
230 id: widthSwitch
231 checked: false
232 }
233 Label {
234 text: "Resize with window"
235 }
198 }236 }
199237
200 PageHeader {238 PageHeader {
@@ -414,6 +452,34 @@
414 "Sections is not hidden by clearing the actions.");452 "Sections is not hidden by clearing the actions.");
415 }453 }
416454
455 function wait_for_animation() {
456 // One or more action fading animations with a duration
457 // of UbuntuAnimation.BriskDuration = 333ms.
458 wait(500);
459 }
460 function check_number_of_action_slots(widthGU, numberOfSlots) {
461 var width = units.gu(widthGU);
462 if (wrapper.width < width) {
463 skip("Only for screen at least " + widthGU + " GU wide.");
464 }
465 root.width = width;
466 compare(header.trailingActionBar.numberOfSlots, numberOfSlots,
467 "Header with width " + widthGU + " GU does not have "
468 + numberOfSlots + " action slots.");
469 }
470 function test_number_of_action_slots() {
471 var initialWidth = root.width;
472 // test for the values specified in the UX specs document
473 check_number_of_action_slots(40, 3);
474 check_number_of_action_slots(50, 3);
475 check_number_of_action_slots(60, 4);
476 check_number_of_action_slots(70, 5);
477 check_number_of_action_slots(80, 6);
478 check_number_of_action_slots(90, 6);
479 check_number_of_action_slots(100, 6);
480 root.width = initialWidth;
481 }
482
417 // The properties of header.sections, header.leadingActionBar and483 // The properties of header.sections, header.leadingActionBar and
418 // header.trailingActionBar are tested in tst_sections.qml and tst_actionbar.qml.484 // header.trailingActionBar are tested in tst_sections.qml and tst_actionbar.qml.
419 }485 }

Subscribers

People subscribed via source and target branches