on xenial help sign in
Add shadows
commit1bc5ffd31336604c1a827b2c2e2ae63c2eba162e authorAndrea Cimitan <andrea.cimitan@gmail.com> dateTue 28 Jul 2015, 11:13 (11 years ago) parent8125c22
6 files changed+39−33
plugins/Dash/CardCreator.js+24−7 qml/Components/ResponsiveGridView.qml+1 qml/Dash/CardCarousel.qml+1−10 qml/Dash/CardGrid.qml+5−1 qml/Launcher/LauncherDelegate.qml+3−14 tests/mocks/Unity/fake_categories.cpp+5−1
plugins/Dash/CardCreator.js+24−7
@@ -78,13 +78,30 @@ var kArtShapeHolderCode = 'Item { \n\
7878 height: 1; \n\
7979 hideSource: doShapeItem; \n\
8080 } \n\
81− UbuntuShape { \n\
82− id: artShapeShape; \n\
83− source: artShapeSource; \n\
81+ Loader { \n\
8482 anchors.fill: parent; \n\
85− visible: doShapeItem; \n\
86− radius: "medium"; \n\
87− aspect: root.artShapeStyle === "inset" ? UbuntuShape.Inset : UbuntuShape.Flat; \n\
83+ visible: artShape.doShapeItem; \n\
84+ sourceComponent: root.artShapeStyle === "icon" ? artShapeIconComponent : artShapeShapeComponent; \n\
85+ Component { \n\
86+ id: artShapeShapeComponent; \n\
87+ UbuntuShape { \n\
88+ source: artShapeSource; \n\
89+ sourceFillMode: UbuntuShape.PreserveAspectCrop; \n\
90+ radius: "medium"; \n\
91+ aspect: { \n\
92+ switch (root.artShapeStyle) { \n\
93+ case "inset": return UbuntuShape.Inset; \n\
94+ case "shadow": return UbuntuShape.DropShadow; \n\
95+ default: \n\
96+ case "flat": return UbuntuShape.Flat; \n\
97+ } \n\
98+ } \n\
99+ } \n\
100+ } \n\
101+ Component { \n\
102+ id: artShapeIconComponent; \n\
103+ UbuntuShapeIcon { source: artShapeSource; } \n\
104+ } \n\
88105 } \n\
89106 readonly property real fixedArtShapeSizeAspect: (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) ? root.fixedArtShapeSize.width / root.fixedArtShapeSize.height : -1; \n\
90107 readonly property real aspect: fixedArtShapeSizeAspect > 0 ? fixedArtShapeSizeAspect : components !== undefined ? components["art"]["aspect-ratio"] : 1; \n\
@@ -236,7 +253,7 @@ var kTouchdownCode = 'UbuntuShape { \n\
236253 id: touchdown; \n\
237254 objectName: "touchdown"; \n\
238255 anchors { %1 } \n\
239− visible: root.pressed; \n\
256+ visible: root.artShapeStyle != "shadow" && root.artShapeStyle != "icon" && root.pressed; \n\
240257 radius: "medium"; \n\
241258 borderSource: "radius_pressed.sci" \n\
242259 }\n';
qml/Components/ResponsiveGridView.qml+1
@@ -50,6 +50,7 @@ Item {
5050 property alias highlightIndex: gridView.highlightIndex
5151 property alias cacheBuffer: gridView.cacheBuffer
5252 readonly property alias currentItem: gridView.currentItem
53+ property alias topMargin: gridView.topMargin
5354
5455 function contentHeightForRows(rows, height) {
5556 return rows * height
qml/Dash/CardCarousel.qml+1−10
@@ -64,18 +64,9 @@ DashRenderer {
6464 item.components = Qt.binding(function() { return cardTool.components; });
6565 item.fontScale = Qt.binding(function() { return carousel.fontScale; });
6666 item.showHeader = Qt.binding(function() { return loader.explicitlyScaled; });
67− item.artShapeStyle = "flat";
67+ item.artShapeStyle = "shadow";
6868 item.scopeStyle = cardCarousel.scopeStyle;
6969 }
70−
71− BorderImage {
72− anchors {
73− fill: parent
74− margins: -units.gu(1)
75− }
76− z: -1
77− source: "graphics/carousel_dropshadow.sci"
78− }
7970 }
8071 }
8172}
qml/Dash/CardGrid.qml+5−1
@@ -24,7 +24,9 @@ DashRenderer {
2424 if (!cardTool || !cardTool.template || typeof cardTool.template["collapsed-rows"] != "number") return 2;
2525 return cardTool.template["collapsed-rows"];
2626 }
27−
27+ // hackish, relies on GenericScopeView.qml:335 tweak to detect application icons in click scope
28+ readonly property var artShapeStyle: cardTool.artShapeSize === Qt.size(units.gu(8), units.gu(7.5)) ? "icon" : "inset";
29+
2830 expandedHeight: grid.totalContentHeight
2931 collapsedHeight: Math.min(grid.contentHeightForRows(collapsedRows, grid.cellHeight), expandedHeight)
3032 collapsedItemCount: collapsedRows * grid.columns
@@ -52,6 +54,7 @@ DashRenderer {
5254 displayMarginEnd: root.displayMarginEnd
5355 cacheBuffer: root.cacheBuffer
5456 interactive: false
57+ topMargin: root.artShapeStyle === "icon" ? units.gu(0.1) : 0 // otherwise when we have a shadow, its top is clipped
5558 delegate: Item {
5659 width: grid.cellWidth
5760 height: grid.cellHeight
@@ -69,6 +72,7 @@ DashRenderer {
6972 item.components = Qt.binding(function() { return cardTool.components; });
7073 item.titleAlignment = Qt.binding(function() { return cardTool.titleAlignment; });
7174 item.scopeStyle = root.scopeStyle;
75+ item.artShapeStyle = root.artShapeStyle;
7276 }
7377 Connections {
7478 target: loader.item
qml/Launcher/LauncherDelegate.qml+3−14
@@ -46,13 +46,10 @@ Item {
4646 height: parent.itemHeight + units.gu(1)
4747 anchors.centerIn: parent
4848
49− UbuntuShape {
49+ UbuntuShapeIcon {
5050 id: iconShape
51− anchors.fill: parent
52− anchors.margins: units.gu(1)
53− radius: "medium"
54− aspect: UbuntuShape.Flat
55− sourceFillMode: UbuntuShape.PreserveAspectCrop
51+ anchors.centerIn: parent
52+ width: parent.width - units.gu(2);
5653 source: Image {
5754 id: iconImage
5855 sourceSize.width: iconShape.width
@@ -61,14 +58,6 @@ Item {
6158 }
6259 }
6360
64− BorderImage {
65− id: itemGlow
66− anchors.centerIn: iconItem
67− source: "graphics/icon-top-highlight.png"
68− width: root.itemWidth - units.gu(1)
69− height: root.itemHeight - units.gu(1)
70− }
71−
7261 UbuntuShape {
7362 id: countEmblem
7463 objectName: "countEmblem"
tests/mocks/Unity/fake_categories.cpp+5−1
@@ -52,7 +52,11 @@ Categories::data(const QModelIndex& index, int role) const
5252 ResultsModel *resultsModel = resultModel(index.row());
5353 switch (role) {
5454 case RoleCategoryId:
55− return QString("%1").arg(index.row());
55+ if (index.row() == 0) {
56+ return QString("predefined");
57+ } else if (index.row() == 2) {
58+ return QString("local");
59+ }
5660 case RoleName:
5761 return QString("Category %1").arg(index.row());
5862 case RoleIcon: