Merge lp:~tpeeters/ubuntu-ui-toolkit/10-Header-animate into lp:ubuntu-ui-toolkit/staging

Proposed by Tim Peeters
Status: Rejected
Rejected by: Tim Peeters
Proposed branch: lp:~tpeeters/ubuntu-ui-toolkit/10-Header-animate
Merge into: lp:ubuntu-ui-toolkit/staging
Diff against target: 176 lines (+65/-7)
4 files modified
components.api (+1/-0)
src/Ubuntu/Components/plugin/ucheader.cpp (+29/-2)
src/Ubuntu/Components/plugin/ucheader.h (+4/-0)
tests/unit_x11/tst_components/tst_header.qml (+31/-5)
To merge this branch: bzr merge lp:~tpeeters/ubuntu-ui-toolkit/10-Header-animate
Reviewer Review Type Date Requested Status
Tim Peeters Disapprove
PS Jenkins bot continuous-integration Approve
Review via email: mp+272422@code.launchpad.net

Commit message

Add animate property to cpp Header.

Description of the change

Add animate property to cpp Header. I added this property because the current behavior of the header is to always show without animating it in, after switching between apps.

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

document default value of animate

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

update unit tests

1657. By Tim Peeters

update components.api

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

Don't happrove this yet. We'll have a talk on Wednesday whether it is ever needed to disable animating of the header.

review: Needs Information
Revision history for this message
Tim Peeters (tpeeters) wrote :

If this bug is valid https://bugs.launchpad.net/ubuntu-ux/+bug/1500483 then we don't need the animate property.

Revision history for this message
Tim Peeters (tpeeters) wrote :

The header needs to animate when showing on app focus. MR for the current (old) Header here: https://code.launchpad.net/~tpeeters/ubuntu-ui-toolkit/11-animate-header-on-app-focus/+merge/272766

New header will have the same behavior.

review: Disapprove

Unmerged revisions

1657. By Tim Peeters

update components.api

1656. By Tim Peeters

update unit tests

1655. By Tim Peeters

document default value of animate

1654. By Tim Peeters

