Commit adf83cac authored by Sergey Chupligin's avatar Sergey Chupligin

[ButtonRow] Code style and better perfomance

parent ddf14056
...@@ -50,14 +50,20 @@ Rectangle { ...@@ -50,14 +50,20 @@ Rectangle {
Rectangle{ Rectangle{
id: selecter id: selecter
height: 50 x: rowElement.children[main.currentIndex].x || 0
y: -5 y: -5
width: rowElement.children[main.currentIndex].width || 0
height: 50
color: "#0091e5" color: "#0091e5"
z:0
visible: false visible: main.currentIndex > -1
anchors{
top: rowElement.top Behavior on x {
topMargin: -5 NumberAnimation { duration: 200 }
}
Behavior on width {
NumberAnimation { duration: 200 }
} }
} }
...@@ -69,36 +75,32 @@ Rectangle { ...@@ -69,36 +75,32 @@ Rectangle {
delegate: Rectangle { delegate: Rectangle {
id: rowItem id: rowItem
height: 50 height: 50
y: -5
width: text.width+(text.width/name.length*2) width: text.width+(text.width/name.length*2)
y: -5
color: "transparent" color: "transparent"
MouseArea { MouseArea {
enabled: main.enabled
width: parent.width width: parent.width
height: parent.height height: parent.height
enabled: main.enabled
onClicked: { onClicked: {
main.currentIndex = index main.currentIndex = index
selecter.visible = true
moveSelecter.start()
} }
} }
Label { Label {
id: text id: text
text: name text: name
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
Component.onCompleted: { Component.onCompleted: {
width = paintedWidth width = paintedWidth
} }
z:1
font.bold: main.currentIndex == index font.bold: main.currentIndex == index
} }
ParallelAnimation {
id: moveSelecter
NumberAnimation { target: selecter; property: "x"; from: selecter.x; to: rowItem.x; duration: 100}
NumberAnimation { target: selecter; property: "width"; from: selecter.width; to: rowItem.width; duration: 100}
}
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment