1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-09-03 02:42:52 +02:00

PathView should be quite good now

This commit is contained in:
Michael Zanetti
2012-11-25 18:14:48 +01:00
parent 2e2a566061
commit 166db57ec3
2 changed files with 51 additions and 14 deletions

View File

@@ -26,10 +26,28 @@ PathView {
pathItemCount: 5 pathItemCount: 5
//highlightMoveDuration: 500 //highlightMoveDuration: 500
delegate: CoverImage { property bool itemHovered: false
delegate: Item {
id: delegateItem
height: root.coverSize
width: root.coverSize
scale: PathView.itemScale
// itemBrightness: PathView.itemBrightness - ((coverView.itemHovered && !coverDelegate.containsMouse) ? .4 : 0)
property double itemBrightness: PathView.itemBrightness
property double itemOpacity: PathView.itemOpacity
z: coverView.width - x
CoverImage {
id: coverDelegate id: coverDelegate
height: root.coverSize height: root.coverSize
width: root.coverSize width: root.coverSize
anchors {
top: parent.top
right: parent.right
}
backgroundColor: coverView.backgroundColor backgroundColor: coverView.backgroundColor
showLabels: true showLabels: true
@@ -40,9 +58,9 @@ PathView {
showPlayButton: true showPlayButton: true
currentlyPlaying: isPlaying currentlyPlaying: isPlaying
scale: PathView.itemScale // itemBrightness: PathView.itemBrightness - ((coverView.itemHovered && !coverDelegate.containsMouse) ? .4 : 0)
itemBrightness: PathView.itemBrightness itemBrightness: coverDelegate.containsMouse ? 1 : parent.itemBrightness * (coverView.itemHovered ? .5 : 1)
opacity: PathView.itemOpacity opacity: parent.itemOpacity
z: coverView.width - x z: coverView.width - x
property int _origX property int _origX
@@ -58,24 +76,25 @@ PathView {
coverView.itemClicked(index) coverView.itemClicked(index)
} }
function newZ() {
return z;
}
onContainsMouseChanged: { onContainsMouseChanged: {
if (containsMouse) { if (containsMouse) {
_origX = x; _origX = x;
_origY = y; _origY = y;
_origZ = z; _origZ = z;
coverView.itemHovered = true
} else {
coverView.itemHovered = false
} }
} }
}
states: [ states: [
State { State {
name: "hovered"; when: coverDelegate.containsMouse && index !== currentIndex name: "hovered"; when: coverDelegate.containsMouse && !coverView.moving && index !== currentIndex
PropertyChanges { PropertyChanges {
target: coverDelegate target: delegateItem
x: _origX + coverDelegate.width * coverDelegate.scale / 2 width: root.coverSize * 2
z: _origZ z: _origZ
} }
} }
@@ -83,14 +102,13 @@ PathView {
transitions: [ transitions: [
Transition { Transition {
NumberAnimation { NumberAnimation {
properties: "x" properties: "width"
duration: 300 duration: 300
easing.type: Easing.InOutSine easing.type: Easing.InOutSine
} }
} }
] ]
} }
path: Path { path: Path {

View File

@@ -67,6 +67,7 @@ Item {
Rectangle { Rectangle {
id: textBackground id: textBackground
anchors { left: parent.left; right: parent.right; bottom: parent.bottom } anchors { left: parent.left; right: parent.right; bottom: parent.bottom }
anchors.margins: -1
height: (artistText.height + trackText.height) * 2 height: (artistText.height + trackText.height) * 2
opacity: 1// showLabels ? 1 : 0 opacity: 1// showLabels ? 1 : 0
radius: 3 radius: 3
@@ -131,7 +132,25 @@ Item {
anchors.rightMargin: -2 anchors.rightMargin: -2
anchors.topMargin: -2 anchors.topMargin: -2
opacity: 1 - itemBrightness + (mouseArea.containsMouse ? .2 : 0) opacity: 1 - itemBrightness
Behavior on opacity {
NumberAnimation { easing.type: Easing.Linear; duration: 300 }
}
}
Rectangle {
id: itemGlow
color: "white"
anchors.fill: parent
anchors.bottomMargin: - parent.height
// scaling might be off a pixel... make sure that the shadow is at least as large as the image
anchors.leftMargin: -2
anchors.rightMargin: -2
anchors.topMargin: -2
opacity: mouseArea.containsMouse ? .2 : 0
Behavior on opacity { Behavior on opacity {
NumberAnimation { easing.type: Easing.Linear; duration: 300 } NumberAnimation { easing.type: Easing.Linear; duration: 300 }