~agateau/unity-2d/show-launcher-from-home-button

« back to all changes in this revision

Viewing changes to launcher/LauncherItem.qml

[launcher] Implement padding in the list entirely with padding inside the items

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
    id: item
32
32
 
33
33
    anchors.horizontalCenter: parent.horizontalCenter
34
 
    /* Manually add some padding to compensate for the spacing
35
 
       of the ListView being set to 0 to work around
36
 
       http://bugreports.qt.nokia.com/browse/QTBUG-17622. */
37
 
    property int padding: 5
 
34
 
 
35
    property int padding
38
36
    height: tileSize + padding
39
37
 
40
38
    property int tileSize
70
68
           number. The following simple conditional code works and is less
71
69
           convoluted than a generic formula. It's ok since we always work with at
72
70
           most three pips anyway. */
73
 
        if (pips == 1) return 0;
 
71
        if (pips == 1) return 0
74
72
        if (pips == 2) return (index == 0) ? -2 : +2
75
73
        else return (index == 0) ? 0 : (index == 1) ? -4 : +4
76
74
    }
103
101
           the active one */
104
102
        Image {
105
103
            anchors.right: parent.right
106
 
            anchors.verticalCenter: parent.verticalCenter
 
104
            y: item.height - item.tileSize / 2 - height / 2
 
105
 
107
106
            source: "image://blended/%1color=%2alpha=%3"
108
107
                  .arg(engineBaseUrl + "artwork/launcher_arrow_rtl.png")
109
108
                  .arg("lightgrey")
110
109
                  .arg(1.0)
111
110
 
112
 
            /* This extra shift is necessary (as is for the pips below)
113
 
               since we are vertically centering in a parent with even height, so
114
 
               there's one pixel offset that need to be assigned arbitrarily.
115
 
               Unity chose to add it, QML to subtract it. So we adjust for that. */
116
 
            transform: Translate { y: 1 }
117
 
 
118
111
            visible: active && (looseItem.state != "beingDragged")
119
112
        }
120
113
 
132
125
                   printed for the following two anchor assignements. This fixes the
133
126
                   problem, but I'm not sure if it should happen in the first place. */
134
127
                anchors.left: (parent) ? parent.left : undefined
135
 
                anchors.verticalCenter: (parent) ? parent.verticalCenter : undefined
 
128
                y: item.height - item.tileSize / 2 - height / 2 + getPipOffset(index)
136
129
 
137
130
                source: "image://blended/%1color=%2alpha=%3"
138
131
                        .arg(pipSource).arg("lightgrey").arg(1.0)
139
132
 
140
 
                transform: Translate { y: getPipOffset(index) + 1 }
141
 
 
142
133
                visible: looseItem.state != "beingDragged"
143
134
            }
144
135
        }
148
139
            id: tile
149
140
            width: item.tileSize
150
141
            height: item.tileSize
151
 
            anchors.centerIn: parent
 
142
            anchors.bottom: parent.bottom
 
143
            anchors.horizontalCenter: parent.horizontalCenter
152
144
 
153
145
            /* This is the image providing the background image. The
154
146
               color blended with this image is obtained from the color of the icon when it's