use a simple Column for the layout

slightly simpler, makes animations more reliable
This commit is contained in:
Marco Martin 2015-07-10 16:00:10 +02:00
parent 21eb17fc49
commit 70551d7ad6
2 changed files with 30 additions and 76 deletions

View file

@ -46,7 +46,7 @@ MouseEventListener {
if (draggingApplet) { if (draggingApplet) {
draggingApplet.animationsEnabled = false; draggingApplet.animationsEnabled = false;
dndSpacer.Layout.minimumHeight = draggingApplet.height; dndSpacer.height = draggingApplet.height;
LayoutManager.insertBefore(draggingApplet, dndSpacer); LayoutManager.insertBefore(draggingApplet, dndSpacer);
draggingApplet.parent = headerItem; draggingApplet.parent = headerItem;
@ -134,27 +134,40 @@ MouseEventListener {
} }
} }
} }
Item { Rectangle {
id: spacer id: spacer
Layout.fillWidth: true radius: 20
Layout.fillHeight: true width: parent.width
height: plasmoid.availableScreenRect.height/4
} }
PlasmaCore.ColorScope { PlasmaCore.ColorScope {
id: colorScope id: colorScope
//TODO: decide what color we want applets //TODO: decide what color we want applets
colorGroup: PlasmaCore.Theme.NormalColorGroup colorGroup: PlasmaCore.Theme.NormalColorGroup
Layout.fillWidth: true Layout.fillWidth: true
Layout.minimumHeight: appletsLayout.Layout.minimumHeight Layout.minimumHeight: appletsLayout.implicitHeight
Layout.maximumHeight: appletsLayout.Layout.maximumHeight Layout.maximumHeight: appletsLayout.implicitHeight
ColumnLayout { Column {
id: appletsLayout id: appletsLayout
width: parent.width
move: Transition {
NumberAnimation {
properties: "x,y"
duration: units.longDuration
easing.type: Easing.InOutQuad
}
}
add: Transition {
NumberAnimation {
properties: "x,y"
duration: units.longDuration
easing.type: Easing.InOutQuad
}
}
} }
Item { Item {
id: dndSpacer id: dndSpacer
Layout.fillWidth: true width: parent.width
Layout.fillHeight: true
Layout.minimumHeight: plasmoid.applets.length % 2 == 0 ? 0 : (root.height - margin)/2
Layout.maximumHeight: Layout.minimumHeight
} }
} }
Item { Item {

View file

@ -74,9 +74,7 @@ Item {
//startupTimer.restart(); //startupTimer.restart();
} }
if (applet.Layout.fillWidth) { checkLastSpacer()
appletsSpace.lastSpacer.parent = root;
}
} }
//Autoscroll related functions //Autoscroll related functions
@ -103,19 +101,9 @@ Item {
function checkLastSpacer() { function checkLastSpacer() {
appletsSpace.lastSpacer.parent = root appletsSpace.lastSpacer.parent = root
var expands = false; if (appletsSpace.layout.children.length <= 1) {
for (var container in appletsSpace.layout.children) {
var item = appletsSpace.layout.children[container];
if (item.Layout && item.Layout.fillHeight) {
expands = true;
}
}
if (!expands) {
appletsSpace.lastSpacer.parent = appletsSpace.layout; appletsSpace.lastSpacer.parent = appletsSpace.layout;
} }
} }
@ -184,9 +172,6 @@ Item {
opacity: 1/Math.abs(x/(width/2)) opacity: 1/Math.abs(x/(width/2))
Layout.fillWidth: true Layout.fillWidth: true
Layout.fillHeight: applet && applet.Layout.fillHeight Layout.fillHeight: applet && applet.Layout.fillHeight
Layout.onFillHeightChanged: {
checkLastSpacer();
}
Connections { Connections {
target: plasmoid target: plasmoid
@ -204,12 +189,7 @@ Item {
applet.anchors.margins = background.margins.top; applet.anchors.margins = background.margins.top;
} }
} }
onAnimationsEnabledChanged: {
if (!animationsEnabled) {
translation.x = 0;
translation.y = 0;
}
}
property int oldX: x property int oldX: x
property int oldY: y property int oldY: y
PlasmaCore.FrameSvgItem { PlasmaCore.FrameSvgItem {
@ -220,14 +200,8 @@ Item {
visible: applet.backgroundHints == PlasmaCore.Types.StandardBackground visible: applet.backgroundHints == PlasmaCore.Types.StandardBackground
} }
Layout.minimumWidth: root.width width: parent.width
Layout.minimumHeight: Math.max(applet.Layout.minimumHeight, (root.height-applicationsView.headerItem.margin) / 2) height: Math.max(applet.Layout.minimumHeight, (root.height-applicationsView.headerItem.margin) / 2)
Layout.preferredWidth: root.width
Layout.preferredHeight: Layout.minimumHeight
Layout.maximumWidth: root.width
Layout.maximumHeight: Layout.minimumHeight
PlasmaComponents.BusyIndicator { PlasmaComponents.BusyIndicator {
z: 1000 z: 1000
@ -237,40 +211,7 @@ Item {
width: Math.min(parent.width, parent.height) width: Math.min(parent.width, parent.height)
height: width height: width
} }
onXChanged: { Component.onDestruction: checkLastSpacer();
return;
if (!animationsEnabled) {
return;
}
translation.x = oldX - x;
translation.y = oldY - y;
translAnim.running = true;
oldX = x;
oldY = y;
}
onYChanged: {
return;
if (!animationsEnabled) {
return;
}
translation.x = oldX - x;
translation.y = oldY - y;
translAnim.running = true;
oldX = x;
oldY = y;
}
transform: Translate {
id: translation
onYChanged: print(y)
}
NumberAnimation {
id: translAnim
duration: units.longDuration
easing.type: Easing.InOutQuad
target: translation
properties: "x,y"
to: 0
}
} }
} }