better layout with multiple applets

This commit is contained in:
Marco Martin 2015-03-18 15:24:27 +01:00
parent ffa4137cd0
commit f9f28f75ed

View file

@ -65,7 +65,8 @@ Item {
container.animationsEnabled = false; container.animationsEnabled = false;
if (appletsSpace.lastSpacer.parent === appletsSpace.layout) { if (appletsSpace.lastSpacer.parent === appletsSpace.layout) {
before = appletsSpace.lastSpacer; //Uncomment to make the spacer the last element again
// before = appletsSpace.lastSpacer;
} }
if (before) { if (before) {
@ -172,13 +173,13 @@ Item {
onFlickingChanged: { onFlickingChanged: {
if (!draggingVertically && contentY < -headerItem.height + root.height) { if (!draggingVertically && contentY < -headerItem.height + root.height) {
scrollAnim.to = Math.round(contentY/root.height) * root.height scrollAnim.to = Math.round(contentY/root.height) * root.height - headerItem.margin
scrollAnim.running = true; scrollAnim.running = true;
} }
} }
onDraggingVerticallyChanged: { onDraggingVerticallyChanged: {
if (!draggingVertically && contentY < -headerItem.height + root.height) { if (!draggingVertically && contentY < -headerItem.height + root.height) {
scrollAnim.to = Math.round(contentY/root.height) * root.height scrollAnim.to = Math.round(contentY/root.height) * root.height - headerItem.margin
scrollAnim.running = true; scrollAnim.running = true;
} }
} }
@ -197,7 +198,8 @@ Item {
property Item layout: appletsLayout property Item layout: appletsLayout
property Item lastSpacer: spacer property Item lastSpacer: spacer
width: root.width width: root.width
height: mainLayout.Layout.minimumHeight height: mainLayout.Layout.minimumHeight + stripe.height + units.gridUnit
property int margin: stripe.height + units.gridUnit * 2
onPressAndHold: { onPressAndHold: {
plasmoid.action("configure").trigger(); plasmoid.action("configure").trigger();
@ -233,11 +235,13 @@ Item {
} }
ColumnLayout { ColumnLayout {
id: appletsLayout id: appletsLayout
Layout.minimumHeight: Math.max(root.height, Math.round(Layout.preferredHeight / root.height) * root.height) //Layout.minimumHeight: Math.max(root.height, Math.round(Layout.preferredHeight / root.height) * root.height)
Item { Item {
id: spacer id: spacer
Layout.fillWidth: true Layout.fillWidth: true
Layout.fillHeight: true Layout.fillHeight: true
Layout.minimumHeight: plasmoid.applets.length % 2 == 0 ? 0 : root.height/2
Layout.maximumHeight: Layout.minimumHeight
} }
} }
} }