diff --git a/CMakeLists.txt b/CMakeLists.txt index 8ff9c59..f5305cf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,6 +18,10 @@ include(ViewSolutions/CMake/ccache.cmake) add_subdirectory(ViewSolutions) if ( NOT DEFINED DISABLE_EXAMPLES ) + set(DISABLE_EXAMPLES OFF) +endif() + +if ( NOT DISABLE_EXAMPLES ) message("DISABLE_EXAMPLES = ${DISABLE_EXAMPLES}") add_subdirectory(Examples) endif() diff --git a/Examples/src/VPGradientPage.qml b/Examples/src/VPGradientPage.qml index b5e8d13..5d6c877 100644 --- a/Examples/src/VPGradientPage.qml +++ b/Examples/src/VPGradientPage.qml @@ -13,19 +13,18 @@ Page { anchors.fill: parent delegate: Component { ViewPortGradientPage { - scrollPos: viewPort.globalPos source: modelData viewground: root height: root.height / 3 title: "Test ViewPortPage" text: "Test ViewPortPage. General text and <i>html code</i>" + contentX: viewPort.contentX + contentY: viewPort.contentY + } } ScrollBar.vertical: ScrollBar { - onPositionChanged: { - viewPort.globalPos = position - } } diff --git a/Examples/src/VPStaticGradientPage.qml b/Examples/src/VPStaticGradientPage.qml index 97fea82..9e68816 100644 --- a/Examples/src/VPStaticGradientPage.qml +++ b/Examples/src/VPStaticGradientPage.qml @@ -18,6 +18,7 @@ Page { width: viewPort.width title: "Test ViewPortPage" text: "Test ViewPortPage. General text and <i>html code</i>" + } } diff --git a/Examples/src/ViewPortContainerPage.qml b/Examples/src/ViewPortContainerPage.qml index 9c58a87..0313097 100644 --- a/Examples/src/ViewPortContainerPage.qml +++ b/Examples/src/ViewPortContainerPage.qml @@ -13,23 +13,19 @@ Page { anchors.fill: parent delegate: Component { ViewPortPage { - scrollPos: viewPort.globalPos source: modelData viewground: root height: root.height / 3 - + contentX: viewPort.contentX + contentY: viewPort.contentY title: "Test ViewPortPage" text: "Test ViewPortPage. General text and <i>html code</i>" } } ScrollBar.vertical: ScrollBar { - onPositionChanged: { - viewPort.globalPos = position - } } - model: [ "qrc:/img/res/LOGO.png", "qrc:/img/res/LOGO-GREAN.png", diff --git a/ViewSolutions/src/ViewSolutionsModule/ViewPortDelegatBase.qml b/ViewSolutions/src/ViewSolutionsModule/ViewPortDelegatBase.qml index 58b359c..13381aa 100644 --- a/ViewSolutions/src/ViewSolutionsModule/ViewPortDelegatBase.qml +++ b/ViewSolutions/src/ViewSolutionsModule/ViewPortDelegatBase.qml @@ -11,7 +11,6 @@ ViewSolutionsControl { property alias imageSource: image property var viewground: null - property real scrollPos: 0 property int imageMrgin: 5 property var theme: Material.theme @@ -22,6 +21,8 @@ ViewSolutionsControl { property int viewPortDelegatW: 0 property int viewPortDelegatH: 0 + property real contentX: 0 + property real contentY: 0 background: Rectangle { border.color: "black" @@ -32,24 +33,11 @@ ViewSolutionsControl { width: (viewPortDelegatW)? viewPortDelegatW: (viewground)? viewground.width : 0 height: (viewPortDelegatH)? viewPortDelegatH: (viewground)?viewground.height * 0.1 : 0 - onScrollPosChanged: { - updatePos(); - } - - function updatePos() { - if (!viewground) { - return ; - } - - const viewGlobal = viewground.mapToGlobal(0, 0); - const img = flickable.mapFromGlobal(viewGlobal.x, viewGlobal.y); - - flickable.contentX = -img.x; - flickable.contentY = -img.y; - } Flickable { id: flickable + contentY: -(parent.contentY - delegateItem.y) + contentX: -(parent.contentX - delegateItem.x) contentWidth: viewground.width contentHeight: viewground.height @@ -62,7 +50,6 @@ ViewSolutionsControl { fillMode: Image.PreserveAspectFit anchors.fill: parent - } anchors.fill: parent