diff options
-rw-r--r-- | examples/touch/main.qml | 21 | ||||
-rw-r--r-- | src/controls/ScrollDecorator.qml | 43 | ||||
-rw-r--r-- | src/controls/controls.pro | 1 | ||||
-rw-r--r-- | src/controls/qmldir | 1 | ||||
-rw-r--r-- | src/styles/FocusFrameStyle.qml | 5 | ||||
-rw-r--r-- | src/styles/ScrollDecoratorStyle.qml | 294 | ||||
-rw-r--r-- | src/styles/ScrollViewStyle.qml | 203 | ||||
-rw-r--r-- | src/styles/qmldir | 3 | ||||
-rw-r--r-- | src/styles/styles.pro | 5 |
9 files changed, 223 insertions, 353 deletions
diff --git a/examples/touch/main.qml b/examples/touch/main.qml index 8be4bea..95dd99b 100644 --- a/examples/touch/main.qml +++ b/examples/touch/main.qml @@ -121,21 +121,20 @@ ApplicationWindow { width: parent.width height: parent.height - - ListView { - id:listView - model: pageModel + ScrollView { anchors.fill: parent - clip:true + ListView { + id:listView + model: pageModel - delegate: AndroidDelegate { - text: title - onClicked: { - content.titleBar.subText = Qt.binding(function() {return pageStack.depth > 1 ? title: "Main Page"}) - pageStack.push(Qt.resolvedUrl(page)) + delegate: AndroidDelegate { + text: title + onClicked: { + content.titleBar.subText = Qt.binding(function() {return pageStack.depth > 1 ? title: "Main Page"}) + pageStack.push(Qt.resolvedUrl(page)) + } } } - ScrollDecorator {flickableItem: listView} } } } diff --git a/src/controls/ScrollDecorator.qml b/src/controls/ScrollDecorator.qml deleted file mode 100644 index 89f34bb..0000000 --- a/src/controls/ScrollDecorator.qml +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (C) 2013 Tomasz Olszak <olszak.tomasz@gmail.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -import QtQuick 2.1 -import QtQuick.Controls 1.0 -import QtQuick.Controls.Private 1.0 - -Item { - id: root - - anchors.fill: flickableItem - - property Flickable flickableItem - - property Component style: Qt.createComponent(Settings.style + "/ScrollDecoratorStyle.qml", root) - - Loader { - id: styleLoader - property Item __control: root - sourceComponent: style - } - - Loader { - id: decorationLoader - sourceComponent: parent.anchors.fill === flickableItem && styleLoader.item.decoration ? styleLoader.item.decoration: null - } -} diff --git a/src/controls/controls.pro b/src/controls/controls.pro index 4ba4a42..e52190b 100644 --- a/src/controls/controls.pro +++ b/src/controls/controls.pro @@ -9,7 +9,6 @@ QML_FILES += \ DetailButton.qml\ ContextMenu.qml\ SplitView.qml\ - ScrollDecorator.qml\ Popup.qml\ DateEdit.qml\ TimeEdit.qml \ diff --git a/src/controls/qmldir b/src/controls/qmldir index 81fb7f5..65b4a63 100644 --- a/src/controls/qmldir +++ b/src/controls/qmldir @@ -5,7 +5,6 @@ plugin tizencontrolsplugin DetailButton 1.0 DetailButton.qml ContextMenu 1.0 ContextMenu.qml SplitView 1.0 SplitView.qml -ScrollDecorator 1.0 ScrollDecorator.qml Popup 1.0 Popup.qml DateEdit 1.0 DateEdit.qml TitleBar 1.0 TitleBar.qml diff --git a/src/styles/FocusFrameStyle.qml b/src/styles/FocusFrameStyle.qml new file mode 100644 index 0000000..763dd7f --- /dev/null +++ b/src/styles/FocusFrameStyle.qml @@ -0,0 +1,5 @@ +import QtQuick 2.2 + +Item { + property int margin: -3 +} diff --git a/src/styles/ScrollDecoratorStyle.qml b/src/styles/ScrollDecoratorStyle.qml deleted file mode 100644 index 9c41020..0000000 --- a/src/styles/ScrollDecoratorStyle.qml +++ /dev/null @@ -1,294 +0,0 @@ -/* - * Copyright (C) 2013 Tomasz Olszak <olszak.tomasz@gmail.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -import QtQuick 2.1 -import QtQuick.Controls 1.0 -import QtQuick.Controls.Private 1.0 -import QtQuick.Controls.Tizen 1.0 -import QtQuick.Controls.Styles.Tizen 1.0 - -Style { - id: style - - property ScrollDecorator control: __control - - property Component decoration: Item { - width: control.width - height: control.height - - property Flickable flickableItem: control.flickableItem - - QtObject { - id: horizontalHelper - property real positionRatio: flickableItem ? flickableItem.visibleArea.xPosition : 0 - property real sizeRatio: flickableItem ? flickableItem.visibleArea.widthRatio : 0 - property real maxPosition: flickableItem ? flickableItem.width : 0 - property real minSize: TizenConfig.scroll.handler.horizontal.minimumWidth - - property real sizeUnderflow: (sizeRatio * maxPosition) < minSize ? minSize - (sizeRatio * maxPosition) : 0 - - // raw start and end position considering minimum size - property real rawStartPos: positionRatio * (maxPosition - sizeUnderflow) - property real rawEndPos: (positionRatio + sizeRatio) * (maxPosition - sizeUnderflow) + sizeUnderflow - - // overshoot amount at start and end - property real overshootStart: rawStartPos < 0 ? -rawStartPos : 0 - property real overshootEnd: rawEndPos > maxPosition ? rawEndPos - maxPosition : 0 - - // overshoot adjusted start and end - property real adjStartPos: rawStartPos + overshootStart - property real adjEndPos: rawEndPos - overshootStart - overshootEnd - - // final position and size of thumb - property int position: 0.5 + (adjStartPos + minSize > maxPosition ? maxPosition - minSize : adjStartPos) - property int size: 0.5 + ((adjEndPos - position) < minSize ? minSize : (adjEndPos - position)) - } - - QtObject { - id: verticalHelper - property real positionRatio: flickableItem ? flickableItem.visibleArea.yPosition : 0 - property real sizeRatio: flickableItem ? flickableItem.visibleArea.heightRatio : 0 - property real maxPosition: flickableItem ? flickableItem.height : 0 - property real minSize: TizenConfig.scroll.handler.vertical.minimumHeight - - property real sizeUnderflow: (sizeRatio * maxPosition) < minSize ? minSize - (sizeRatio * maxPosition) : 0 - - // raw start and end position considering minimum size - property real rawStartPos: positionRatio * (maxPosition - sizeUnderflow) - property real rawEndPos: (positionRatio + sizeRatio) * (maxPosition - sizeUnderflow) + sizeUnderflow - - // overshoot amount at start and end - property real overshootStart: rawStartPos < 0 ? -rawStartPos : 0 - property real overshootEnd: rawEndPos > maxPosition ? rawEndPos - maxPosition : 0 - - // overshoot adjusted start and end - property real adjStartPos: rawStartPos + overshootStart - property real adjEndPos: rawEndPos - overshootStart - overshootEnd - - // final position and size of thumb - property int position: 0.5 + (adjStartPos + minSize > maxPosition ? maxPosition - minSize : adjStartPos) - property int size: 0.5 + ((adjEndPos - position) < minSize ? minSize : (adjEndPos - position)) - } - - BorderImage { - id: overscrollingTop - anchors.left: parent.left - anchors.top: parent.top - anchors.right: parent.right - height: TizenConfig.scroll.overscrolling.top.height - source: TizenConfig.scroll.overscrolling.top.source - opacity:0 - states: State { - name:"visible" - when: flickableItem.atYBeginning && flickableItem.movingVertically - PropertyChanges { - target:overscrollingTop - opacity: 1 - } - } - transitions: [ - Transition { - to: "visible" - NumberAnimation { - property: "opacity" - duration: 150 - } - }, - Transition { - from: "visible" - NumberAnimation { - property: "opacity" - duration: 500 - } - } - ] - } - BorderImage { - id: overscrollingBottom - anchors.left: parent.left - anchors.bottom: parent.bottom - anchors.right: parent.right - height: TizenConfig.scroll.overscrolling.bottom.height - source: TizenConfig.scroll.overscrolling.bottom.source - opacity:0 - states: State { - name:"visible" - when: flickableItem.atYEnd && flickableItem.movingVertically - PropertyChanges { - target:overscrollingBottom - opacity: 1 - } - } - transitions: [ - Transition { - to: "visible" - NumberAnimation { - property: "opacity" - duration: 150 - } - }, - Transition { - from: "visible" - NumberAnimation { - property: "opacity" - duration: 500 - } - } - ] - } - BorderImage { - id: overscrollingRight - anchors.top: parent.top - anchors.bottom: parent.bottom - anchors.right: parent.right - width: TizenConfig.scroll.overscrolling.left.right - source: TizenConfig.scroll.overscrolling.right.source - opacity:0 - states: State { - name:"visible" - when: flickableItem.atXEnd && flickableItem.movingHorizontally - PropertyChanges { - target:overscrollingRight - opacity: 1 - } - } - transitions: [ - Transition { - to: "visible" - NumberAnimation { - property: "opacity" - duration: 150 - } - }, - Transition { - from: "visible" - NumberAnimation { - property: "opacity" - duration: 500 - } - } - ] - } - TizenBorderImage { - id: overscrollingLeft - anchors.top: parent.top - anchors.bottom: parent.bottom - anchors.left: parent.left - width: TizenConfig.scroll.overscrolling.left.width - source: TizenConfig.scroll.overscrolling.left.source - opacity:0 - states: State { - name:"visible" - when: flickableItem.atXBeginning && flickableItem.movingHorizontally - PropertyChanges { - target:overscrollingLeft - opacity: 1 - } - } - transitions: [ - Transition { - to: "visible" - NumberAnimation { - property: "opacity" - duration: 150 - } - }, - Transition { - from: "visible" - NumberAnimation { - property: "opacity" - duration: 500 - } - } - ] - } - - TizenBorderImage { - id: horizontalIndicator - x: horizontalHelper.position - opacity: 0 - width: horizontalHelper.size - anchors.bottom: parent.bottom - height: TizenConfig.scroll.handler.horizontal.minimumHeight - source: TizenConfig.scroll.handler.horizontal.source - backgroundColor: TizenConfig.scroll.handler.color - effectSource: TizenConfig.scroll.handler.horizontal.effectSource - states: State { - name: "visible" - when: flickableItem.movingHorizontally - PropertyChanges { - target: horizontalIndicator - opacity: 1 - } - } - transitions: [ - Transition { - to: "visible" - NumberAnimation { - property: "opacity" - duration: 150 - } - }, - Transition { - from: "visible" - NumberAnimation { - property: "opacity" - duration: 500 - } - } - ] - } - TizenBorderImage { - id: verticalIndicator - y: verticalHelper.position - anchors.right: parent.right - opacity: 0 - anchors.margins: TizenConfig.scroll.handler.vertical.margin - width: TizenConfig.scroll.handler.vertical.minimumWidth - height: verticalHelper.size - source: TizenConfig.scroll.handler.vertical.source - backgroundColor: TizenConfig.scroll.handler.color - effectSource: TizenConfig.scroll.handler.vertical.effectSource - states: State { - name: "visible" - when: flickableItem.movingVertically - PropertyChanges { - target: verticalIndicator - opacity: 1 - } - } - transitions: [ - Transition { - to: "visible" - NumberAnimation { - property: "opacity" - duration: 150 - } - }, - Transition { - from: "visible" - NumberAnimation { - property: "opacity" - duration: 500 - } - } - ] - } - } -} diff --git a/src/styles/ScrollViewStyle.qml b/src/styles/ScrollViewStyle.qml new file mode 100644 index 0000000..0738e1c --- /dev/null +++ b/src/styles/ScrollViewStyle.qml @@ -0,0 +1,203 @@ +/* + * Copyright (C) 2013 Tomasz Olszak <olszak.tomasz@gmail.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +import QtQuick 2.2 +import QtQuick.Controls.Styles 1.1 +import QtQuick.Controls.Styles.Tizen 1.0 + +ScrollViewStyle { + transientScrollBars: true + Binding { + target: control.flickableItem + property: "interactive" + value: true + } + handle: TizenBorderImage { + id: verticalIndicator + anchors.margins: TizenConfig.scroll.handler.vertical.margin + source: TizenConfig.scroll.handler.vertical.source + backgroundColor: TizenConfig.scroll.handler.color + effectSource: TizenConfig.scroll.handler.vertical.effectSource + states: State { + name: "visible" + when: control.flickableItem.movingVertically + PropertyChanges { + target: verticalIndicator + opacity: 1 + } + } + transitions: [ + Transition { + to: "visible" + NumberAnimation { + property: "opacity" + duration: 150 + } + }, + Transition { + from: "visible" + NumberAnimation { + property: "opacity" + duration: 500 + } + } + ] + } + corner: null + decrementControl: null + frame: Item { + width: control.width + height: control.height + + BorderImage { + id: overscrollingTop + anchors.left: parent.left + anchors.top: parent.top + anchors.right: parent.right + height: TizenConfig.scroll.overscrolling.top.height + source: TizenConfig.scroll.overscrolling.top.source + opacity:0 + states: State { + name:"visible" + when: control.flickableItem.atYBeginning && control.flickableItem.movingVertically + PropertyChanges { + target:overscrollingTop + opacity: 1 + } + } + transitions: [ + Transition { + to: "visible" + NumberAnimation { + property: "opacity" + duration: 150 + } + }, + Transition { + from: "visible" + NumberAnimation { + property: "opacity" + duration: 500 + } + } + ] + } + + BorderImage { + id: overscrollingBottom + anchors.left: parent.left + anchors.bottom: parent.bottom + anchors.right: parent.right + height: TizenConfig.scroll.overscrolling.bottom.height + source: TizenConfig.scroll.overscrolling.bottom.source + opacity:0 + states: State { + name:"visible" + when: control.flickableItem.atYEnd && control.flickableItem.movingVertically + PropertyChanges { + target:overscrollingBottom + opacity: 1 + } + } + transitions: [ + Transition { + to: "visible" + NumberAnimation { + property: "opacity" + duration: 150 + } + }, + Transition { + from: "visible" + NumberAnimation { + property: "opacity" + duration: 500 + } + } + ] + } + BorderImage { + id: overscrollingRight + anchors.top: parent.top + anchors.bottom: parent.bottom + anchors.right: parent.right + width: TizenConfig.scroll.overscrolling.left.right + source: TizenConfig.scroll.overscrolling.right.source + opacity:0 + states: State { + name:"visible" + when: control.flickableItem.atXEnd && control.flickableItem.movingHorizontally + PropertyChanges { + target:overscrollingRight + opacity: 1 + } + } + transitions: [ + Transition { + to: "visible" + NumberAnimation { + property: "opacity" + duration: 150 + } + }, + Transition { + from: "visible" + NumberAnimation { + property: "opacity" + duration: 500 + } + } + ] + } + TizenBorderImage { + id: overscrollingLeft + anchors.top: parent.top + anchors.bottom: parent.bottom + anchors.left: parent.left + width: TizenConfig.scroll.overscrolling.left.width + source: TizenConfig.scroll.overscrolling.left.source + opacity:0 + states: State { + name:"visible" + when: control.flickableItem.atXBeginning && control.flickableItem.movingHorizontally + PropertyChanges { + target:overscrollingLeft + opacity: 1 + } + } + transitions: [ + Transition { + to: "visible" + NumberAnimation { + property: "opacity" + duration: 150 + } + }, + Transition { + from: "visible" + NumberAnimation { + property: "opacity" + duration: 500 + } + } + ] + } + } + incrementControl: null +} diff --git a/src/styles/qmldir b/src/styles/qmldir index 4c6aace..be4cd25 100644 --- a/src/styles/qmldir +++ b/src/styles/qmldir @@ -11,7 +11,6 @@ PanelStyle 1.0 PanelStyle.qml Floater 1.0 Floater.qml SwitchStyle 1.0 SwitchStyle.qml DetailButtonStyle 1.0 DetailButtonStyle.qml -ScrollDecoratorStyle 1.0 ScrollDecoratorStyle.qml ContextMenuStyle 1.0 ContextMenuStyle.qml PopupStyle 1.0 PopupStyle.qml BusyIndicatorStyle 1.0 BusyIndicatorStyle.qml @@ -22,3 +21,5 @@ ToolBarStyle 1.0 ToolBarStyle.qml ToolBarButton 1.0 ToolBarButton.qml ViewStyle 1.0 ViewStyle.qml RadioButtonStyle 1.0 RadioButtonStyle.qml +ScrollViewStyle 1.0 ScrollViewStyle.qml + diff --git a/src/styles/styles.pro b/src/styles/styles.pro index ed66891..90ef5d7 100644 --- a/src/styles/styles.pro +++ b/src/styles/styles.pro @@ -17,7 +17,6 @@ QML_FILES = \ Floater.qml \ SwitchStyle.qml\ DetailButtonStyle.qml\ - ScrollDecoratorStyle.qml\ ContextMenuStyle.qml\ PopupStyle.qml\ BusyIndicatorStyle.qml \ @@ -28,7 +27,9 @@ QML_FILES = \ ToolBarStyle.qml \ ToolBarButton.qml \ PanelStyle.qml \ - RadioButtonStyle.qml + RadioButtonStyle.qml \ + FocusFrameStyle.qml \ + ScrollViewStyle.qml QML_FILES += \ private/DateEditField.qml\ |