Merge lp:~nick-dedekind/unity/lp893140.launcher-icon-feedback into lp:unity

Proposed by Nick Dedekind on 2012-10-26
Status: Merged
Approved by: Marco Trevisan (Treviño) on 2012-11-12
Approved revision: 2869
Merged at revision: 2891
Proposed branch: lp:~nick-dedekind/unity/lp893140.launcher-icon-feedback
Merge into: lp:unity
Diff against target: 205 lines (+58/-70)
2 files modified
launcher/Launcher.cpp (+14/-2)
tests/test_launcher.cpp (+44/-68)
To merge this branch: bzr merge lp:~nick-dedekind/unity/lp893140.launcher-icon-feedback
Reviewer Review Type Date Requested Status
John Lea (community) design 2012-11-06 Approve on 2012-11-14
Marco Trevisan (Treviño) Approve on 2012-11-12
Brandon Schaefer (community) Approve on 2012-11-09
Stephen M. Webb (community) 2012-10-26 Needs Fixing on 2012-11-07
PS Jenkins bot continuous-integration Pending
Review via email: mp+131576@code.launchpad.net

Commit Message

Inverted launcher icon blink/pulse on application start for immediate feedback. (LP: #893140)

Description of the Change

= Problem description =

https://bugs.launchpad.net/ayatana-design/+bug/893140

= The fix =

Inverted launcher icon blink/pulse on application start for immediate feedback.

= Test coverage =

Unit test for correct icon blink/pulse values at start of animation.

To post a comment you must log in.
Nick Dedekind (nick-dedekind) wrote :

Transition:
http://ubuntuone.com/1k07OmG8oVHj7nquAXa4eJ

Unfortunately you can't actually see when the mouse is clicked to activate the application, but you will have to trust that it's at the point of the start of the icon background inversion.

Brandon Schaefer (brandontschaefer) wrote :

Awesome looks good, and works for me. Possibly a manual test?

Didier Roche (didrocks) wrote :

Hey Bradon, Nick,

as discussed during the week pre-UDS, no more manual tests permitted as we will have automated daily upload to ubuntu, and so, no way to have manual perf performed before a release. Please instrument this part of code so that we can have an unit test.

Stephen M. Webb (bregma) wrote :

Needs test.

review: Needs Fixing
2868. By Nick Dedekind on 2012-11-08

Added launcher icon blink/pulse test.

Nick Dedekind (nick-dedekind) wrote :

Added unit tests

Brandon Schaefer (brandontschaefer) wrote :

Looks good, unit tests pass (though...a bit evil). When the conflict gets fixed, and JohnLea apporves this is ready for a merge.

review: Approve
2869. By Nick Dedekind on 2012-11-09

Merge with trunk.

Nick Dedekind (nick-dedekind) wrote :

fixed conflicts.

Marco Trevisan (Treviño) (3v1n0) wrote :

Looks good to me.

review: Approve
Nick Dedekind (nick-dedekind) wrote :

This is a UI feature.
Not supposed to be approved without design approval!

John Lea (johnlea) :
review: Approve (design)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'launcher/Launcher.cpp'
2--- launcher/Launcher.cpp 2012-11-08 09:12:24 +0000
3+++ launcher/Launcher.cpp 2012-11-09 09:21:19 +0000
4@@ -640,15 +640,27 @@
5
6 float Launcher::IconStartingBlinkValue(AbstractLauncherIcon::Ptr const& icon, struct timespec const& current) const
7 {
8+ if (icon->GetQuirk(AbstractLauncherIcon::Quirk::RUNNING))
9+ return 1.0f;
10+
11+ if (!icon->GetQuirk(AbstractLauncherIcon::Quirk::STARTING))
12+ return 1.0f;
13+
14 struct timespec starting_time = icon->GetQuirkTime(AbstractLauncherIcon::Quirk::STARTING);
15 int starting_ms = unity::TimeUtil::TimeDelta(&current, &starting_time);
16 double starting_progress = (double) CLAMP((float) starting_ms / (float)(ANIM_DURATION_LONG * STARTING_BLINK_LAMBDA), 0.0f, 1.0f);
17 double val = IsBackLightModeToggles() ? 3.0f : 4.0f;
18- return 0.5f + (float)(std::cos(M_PI * val * starting_progress)) * 0.5f;
19+ return 1.0f-(0.5f + (float)(std::cos(M_PI * val * starting_progress)) * 0.5f);
20 }
21
22 float Launcher::IconStartingPulseValue(AbstractLauncherIcon::Ptr const& icon, struct timespec const& current) const
23 {
24+ if (icon->GetQuirk(AbstractLauncherIcon::Quirk::RUNNING))
25+ return 1.0f;
26+
27+ if (!icon->GetQuirk(AbstractLauncherIcon::Quirk::STARTING))
28+ return 1.0f;
29+
30 struct timespec starting_time = icon->GetQuirkTime(AbstractLauncherIcon::Quirk::STARTING);
31 int starting_ms = unity::TimeUtil::TimeDelta(&current, &starting_time);
32 double starting_progress = (double) CLAMP((float) starting_ms / (float)(ANIM_DURATION_LONG * MAX_STARTING_BLINKS * STARTING_BLINK_LAMBDA * 2), 0.0f, 1.0f);
33@@ -659,7 +671,7 @@
34 icon->ResetQuirkTime(AbstractLauncherIcon::Quirk::STARTING);
35 }
36
37- return 0.5f + (float)(std::cos(M_PI * (float)(MAX_STARTING_BLINKS * 2) * starting_progress)) * 0.5f;
38+ return 1.0f-(0.5f + (float)(std::cos(M_PI * (float)(MAX_STARTING_BLINKS * 2) * starting_progress)) * 0.5f);
39 }
40
41 float Launcher::IconBackgroundIntensity(AbstractLauncherIcon::Ptr const& icon, struct timespec const& current) const
42
43=== modified file 'tests/test_launcher.cpp'
44--- tests/test_launcher.cpp 2012-11-06 18:19:09 +0000
45+++ tests/test_launcher.cpp 2012-11-09 09:21:19 +0000
46@@ -80,65 +80,22 @@
47 return AbstractLauncherIcon::Ptr();
48 }
49
50- float IconBackgroundIntensity(AbstractLauncherIcon::Ptr const& icon, timespec const& current) const
51- {
52- return Launcher::IconBackgroundIntensity(icon, current);
53- }
54-
55- void StartIconDrag(AbstractLauncherIcon::Ptr const& icon)
56- {
57- Launcher::StartIconDrag(icon);
58- }
59-
60- void ShowDragWindow()
61- {
62- Launcher::ShowDragWindow();
63- }
64-
65- void EndIconDrag()
66- {
67- Launcher::EndIconDrag();
68- }
69-
70- void UpdateDragWindowPosition(int x, int y)
71- {
72- Launcher::UpdateDragWindowPosition(x, y);
73- }
74-
75- void HideDragWindow()
76- {
77- Launcher::HideDragWindow();
78- }
79-
80- void ResetMouseDragState()
81- {
82- Launcher::ResetMouseDragState();
83- }
84-
85- bool DndIsSpecialRequest(std::string const& uri) const
86- {
87- return Launcher::DndIsSpecialRequest(uri);
88- }
89-
90- int GetDragIconPosition() const
91- {
92- return _drag_icon_position;
93- }
94-
95- void ProcessDndEnter()
96- {
97- Launcher::ProcessDndEnter();
98- }
99-
100- void ProcessDndLeave()
101- {
102- Launcher::ProcessDndLeave();
103- }
104-
105- void ProcessDndMove(int x, int y, std::list<char*> mimes)
106- {
107- Launcher::ProcessDndMove(x, y, mimes);
108- }
109+ using Launcher::IconBackgroundIntensity;
110+ using Launcher::StartIconDrag;
111+ using Launcher::ShowDragWindow;
112+ using Launcher::EndIconDrag;
113+ using Launcher::UpdateDragWindowPosition;
114+ using Launcher::HideDragWindow;
115+ using Launcher::ResetMouseDragState;
116+ using Launcher::DndIsSpecialRequest;
117+ using Launcher::ProcessDndEnter;
118+ using Launcher::ProcessDndLeave;
119+ using Launcher::ProcessDndMove;
120+ using Launcher::ProcessDndDrop;
121+ using Launcher::_drag_icon_position;
122+
123+ using Launcher::IconStartingBlinkValue;
124+ using Launcher::IconStartingPulseValue;
125
126 void FakeProcessDndMove(int x, int y, std::list<std::string> uris)
127 {
128@@ -158,11 +115,6 @@
129
130 _dnd_hovered_icon = MouseIconIntersection(x, y);
131 }
132-
133- void ProcessDndDrop(int x, int y)
134- {
135- Launcher::ProcessDndDrop(x, y);
136- }
137 };
138
139 TestLauncher()
140@@ -354,7 +306,7 @@
141 // Start dragging icon2
142 launcher_->StartIconDrag(icon2);
143 launcher_->ShowDragWindow();
144- ASSERT_EQ(launcher_->GetDragIconPosition(), model_->IconIndex(icon2));
145+ ASSERT_EQ(launcher_->_drag_icon_position, model_->IconIndex(icon2));
146
147 // Moving icon2 at the end
148 auto const& center3 = icon3->GetCenter(launcher_->monitor());
149@@ -364,7 +316,7 @@
150 model_->saved.connect([&model_saved] { model_saved = true; });
151 EXPECT_CALL(*icon2, Stick(false));
152
153- ASSERT_NE(launcher_->GetDragIconPosition(), model_->IconIndex(icon2));
154+ ASSERT_NE(launcher_->_drag_icon_position, model_->IconIndex(icon2));
155 launcher_->EndIconDrag();
156
157 // The icon order should be reset
158@@ -391,7 +343,7 @@
159 // Start dragging icon2
160 launcher_->StartIconDrag(icon2);
161 launcher_->ShowDragWindow();
162- ASSERT_EQ(launcher_->GetDragIconPosition(), model_->IconIndex(icon2));
163+ ASSERT_EQ(launcher_->_drag_icon_position, model_->IconIndex(icon2));
164
165 // Moving icon2 at the end
166 auto center3 = icon3->GetCenter(launcher_->monitor());
167@@ -408,7 +360,7 @@
168 bool model_saved = false;
169 model_->saved.connect([&model_saved] { model_saved = true; });
170
171- ASSERT_EQ(launcher_->GetDragIconPosition(), model_->IconIndex(icon2));
172+ ASSERT_EQ(launcher_->_drag_icon_position, model_->IconIndex(icon2));
173 launcher_->EndIconDrag();
174
175 // The icon order should be reset
176@@ -524,6 +476,30 @@
177 EXPECT_TRUE(add_request);
178 }
179
180+TEST_F(TestLauncher, IconStartingPulseValue)
181+{
182+ struct timespec current;
183+ clock_gettime(CLOCK_MONOTONIC, &current);
184+ MockMockLauncherIcon::Ptr icon(new MockMockLauncherIcon);
185+
186+ icon->SetQuirk(AbstractLauncherIcon::Quirk::STARTING, true);
187+
188+ // Pulse value should start at 0.
189+ EXPECT_EQ(launcher_->IconStartingPulseValue(icon, current), 0.0);
190+}
191+
192+TEST_F(TestLauncher, IconStartingBlinkValue)
193+{
194+ struct timespec current;
195+ clock_gettime(CLOCK_MONOTONIC, &current);
196+ MockMockLauncherIcon::Ptr icon(new MockMockLauncherIcon);
197+
198+ icon->SetQuirk(AbstractLauncherIcon::Quirk::STARTING, true);
199+
200+ // Pulse value should start at 0.
201+ EXPECT_EQ(launcher_->IconStartingBlinkValue(icon, current), 0.0);
202+}
203+
204 }
205 }
206