try to keep current tab in the middle if possible
This commit is contained in:
parent
22ef1f9318
commit
bc631e4467
@ -106,9 +106,10 @@ FocusScope {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onCurrentTabChanged: tabBarLayout.x = Math.min(0, -(currentTab.x + currentTab.width - tabbarScroller.width))
|
onCurrentTabChanged: tabBarLayout.x = Math.max(Math.min(0, -(currentTab.x + currentTab.width/2) + tabbarScroller.width/2), -tabBarLayout.width + tabbarScroller.width)
|
||||||
|
|
||||||
onWidthChanged: tabBarLayout.x = Math.min(0, -(currentTab.x + currentTab.width - tabbarScroller.width))
|
|
||||||
|
onWidthChanged: tabBarLayout.x = Math.max(Math.min(0, -(currentTab.x + currentTab.width/2) + tabbarScroller.width/2), -tabBarLayout.width + tabbarScroller.width)
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
id: tabbarScroller
|
id: tabbarScroller
|
||||||
@ -128,12 +129,19 @@ FocusScope {
|
|||||||
top: parent.top
|
top: parent.top
|
||||||
bottom: parent.bottom
|
bottom: parent.bottom
|
||||||
}
|
}
|
||||||
|
Behavior on x {
|
||||||
|
NumberAnimation {
|
||||||
|
duration: 250
|
||||||
|
easing: Easing.InOutQuad
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Row {
|
Row {
|
||||||
id: buttonsLayout
|
id: buttonsLayout
|
||||||
visible: tabBarLayout.width > root.width - backgroundFrame.margins.left - backgroundFrame.margins.right
|
visible: tabBarLayout.width > root.width - backgroundFrame.margins.left - backgroundFrame.margins.right
|
||||||
height: Math.min(parent.height, theme.mediumIconSize)
|
height: Math.min(parent.height, theme.mediumIconSize)
|
||||||
|
|
||||||
anchors {
|
anchors {
|
||||||
right: parent.right
|
right: parent.right
|
||||||
verticalCenter: parent.verticalCenter
|
verticalCenter: parent.verticalCenter
|
||||||
@ -143,12 +151,14 @@ FocusScope {
|
|||||||
height: parent.height
|
height: parent.height
|
||||||
width: height
|
width: height
|
||||||
iconSource: "go-previous"
|
iconSource: "go-previous"
|
||||||
|
enabled: tabBarLayout.x < 0
|
||||||
onClicked: tabBarLayout.x = Math.min(0, tabBarLayout.x + tabBarLayout.width/tabBarLayout.children.length)
|
onClicked: tabBarLayout.x = Math.min(0, tabBarLayout.x + tabBarLayout.width/tabBarLayout.children.length)
|
||||||
}
|
}
|
||||||
ToolButton {
|
ToolButton {
|
||||||
height: parent.height
|
height: parent.height
|
||||||
width: height
|
width: height
|
||||||
iconSource: "go-next"
|
iconSource: "go-next"
|
||||||
|
enabled: tabBarLayout.x > -tabBarLayout.width + tabbarScroller.width
|
||||||
onClicked: tabBarLayout.x = Math.max(-tabBarLayout.width + tabbarScroller.width, tabBarLayout.x - tabBarLayout.width/tabBarLayout.children.length)
|
onClicked: tabBarLayout.x = Math.max(-tabBarLayout.width + tabbarScroller.width, tabBarLayout.x - tabBarLayout.width/tabBarLayout.children.length)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user