add animate property

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'components.api'
2--- components.api 2015-09-24 20:03:02 +0000
3+++ components.api 2015-09-28 13:41:26 +0000
4@@ -448,6 +448,7 @@
5 Ubuntu.Components.ListItems.Header 1.3: Item
6 property string text
7 Ubuntu.Components.Header 1.3: StyledItem
8+ property bool animate
9 property bool exposed
10 property Flickable flickable
11 readonly property bool moving
12
13=== modified file 'src/Ubuntu/Components/plugin/ucheader.cpp'
14--- src/Ubuntu/Components/plugin/ucheader.cpp 2015-09-23 11:35:33 +0000
15+++ src/Ubuntu/Components/plugin/ucheader.cpp 2015-09-28 13:41:26 +0000
16@@ -87,6 +87,7 @@
17 , m_previous_contentY(0)
18 , m_exposed(true)
19 , m_moving(false)
20+ , m_animate(true)
21 {
22 m_showHideAnimation->setParent(this);
23 m_showHideAnimation->setTargetObject(this);
24@@ -202,7 +203,7 @@
25 m_showHideAnimation->stop();
26 }
27 }
28- if (isComponentComplete()) {
29+ if (m_animate && isComponentComplete()) {
30 m_showHideAnimation->setFrom(y());
31 m_showHideAnimation->setTo(0.0);
32 m_showHideAnimation->start();
33@@ -224,7 +225,7 @@
34 m_showHideAnimation->stop();
35 }
36 }
37- if (isComponentComplete()) {
38+ if (m_animate && isComponentComplete()) {
39 m_showHideAnimation->setFrom(y());
40 m_showHideAnimation->setTo(-1.0*height());
41 m_showHideAnimation->start();
42@@ -277,6 +278,32 @@
43 return m_moving;
44 }
45
46+/*!
47+ * \qmlproperty bool Header::animate
48+ * Enable or disable animating of the header when exposing or hiding it
49+ * either by setting the \l exposed property, or when the user finishes
50+ * interaction with the \l flickable. Default value: true.
51+ */
52+void UCHeader::setAnimate(bool animate) {
53+ if (m_animate == animate) {
54+ return;
55+ }
56+
57+ m_animate = animate;
58+ if (!m_animate && m_moving) {
59+ m_showHideAnimation->stop();
60+ // _q_showHideAnimationRunningChanged() will update m_moving.
61+
62+ // Finish showing/hiding:
63+ if (m_exposed) {
64+ show();
65+ } else {
66+ hide();
67+ }
68+ }
69+ Q_EMIT animateChanged();
70+}
71+
72 // Called when moving due to user interaction with the flickable, or by
73 // setting m_flickable.contentY programatically.
74 void UCHeader::_q_scrolledContents() {
75
76=== modified file 'src/Ubuntu/Components/plugin/ucheader.h'
77--- src/Ubuntu/Components/plugin/ucheader.h 2015-09-22 18:24:27 +0000
78+++ src/Ubuntu/Components/plugin/ucheader.h 2015-09-28 13:41:26 +0000
79@@ -31,6 +31,7 @@
80 Q_PROPERTY(QQuickFlickable* flickable READ flickable WRITE setFlickable NOTIFY flickableChanged FINAL)
81 Q_PROPERTY(bool exposed MEMBER m_exposed WRITE setExposed NOTIFY exposedChanged FINAL)
82 Q_PROPERTY(bool moving READ moving NOTIFY movingChanged FINAL)
83+ Q_PROPERTY(bool animate MEMBER m_animate WRITE setAnimate NOTIFY animateChanged FINAL)
84
85 public:
86 explicit UCHeader(QQuickItem *parent = 0);
87@@ -40,11 +41,13 @@
88 void setFlickable(QQuickFlickable* flickable);
89 void setExposed(bool exposed);
90 bool moving();
91+ void setAnimate(bool animate);
92
93 Q_SIGNALS:
94 void flickableChanged();
95 void exposedChanged();
96 void movingChanged();
97+ void animateChanged();
98
99 protected:
100 void show();
101@@ -66,6 +69,7 @@
102 qreal m_previous_contentY;
103 bool m_exposed:1;
104 bool m_moving:1;
105+ bool m_animate:1;
106
107 // used to set the easing and duration of m_showHideAnimation
108 static UCUbuntuAnimation *s_ubuntuAnimation;
109
110=== modified file 'tests/unit_x11/tst_components/tst_header.qml'
111--- tests/unit_x11/tst_components/tst_header.qml 2015-09-22 14:13:36 +0000
112+++ tests/unit_x11/tst_components/tst_header.qml 2015-09-28 13:41:26 +0000
113@@ -82,9 +82,15 @@
114 Label {
115 text: "header exposed"
116 }
117- Item {
118- width: 1
119- height: 1
120+ Switch {
121+ id: animateSwitch
122+ checked: header.animate
123+ function trigger() {
124+ header.animate = !header.animate;
125+ }
126+ }
127+ Label {
128+ text: "animate header"
129 }
130 }
131 Button {
132@@ -163,6 +169,7 @@
133 // note: moving may be true briefly due to header height changes, but
134 // it does not change in the initialization after wait_for_exposed() above.
135 compare(header.moving, false, "Header moving initially.");
136+ compare(header.animate, true, "Header does not animate by default.");
137 }
138
139 function init() {
140@@ -268,9 +275,11 @@
141
142 function test_set_exposed_to_hide_and_show() {
143 header.exposed = false;
144- wait_for_exposed(false, "Cannot hide header by setting visible to false.");
145+ tryCompare(header, "moving", true, 1000, "Header does not start moving after setting exposed to false.");
146+ wait_for_exposed(false, "Cannot hide header by setting exposed to false.");
147 header.exposed = true;
148- wait_for_exposed(true, "Cannot show header by setting visible to true.");
149+ tryCompare(header, "moving", true, 1000, "Header does not start moving after setting exposed to true.");
150+ wait_for_exposed(true, "Cannot show header by setting exposed to true.");
151
152 // change the value of exposed twice quickly:
153 header.exposed = false;
154@@ -350,5 +359,22 @@
155
156 header.flickable = flickable;
157 }
158+
159+ function test_animate_off() {
160+ header.animate = false;
161+ compare(header.animate, false, "Cannot disable header animation.");
162+ compare(header.moving, false, "Disabling animate sets moving.");
163+ header.exposed = false;
164+ compare(header.moving, false, "Header moves while animate is off.");
165+ compare(header.exposed, false, "Header exposed is not unset instantly with animate off.");
166+ compare(header.y, -header.height, "Header is not instantly hidden by setting exposed to false with animate off.");
167+
168+ header.exposed = true;
169+ compare(header.moving, false, "Header moves after exposing it with animate off.");
170+ compare(header.exposed, true, "Header exposed is not set instantly with animate off.");
171+ compare(header.y, 0, "Header is not instantly shown by setting exposed with animate off.");
172+
173+ header.animate = true;
174+ }
175 }
176 }

Subscribers

People subscribed via source and target branches