use a scrollArea

This commit is contained in:
Marco Martin 2012-08-09 11:11:29 +02:00
parent a2f6e62e6c
commit 9b4c8ba95d

View File

@ -59,7 +59,7 @@ Item {
property variant initialPage property variant initialPage
//A column is wide enough for 30 characters //A column is wide enough for 30 characters
property int columnWidth: Math.round(parent.width/(theme.defaultFont.mSize.width*30)) > 0 ? parent.width/Math.round(parent.width/(theme.defaultFont.mSize.width*30)) : width property int columnWidth: Math.round(parent.width/(theme.defaultFont.mSize.width*30)) > 0 ? parent.width/Math.round(parent.width/(theme.defaultFont.mSize.width*30)) : width
clip: true property alias clip: scrollArea.clip
// Indicates whether there is an ongoing page transition. // Indicates whether there is an ongoing page transition.
property bool busy: internal.ongoingTransitionCount > 0 property bool busy: internal.ongoingTransitionCount > 0
@ -194,32 +194,32 @@ Item {
} }
} }
Flickable { ScrollArea {
id: mainFlickable id: scrollArea
anchors.fill: parent anchors.fill: parent
interactive: root.width > width Flickable {
boundsBehavior: Flickable.StopAtBounds id: mainFlickable
contentWidth: root.width anchors.fill: parent
contentHeight: height interactive: root.width > width
Row { boundsBehavior: Flickable.StopAtBounds
id: root contentWidth: root.width
spacing: -100 contentHeight: height
width: columnWidth*depth Row {
height: parent.height id: root
Behavior on width { spacing: -100
NumberAnimation { width: columnWidth*depth
duration: internal.transitionDuration height: parent.height
easing.type: Easing.InOutQuad Behavior on width {
NumberAnimation {
duration: internal.transitionDuration
easing.type: Easing.InOutQuad
}
} }
} }
onMovementEnded: {print(Math.round(contentX/columnWidth))
scrollToLevel(Math.round(contentX/columnWidth)+1)
}
} }
onMovementEnded: {print(Math.round(contentX/columnWidth))
scrollToLevel(Math.round(contentX/columnWidth)+1)
}
}
ScrollBar {
flickableItem: mainFlickable
orientation: Qt.Horizontal
} }
Component { Component {