on xenial help sign in
clip the corner of pinned icons as per new design
ca89475Michael Zanetti
qml/Launcher/LauncherDelegate.qml+29
@@ -27,6 +27,7 @@ Item {
27 property bool itemFocused: false
27 property bool itemFocused: false
28 property real maxAngle: 0
28 property real maxAngle: 0
29 property bool inverted: false
29 property bool inverted: false
30+ property bool clipCorner: false
30
31
31 readonly property int effectiveHeight: Math.cos(angle * Math.PI / 180) * itemHeight
32 readonly property int effectiveHeight: Math.cos(angle * Math.PI / 180) * itemHeight
32 readonly property real foldedHeight: Math.cos(maxAngle * Math.PI / 180) * itemHeight
33 readonly property real foldedHeight: Math.cos(maxAngle * Math.PI / 180) * itemHeight
@@ -150,6 +151,22 @@ Item {
150 }
151 }
151 }
152 }
152
153
154+ Item {
155+ id: clipper
156+ anchors.fill: parent
157+ Rectangle {
158+ anchors {
159+ fill: parent
160+ topMargin: -units.gu(2)
161+ leftMargin: -units.gu(2)
162+ rightMargin: -units.gu(2)
163+ bottomMargin: units.gu(1)
164+ }
165+ color: "red"
166+ rotation: root.rotation + 45
167+ }
168+ }
169+
153 ShaderEffect {
170 ShaderEffect {
154 id: transformEffect
171 id: transformEffect
155 anchors.centerIn: parent
172 anchors.centerIn: parent
@@ -159,6 +176,7 @@ Item {
159 property real itemOpacity: root.itemOpacity
176 property real itemOpacity: root.itemOpacity
160 property real brightness: Math.max(-1, root.brightness)
177 property real brightness: Math.max(-1, root.brightness)
161 property real angle: root.angle
178 property real angle: root.angle
179+ property bool clipCorner: root.clipCorner
162 rotation: root.inverted ? 180 : 0
180 rotation: root.inverted ? 180 : 0
163
181
164 property variant source: ShaderEffectSource {
182 property variant source: ShaderEffectSource {
@@ -168,6 +186,11 @@ Item {
168 live: false
186 live: false
169 }
187 }
170
188
189+ property var mask: ShaderEffectSource {
190+ sourceItem: clipper
191+ hideSource: true
192+ }
193+
171 transform: [
194 transform: [
172 // Rotating 3 times at top/bottom because that increases the perspective.
195 // Rotating 3 times at top/bottom because that increases the perspective.
173 // This is a hack, but as QML does not support real 3D coordinates
196 // This is a hack, but as QML does not support real 3D coordinates
@@ -202,13 +225,19 @@ Item {
202 fragmentShader: "
225 fragmentShader: "
203 varying highp vec2 qt_TexCoord0;
226 varying highp vec2 qt_TexCoord0;
204 uniform sampler2D source;
227 uniform sampler2D source;
228+ uniform sampler2D mask;
205 uniform lowp float brightness;
229 uniform lowp float brightness;
206 uniform lowp float itemOpacity;
230 uniform lowp float itemOpacity;
231+ uniform bool clipCorner;
207 void main(void)
232 void main(void)
208 {
233 {
209 highp vec4 sourceColor = texture2D(source, qt_TexCoord0);
234 highp vec4 sourceColor = texture2D(source, qt_TexCoord0);
235+ highp vec4 maskColor = texture2D(mask, qt_TexCoord0);
210 sourceColor.rgb = mix(sourceColor.rgb, vec3(step(0.0, brightness)), abs(brightness));
236 sourceColor.rgb = mix(sourceColor.rgb, vec3(step(0.0, brightness)), abs(brightness));
211 sourceColor *= itemOpacity;
237 sourceColor *= itemOpacity;
238+ if (clipCorner) {
239+ sourceColor *= maskColor.a;
240+ }
212 gl_FragColor = sourceColor;
241 gl_FragColor = sourceColor;
213 }"
242 }"
214 }
243 }
qml/Launcher/LauncherPanel.qml+1
@@ -156,6 +156,7 @@ Item {
156 iconName: model.icon
156 iconName: model.icon
157 count: model.count
157 count: model.count
158 progress: model.progress
158 progress: model.progress
159+ clipCorner: model.pinned
159 itemFocused: model.focused
160 itemFocused: model.focused
160 inverted: root.inverted
161 inverted: root.inverted
161 z: -Math.abs(offset)
162 z: -Math.abs(offset)
tests/mocks/Unity/Launcher/MockLauncherModel.cpp+5−1
@@ -24,10 +24,12 @@ MockLauncherModel::MockLauncherModel(QObject* parent): LauncherModelInterface(pa
24{
24{
25 MockLauncherItem *item = new MockLauncherItem("phone-app", "/usr/share/applications/phone-app.desktop", "Phone", "phone-app", this);
25 MockLauncherItem *item = new MockLauncherItem("phone-app", "/usr/share/applications/phone-app.desktop", "Phone", "phone-app", this);
26 item->setProgress(0);
26 item->setProgress(0);
27− m_list.append(item);
27+ item->setPinned(true);
28 item->setFocused(true);
28 item->setFocused(true);
29+ m_list.append(item);
29 item = new MockLauncherItem("camera-app", "/usr/share/applications/camera-app.desktop", "Camera", "camera", this);
30 item = new MockLauncherItem("camera-app", "/usr/share/applications/camera-app.desktop", "Camera", "camera", this);
30 item->setProgress(10);
31 item->setProgress(10);
32+ item->setPinned(true);
31 m_list.append(item);
33 m_list.append(item);
32 item = new MockLauncherItem("gallery-app", "/usr/share/applications/gallery-app.desktop", "Gallery", "gallery", this);
34 item = new MockLauncherItem("gallery-app", "/usr/share/applications/gallery-app.desktop", "Gallery", "gallery", this);
33 item->setProgress(50);
35 item->setProgress(50);
@@ -40,6 +42,7 @@ MockLauncherModel::MockLauncherModel(QObject* parent): LauncherModelInterface(pa
40 m_list.append(item);
42 m_list.append(item);
41 item = new MockLauncherItem("twitter-webapp", "/usr/share/applications/twitter-webapp.desktop", "Twitter", "twitter", this);
43 item = new MockLauncherItem("twitter-webapp", "/usr/share/applications/twitter-webapp.desktop", "Twitter", "twitter", this);
42 item->setCount(12);
44 item->setCount(12);
45+ item->setPinned(true);
43 m_list.append(item);
46 m_list.append(item);
44 item = new MockLauncherItem("gmail-webapp", "/usr/share/applications/gmail-webapp.desktop", "GMail", "gmail", this);
47 item = new MockLauncherItem("gmail-webapp", "/usr/share/applications/gmail-webapp.desktop", "GMail", "gmail", this);
45 item->setCount(123);
48 item->setCount(123);
@@ -51,6 +54,7 @@ MockLauncherModel::MockLauncherModel(QObject* parent): LauncherModelInterface(pa
51 item->setProgress(50);
54 item->setProgress(50);
52 item->setCount(5);
55 item->setCount(5);
53 item->setFocused(true);
56 item->setFocused(true);
57+ item->setPinned(true);
54 m_list.append(item);
58 m_list.append(item);
55 item = new MockLauncherItem("calendar-app", "/usr/share/applications/calendar-app.desktop","Calendar", "calendar", this);
59 item = new MockLauncherItem("calendar-app", "/usr/share/applications/calendar-app.desktop","Calendar", "calendar", this);
56 m_list.append(item);
60 m_list.append(item);