fix scrollbar anchors

make scrollbar anchor to root, so the binding doesn't break at the moment of creation when they are parentless for a moment

also, clip the flickable, not the scrollares
This commit is contained in:
Marco Martin 2012-11-28 15:24:17 +01:00
parent 0d03bf21c8
commit 7b6d50b3c6

View File

@ -35,7 +35,7 @@ Properties:
**/ **/
import QtQuick 1.1 import QtQuick 1.1
import org.kde.plasma.components 0.1 import org.kde.plasma.components 0.1 as PlasmaComponents
import org.kde.plasma.core 0.1 as PlasmaCore import org.kde.plasma.core 0.1 as PlasmaCore
Item { Item {
@ -44,13 +44,13 @@ Item {
property Flickable flickableItem property Flickable flickableItem
//FIXME: this alias seems necessary for it to correctly parse //FIXME: this alias seems necessary for it to correctly parse
default property alias flickableItemDefault: root.flickableItem default property alias flickableItemDefault: root.flickableItem
clip: true
Connections { Connections {
target: root target: root
onFlickableItemChanged: { onFlickableItemChanged: {
root.flickableItem.parent = root root.flickableItem.parent = root
root.flickableItem.anchors.fill = root root.flickableItem.anchors.fill = root
root.flickableItem.clip = true
internal.checkVerticalScrollBar() internal.checkVerticalScrollBar()
internal.checkHorizontalScrollBar() internal.checkHorizontalScrollBar()
} }
@ -58,6 +58,7 @@ Item {
Component.onCompleted: { Component.onCompleted: {
root.flickableItem.parent = root root.flickableItem.parent = root
root.flickableItem.anchors.fill = root root.flickableItem.anchors.fill = root
root.flickableItem.clip = true
internal.checkVerticalScrollBar() internal.checkVerticalScrollBar()
internal.checkHorizontalScrollBar() internal.checkHorizontalScrollBar()
} }
@ -132,49 +133,49 @@ Item {
} }
Component { Component {
id: verticalScrollBarComponent id: verticalScrollBarComponent
ScrollBar { PlasmaComponents.ScrollBar {
flickableItem: root.flickableItem flickableItem: root.flickableItem
orientation: Qt.Vertical orientation: Qt.Vertical
property bool isScrollBar: true property bool isScrollBar: true
z: root.flickableItem.z + 1 z: root.flickableItem.z + 1
anchors { anchors {
left: undefined left: undefined
top: parent.top top: root.top
right: parent.right right: root.right
bottom: parent.bottom bottom: root.bottom
bottomMargin: parent.height - root.flickableItem.height bottomMargin: root.height - root.flickableItem.height
} }
onVisibleChanged: internal.checkVerticalScrollBarMargins() onVisibleChanged: internal.checkVerticalScrollBarMargins()
} }
} }
Component { Component {
id: horizontalScrollBarComponent id: horizontalScrollBarComponent
ScrollBar { PlasmaComponents.ScrollBar {
flickableItem: root.flickableItem flickableItem: root.flickableItem
orientation: Qt.Horizontal orientation: Qt.Horizontal
z: root.flickableItem.z + 1 z: root.flickableItem.z + 1
anchors { anchors {
left: parent.left left: root.left
top: undefined top: undefined
right: parent.right right: root.right
bottom: parent.bottom bottom: root.bottom
rightMargin: parent.width - root.flickableItem.width rightMargin: root.width - root.flickableItem.width
} }
onVisibleChanged: internal.checkHorizontalScrollBarMargins() onVisibleChanged: internal.checkHorizontalScrollBarMargins()
} }
} }
Component { Component {
id: sectionScrollerComponent id: sectionScrollerComponent
SectionScroller { PlasmaComponents.SectionScroller {
listView: root.flickableItem listView: root.flickableItem
property bool isScrollBar: false property bool isScrollBar: false
z: root.flickableItem.z + 1 z: root.flickableItem.z + 1
anchors { anchors {
left: undefined left: undefined
top: parent.top top: root.top
right: parent.right right: root.right
bottom: parent.bottom bottom: root.bottom
bottomMargin: parent.height - root.flickableItem.height bottomMargin: root.height - root.flickableItem.height
} }
onVisibleChanged: internal.checkVerticalScrollBarMargins() onVisibleChanged: internal.checkVerticalScrollBarMargins()
} }