~cimi/unity8/card_touchdown

« back to all changes in this revision

Viewing changes to tests/plugins/Dash/cardcreator/3.res

  • Committer: Andrea Cimitan
  • Date: 2014-06-20 15:02:12 UTC
  • mfrom: (917.1.36 obeyArtShapeFixedSize)
  • Revision ID: andrea.cimitan@gmail.com-20140620150212-an6nkcv515i22usy
Merged albert branch with fixes for icon size

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
readonly property size artShapeSize: artShapeLoader.item ? Qt.size(artShapeLoader.item.width, artShapeLoader.item.height) : Qt.size(-1, -1);
17
17
Item  { 
18
18
                    id: artShapeHolder; 
19
 
                    height: root.fixedArtShapeSize.height != -1 ? root.fixedArtShapeSize.height : artShapeLoader.height; 
20
 
                    width: root.fixedArtShapeSize.width != -1 ? root.fixedArtShapeSize.width : artShapeLoader.width; 
 
19
                    height: root.fixedArtShapeSize.height > 0 ? root.fixedArtShapeSize.height : artShapeLoader.height;
 
20
                    width: root.fixedArtShapeSize.width > 0 ? root.fixedArtShapeSize.width : artShapeLoader.width;
21
21
                    anchors { horizontalCenter: parent.horizontalCenter; }
22
22
                    Loader { 
23
23
                        id: artShapeLoader; 
29
29
                            id: artShape; 
30
30
                            objectName: "artShape"; 
31
31
                            radius: "medium"; 
32
 
                            readonly property real aspect: components !== undefined ? components["art"]["aspect-ratio"] : 1; 
33
 
                            readonly property bool aspectSmallerThanImageAspect: aspect < image.aspect; 
34
 
                            Component.onCompleted: { updateWidthHeightBindings(); if (artShapeBorderSource !== undefined) borderSource = artShapeBorderSource; } 
35
 
                            onAspectSmallerThanImageAspectChanged: updateWidthHeightBindings(); 
36
32
                            visible: image.status == Image.Ready; 
37
 
                            function updateWidthHeightBindings() { 
38
 
                                if (aspectSmallerThanImageAspect) { 
39
 
                                    width = Qt.binding(function() { return !visible ? 0 : image.width }); 
40
 
                                    height = Qt.binding(function() { return !visible ? 0 : image.fillMode === Image.PreserveAspectCrop ? image.height : width / image.aspect }); 
41
 
                                } else { 
42
 
                                    width = Qt.binding(function() { return !visible ? 0 : image.fillMode === Image.PreserveAspectCrop ? image.width : height * image.aspect }); 
43
 
                                    height = Qt.binding(function() { return !visible ? 0 : image.height }); 
44
 
                                } 
 
33
                            readonly property real fixedArtShapeSizeAspect: (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) ? root.fixedArtShapeSize.width / root.fixedArtShapeSize.height : -1;
 
34
                            readonly property real aspect: fixedArtShapeSizeAspect > 0 ? fixedArtShapeSizeAspect : components !== undefined ? components["art"]["aspect-ratio"] : 1;
 
35
                            readonly property bool aspectSmallerThanImageAspect: aspect < image.aspect;
 
36
                            Component.onCompleted: { updateWidthHeightBindings(); if (artShapeBorderSource !== undefined) borderSource = artShapeBorderSource; }
 
37
                            onAspectSmallerThanImageAspectChanged: updateWidthHeightBindings();
 
38
                            Connections { target: root; onFixedArtShapeSizeChanged: updateWidthHeightBindings(); }
 
39
                            function updateWidthHeightBindings() {
 
40
                                if (root.fixedArtShapeSize.height > 0 && root.fixedArtShapeSize.width > 0) {
 
41
                                            width = root.fixedArtShapeSize.width;
 
42
                                            height = root.fixedArtShapeSize.height;
 
43
                                } else if (aspectSmallerThanImageAspect) {
 
44
                                    width = Qt.binding(function() { return !visible ? 0 : image.width });
 
45
                                    height = Qt.binding(function() { return !visible ? 0 : image.fillMode === Image.PreserveAspectCrop ? image.height : width / image.aspect });
 
46
                                } else {
 
47
                                    width = Qt.binding(function() { return !visible ? 0 : image.fillMode === Image.PreserveAspectCrop ? image.width : height * image.aspect });
 
48
                                    height = Qt.binding(function() { return !visible ? 0 : image.height });
 
49
                                }
45
50
                            } 
46
51
                            image: Image { 
47
52
                                objectName: "artImage";