Commit b598a943 authored by Sergey Chupligin's avatar Sergey Chupligin

[ButtonRow] selector fix

parent 79e76a7e
...@@ -39,21 +39,36 @@ Rectangle { ...@@ -39,21 +39,36 @@ Rectangle {
height: 40 height: 40
property ListModel model: ListModel {} property ListModel model: ListModel {}
property bool enabled: true property bool enabled: true
property int currentIndex: -1
signal selected(string sel) signal selected(string sel)
Image { Image {
anchors.fill: parent anchors.fill: parent
visible: !main.enabled visible: !main.enabled
source: "images/disabled-overlay.png" source: "images/disabled-overlay.png"
fillMode: Image.Tile fillMode: Image.Tile
} }
Rectangle{
id: selecter
height: 50
y: -5
color: "#0091e5"
z:0
visible: false
anchors{
top: rowElement.top
topMargin: -5
}
}
Row { Row {
spacing: 0 id: rowElement
Repeater { Repeater {
id: rectangles id: rectangles
model: main.model model: main.model
delegate: delegate: Rectangle {
Rectangle { id: rowItem
property bool active: false
height: 50 height: 50
y: -5 y: -5
width: text.width+(text.width/name.length*2) width: text.width+(text.width/name.length*2)
...@@ -64,15 +79,9 @@ Rectangle { ...@@ -64,15 +79,9 @@ Rectangle {
width: parent.width width: parent.width
height: parent.height height: parent.height
onClicked: { onClicked: {
if (!parent.active) { main.currentIndex = index
text.font.bold = true selecter.visible = true
parent.color = "#0091e5" moveSelecter.start()
parent.active = true
} else {
text.font.bold = false
parent.color = "transparent"
parent.active = false
}
main.selected(name) main.selected(name)
} }
} }
...@@ -83,6 +92,14 @@ Rectangle { ...@@ -83,6 +92,14 @@ Rectangle {
Component.onCompleted: { Component.onCompleted: {
width = paintedWidth width = paintedWidth
} }
z:1
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