From 8d327acc6f1505c6c7133ab5f1d3ea0e457401ca Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Thu, 11 Oct 2012 11:09:07 +0200 Subject: [PATCH] A bit of snap before scolling the layout --- declarativeimports/plasmacomponents/qml/TabBar.qml | 6 +++++- .../plasmacomponents/qml/private/TabBarLayout.qml | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/declarativeimports/plasmacomponents/qml/TabBar.qml b/declarativeimports/plasmacomponents/qml/TabBar.qml index b65981c81..65971e498 100644 --- a/declarativeimports/plasmacomponents/qml/TabBar.qml +++ b/declarativeimports/plasmacomponents/qml/TabBar.qml @@ -108,6 +108,9 @@ FocusScope { onCurrentTabChanged: tabBarLayout.x = Math.max(Math.min(0, -(currentTab.x + currentTab.width/2) + tabbarScroller.width/2), -tabBarLayout.width + tabbarScroller.width) +Text { + text: tabBarLayout.implicitWidth + " " + tabBarLayout.width + " " + tabbarScroller.width +} onWidthChanged: tabBarLayout.x = Math.max(Math.min(0, -(currentTab.x + currentTab.width/2) + tabbarScroller.width/2), -tabBarLayout.width + tabbarScroller.width) @@ -124,7 +127,8 @@ FocusScope { Private.TabBarLayout { id: tabBarLayout - width: Math.max(parent.width, implicitWidth) + //A bit of snap before scolling the layout + width: (implicitWidth - parent.width < theme.defaultFont.mSize.width*4) ? parent.width : implicitWidth anchors { top: parent.top bottom: parent.bottom diff --git a/declarativeimports/plasmacomponents/qml/private/TabBarLayout.qml b/declarativeimports/plasmacomponents/qml/private/TabBarLayout.qml index 0ef546554..c1b1c21ee 100644 --- a/declarativeimports/plasmacomponents/qml/private/TabBarLayout.qml +++ b/declarativeimports/plasmacomponents/qml/private/TabBarLayout.qml @@ -152,7 +152,9 @@ Item { --visibleChildCount } } + var itemWidth = (root.width - (visibleChildCount-1)*10) / visibleChildCount + var itemIndex = mirrored ? childCount - 1 : 0 var increment = mirrored ? - 1 : 1 var visibleIndex = 0