Commit e8d87ece authored by Sergey Chupligin's avatar Sergey Chupligin Committed by Aleksi Suomalainen

[SelectRoller] Add GlacierRollerItem

parent f9f34745
...@@ -45,26 +45,13 @@ Page { ...@@ -45,26 +45,13 @@ Page {
clip: true clip: true
model: animalsModel model: animalsModel
label: qsTr("Choose your favorite animal") label: qsTr("Choose your favorite animal")
delegate:Text{ delegate: GlacierRollerItem{
Text{
height: simpleRoller.itemHeight height: simpleRoller.itemHeight
text: name text: name
color: "white" color: "white"
font.pixelSize: 32 font.pixelSize: 32
font.bold: (simpleRoller.active && ListView.view.currentIndex === index) font.bold: (simpleRoller.activated && simpleRoller.currentIndex === index)
MouseArea{
anchors.fill: parent
onClicked: {
if(!simpleRoller.active)
{
simpleRoller.active = true;
}
else
{
simpleRoller.currentIndex = index
simpleRoller.active = false
}
}
} }
} }
} }
...@@ -80,26 +67,14 @@ Page { ...@@ -80,26 +67,14 @@ Page {
clip: true clip: true
model: animalsModel model: animalsModel
label: qsTr("Choose your second favorite animal") label: qsTr("Choose your second favorite animal")
delegate:Text{
delegate: GlacierRollerItem{
Text{
height: simpleRoller2.itemHeight height: simpleRoller2.itemHeight
text: name text: name
color: "white" color: "white"
font.pixelSize: 32 font.pixelSize: 32
font.bold: (simpleRoller2.active && ListView.view.currentIndex === index) font.bold: (simpleRoller2.activated && simpleRoller2.currentIndex === index)
MouseArea{
anchors.fill: parent
onClicked: {
if(!simpleRoller2.active)
{
simpleRoller2.active = true;
}
else
{
simpleRoller2.currentIndex = index
simpleRoller2.active = false
}
}
} }
} }
} }
......
...@@ -5,12 +5,11 @@ Item { ...@@ -5,12 +5,11 @@ Item {
property alias model : view.model property alias model : view.model
property alias label: label.text property alias label: label.text
property alias delegate: view.delegate property alias delegate: view.delegate
property int currentIndex: -1 property int currentIndex: -1
property int activateSize: 5 property int activateSize: 5
property int itemHeight: 40 property alias itemHeight: view.itemHeight
property bool active: false property bool activated: false
signal clicked(); signal clicked();
signal select(int currentItem); signal select(int currentItem);
...@@ -50,11 +49,13 @@ Item { ...@@ -50,11 +49,13 @@ Item {
z: 2 z: 2
} }
ListView{ PathView{
id: view id: view
property int itemHeight: 40
property bool showRow: false
interactive: active interactive: activated
width: parent.width width: parent.width-60
height: 40 height: 40
clip: true clip: true
...@@ -65,58 +66,45 @@ Item { ...@@ -65,58 +66,45 @@ Item {
leftMargin: 30 leftMargin: 30
} }
snapMode: ListView.SnapToItem pathItemCount: height/itemHeight
preferredHighlightBegin: 0.5
Image{ preferredHighlightEnd: 0.5
id: arrowDown dragMargin: view.width
source: "images/glacierroller-icon-arrow-down.svg"
width: itemHeight/4
height: width
sourceSize.width: width
sourceSize.height: height
x: view.currentItem.width+25 path: Path {
startX: view.width/2; startY: 0
anchors{ PathLine { x: view.width/2; y: view.pathItemCount*itemHeight }
verticalCenter: view.verticalCenter
} }
MouseArea{ snapMode: PathView.SnapToItem
anchors.fill: parent
onClicked: {
active = true
}
}
}
} }
Component.onCompleted: { Component.onCompleted: {
if(active) if(activated)
{ {
view.showRow = false
bottomLine.opacity = 1 bottomLine.opacity = 1
topLine.opacity = 1 topLine.opacity = 1
view.height = itemHeight*activateSize view.height = itemHeight*activateSize
arrowDown.visible = false
} }
else else
{ {
view.showRow = true
bottomLine.opacity = 0 bottomLine.opacity = 0
topLine.opacity = 0 topLine.opacity = 0
view.height = itemHeight view.height = itemHeight
arrowDown.visible = true
} }
} }
onCurrentIndexChanged: { onCurrentIndexChanged: {
view.currentIndex = currentIndex view.currentIndex = currentIndex
arrowDown.x = view.currentItem.width+25
} }
onActiveChanged: { onActivatedChanged: {
if(active) if(activated)
{ {
arrowDown.visible = false view.showRow = false
activateAnimations.start() activateAnimations.start()
} }
else else
...@@ -128,18 +116,18 @@ Item { ...@@ -128,18 +116,18 @@ Item {
ParallelAnimation { ParallelAnimation {
id: activateAnimations id: activateAnimations
NumberAnimation{target: bottomLine; property: "opacity"; to: 1; duration: 400} NumberAnimation{target: bottomLine; property: "opacity"; to: 1; duration: 250}
NumberAnimation{target: topLine; property: "opacity"; to: 1; duration: 400} NumberAnimation{target: topLine; property: "opacity"; to: 1; duration: 250}
NumberAnimation{target: view; property: "height"; to: itemHeight*activateSize; duration: 400} NumberAnimation{target: view; property: "height"; to: itemHeight*activateSize; duration: 250}
} }
ParallelAnimation { ParallelAnimation {
id: deActivateAnimations id: deActivateAnimations
NumberAnimation{target: bottomLine; property: "opacity"; to: 0; duration: 400} NumberAnimation{target: bottomLine; property: "opacity"; to: 0; duration: 250}
NumberAnimation{target: topLine; property: "opacity"; to: 0; duration: 400} NumberAnimation{target: topLine; property: "opacity"; to: 0; duration: 250}
NumberAnimation{target: view; property: "height"; to: itemHeight; duration: 400} NumberAnimation{target: view; property: "height"; to: itemHeight; duration: 250}
onStopped: { onStopped: {
arrowDown.visible = true view.showRow = true
} }
} }
} }
import QtQuick 2.0
Rectangle{
id: glacierRollerItem
color: "transparent"
width: parent.width
height: parent.itemHeight
property alias cWidth: dataLine.width
default property alias contentItem: dataLine.children
Rectangle{
id: dataLine
width: childrenRect.width
height: parent.height
color: "transparent"
}
Image{
id: arrowDown
source: "images/glacierroller-icon-arrow-down.svg"
width: glacierRollerItem.height/4
height: width
sourceSize.width: width
sourceSize.height: height
visible: glacierRollerItem.parent.showRow
anchors{
verticalCenter: dataLine.verticalCenter
left: dataLine.right
leftMargin: width
}
MouseArea{
anchors.fill: parent
onClicked: {
glacierRollerItem.parent.parent.activated = true
}
}
}
MouseArea{
anchors.fill: dataLine
onClicked: {
if(!glacierRollerItem.parent.parent.activated)
{
glacierRollerItem.parent.parent.activated = true;
}
else
{
glacierRollerItem.parent.parent.currentIndex = index
glacierRollerItem.parent.parent.activated = false
}
}
}
}
...@@ -20,7 +20,8 @@ QML_FILES += \ ...@@ -20,7 +20,8 @@ QML_FILES += \
Slider.qml\ Slider.qml\
ListView.qml \ ListView.qml \
ListViewItemWithActions.qml\ ListViewItemWithActions.qml\
GlacierRoller.qml GlacierRoller.qml \
GlacierRollerItem.qml
OTHER_FILES += qmldir \ OTHER_FILES += qmldir \
$$QML_FILES $$QML_FILES
......
...@@ -22,6 +22,7 @@ Slider 1.0 Slider.qml ...@@ -22,6 +22,7 @@ Slider 1.0 Slider.qml
ListView 1.0 ListView.qml ListView 1.0 ListView.qml
ListViewItemWithActions 1.0 ListViewItemWithActions.qml ListViewItemWithActions 1.0 ListViewItemWithActions.qml
GlacierRoller 1.0 GlacierRoller.qml GlacierRoller 1.0 GlacierRoller.qml
GlacierRollerItem 1.0 GlacierRollerItem.qml
# MIRRORED CONTROLS: # MIRRORED CONTROLS:
# These are the controls that we take directly from official QQC. # These are the controls that we take directly from official QQC.
......
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