on xenial help sign in
clip the corner of pinned icons as per new design
commitca89475b89c2bb5bcccf451c3ba58b8409695e6e authorMichael Zanetti <michael.zanetti@canonical.com> dateWed 2 Jul 2014, 21:19 (12 years ago) parent9ecb67c
3 files changed+35−1
qml/Launcher/LauncherDelegate.qml+29 qml/Launcher/LauncherPanel.qml+1 tests/mocks/Unity/Launcher/MockLauncherModel.cpp+5−1
qml/Launcher/LauncherDelegate.qml+29
@@ -27,6 +27,7 @@ Item {
2727 property bool itemFocused: false
2828 property real maxAngle: 0
2929 property bool inverted: false
30+ property bool clipCorner: false
3031
3132 readonly property int effectiveHeight: Math.cos(angle * Math.PI / 180) * itemHeight
3233 readonly property real foldedHeight: Math.cos(maxAngle * Math.PI / 180) * itemHeight
@@ -150,6 +151,22 @@ Item {
150151 }
151152 }
152153
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+
153170 ShaderEffect {
154171 id: transformEffect
155172 anchors.centerIn: parent
@@ -159,6 +176,7 @@ Item {
159176 property real itemOpacity: root.itemOpacity
160177 property real brightness: Math.max(-1, root.brightness)
161178 property real angle: root.angle
179+ property bool clipCorner: root.clipCorner
162180 rotation: root.inverted ? 180 : 0
163181
164182 property variant source: ShaderEffectSource {
@@ -168,6 +186,11 @@ Item {
168186 live: false
169187 }
170188
189+ property var mask: ShaderEffectSource {
190+ sourceItem: clipper
191+ hideSource: true
192+ }
193+
171194 transform: [
172195 // Rotating 3 times at top/bottom because that increases the perspective.
173196 // This is a hack, but as QML does not support real 3D coordinates
@@ -202,13 +225,19 @@ Item {
202225 fragmentShader: "
203226 varying highp vec2 qt_TexCoord0;
204227 uniform sampler2D source;
228+ uniform sampler2D mask;
205229 uniform lowp float brightness;
206230 uniform lowp float itemOpacity;
231+ uniform bool clipCorner;
207232 void main(void)
208233 {
209234 highp vec4 sourceColor = texture2D(source, qt_TexCoord0);
235+ highp vec4 maskColor = texture2D(mask, qt_TexCoord0);
210236 sourceColor.rgb = mix(sourceColor.rgb, vec3(step(0.0, brightness)), abs(brightness));
211237 sourceColor *= itemOpacity;
238+ if (clipCorner) {
239+ sourceColor *= maskColor.a;
240+ }
212241 gl_FragColor = sourceColor;
213242 }"
214243 }
qml/Launcher/LauncherPanel.qml+1
@@ -156,6 +156,7 @@ Item {
156156 iconName: model.icon
157157 count: model.count
158158 progress: model.progress
159+ clipCorner: model.pinned
159160 itemFocused: model.focused
160161 inverted: root.inverted
161162 z: -Math.abs(offset)
tests/mocks/Unity/Launcher/MockLauncherModel.cpp+5−1
@@ -24,10 +24,12 @@ MockLauncherModel::MockLauncherModel(QObject* parent): LauncherModelInterface(pa
2424{
2525 MockLauncherItem *item = new MockLauncherItem("phone-app", "/usr/share/applications/phone-app.desktop", "Phone", "phone-app", this);
2626 item->setProgress(0);
27− m_list.append(item);
27+ item->setPinned(true);
2828 item->setFocused(true);
29+ m_list.append(item);
2930 item = new MockLauncherItem("camera-app", "/usr/share/applications/camera-app.desktop", "Camera", "camera", this);
3031 item->setProgress(10);
32+ item->setPinned(true);
3133 m_list.append(item);
3234 item = new MockLauncherItem("gallery-app", "/usr/share/applications/gallery-app.desktop", "Gallery", "gallery", this);
3335 item->setProgress(50);
@@ -40,6 +42,7 @@ MockLauncherModel::MockLauncherModel(QObject* parent): LauncherModelInterface(pa
4042 m_list.append(item);
4143 item = new MockLauncherItem("twitter-webapp", "/usr/share/applications/twitter-webapp.desktop", "Twitter", "twitter", this);
4244 item->setCount(12);
45+ item->setPinned(true);
4346 m_list.append(item);
4447 item = new MockLauncherItem("gmail-webapp", "/usr/share/applications/gmail-webapp.desktop", "GMail", "gmail", this);
4548 item->setCount(123);
@@ -51,6 +54,7 @@ MockLauncherModel::MockLauncherModel(QObject* parent): LauncherModelInterface(pa
5154 item->setProgress(50);
5255 item->setCount(5);
5356 item->setFocused(true);
57+ item->setPinned(true);
5458 m_list.append(item);
5559 item = new MockLauncherItem("calendar-app", "/usr/share/applications/calendar-app.desktop","Calendar", "calendar", this);
5660 m_list.append(item);