mirror of
https://github.com/QuasarApp/ViewSolutions.git
synced 2025-05-07 06:59:45 +00:00
optimise the ViewPortPage cmpanent
This commit is contained in:
parent
c37366eb19
commit
cea929e9cb
@ -18,6 +18,10 @@ include(ViewSolutions/CMake/ccache.cmake)
|
|||||||
add_subdirectory(ViewSolutions)
|
add_subdirectory(ViewSolutions)
|
||||||
|
|
||||||
if ( NOT DEFINED DISABLE_EXAMPLES )
|
if ( NOT DEFINED DISABLE_EXAMPLES )
|
||||||
|
set(DISABLE_EXAMPLES OFF)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if ( NOT DISABLE_EXAMPLES )
|
||||||
message("DISABLE_EXAMPLES = ${DISABLE_EXAMPLES}")
|
message("DISABLE_EXAMPLES = ${DISABLE_EXAMPLES}")
|
||||||
add_subdirectory(Examples)
|
add_subdirectory(Examples)
|
||||||
endif()
|
endif()
|
||||||
|
@ -13,19 +13,18 @@ Page {
|
|||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
delegate: Component {
|
delegate: Component {
|
||||||
ViewPortGradientPage {
|
ViewPortGradientPage {
|
||||||
scrollPos: viewPort.globalPos
|
|
||||||
source: modelData
|
source: modelData
|
||||||
viewground: root
|
viewground: root
|
||||||
height: root.height / 3
|
height: root.height / 3
|
||||||
title: "Test ViewPortPage"
|
title: "Test ViewPortPage"
|
||||||
text: "Test ViewPortPage. General text and <i>html code</i>"
|
text: "Test ViewPortPage. General text and <i>html code</i>"
|
||||||
|
contentX: viewPort.contentX
|
||||||
|
contentY: viewPort.contentY
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ScrollBar.vertical: ScrollBar {
|
ScrollBar.vertical: ScrollBar {
|
||||||
onPositionChanged: {
|
|
||||||
viewPort.globalPos = position
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@ Page {
|
|||||||
width: viewPort.width
|
width: viewPort.width
|
||||||
title: "Test ViewPortPage"
|
title: "Test ViewPortPage"
|
||||||
text: "Test ViewPortPage. General text and <i>html code</i>"
|
text: "Test ViewPortPage. General text and <i>html code</i>"
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,23 +13,19 @@ Page {
|
|||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
delegate: Component {
|
delegate: Component {
|
||||||
ViewPortPage {
|
ViewPortPage {
|
||||||
scrollPos: viewPort.globalPos
|
|
||||||
source: modelData
|
source: modelData
|
||||||
viewground: root
|
viewground: root
|
||||||
height: root.height / 3
|
height: root.height / 3
|
||||||
|
contentX: viewPort.contentX
|
||||||
|
contentY: viewPort.contentY
|
||||||
title: "Test ViewPortPage"
|
title: "Test ViewPortPage"
|
||||||
text: "Test ViewPortPage. General text and <i>html code</i>"
|
text: "Test ViewPortPage. General text and <i>html code</i>"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ScrollBar.vertical: ScrollBar {
|
ScrollBar.vertical: ScrollBar {
|
||||||
onPositionChanged: {
|
|
||||||
viewPort.globalPos = position
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
model: [
|
model: [
|
||||||
"qrc:/img/res/LOGO.png",
|
"qrc:/img/res/LOGO.png",
|
||||||
"qrc:/img/res/LOGO-GREAN.png",
|
"qrc:/img/res/LOGO-GREAN.png",
|
||||||
|
@ -11,7 +11,6 @@ ViewSolutionsControl {
|
|||||||
property alias imageSource: image
|
property alias imageSource: image
|
||||||
|
|
||||||
property var viewground: null
|
property var viewground: null
|
||||||
property real scrollPos: 0
|
|
||||||
property int imageMrgin: 5
|
property int imageMrgin: 5
|
||||||
|
|
||||||
property var theme: Material.theme
|
property var theme: Material.theme
|
||||||
@ -22,6 +21,8 @@ ViewSolutionsControl {
|
|||||||
|
|
||||||
property int viewPortDelegatW: 0
|
property int viewPortDelegatW: 0
|
||||||
property int viewPortDelegatH: 0
|
property int viewPortDelegatH: 0
|
||||||
|
property real contentX: 0
|
||||||
|
property real contentY: 0
|
||||||
|
|
||||||
background: Rectangle {
|
background: Rectangle {
|
||||||
border.color: "black"
|
border.color: "black"
|
||||||
@ -32,24 +33,11 @@ ViewSolutionsControl {
|
|||||||
width: (viewPortDelegatW)? viewPortDelegatW: (viewground)? viewground.width : 0
|
width: (viewPortDelegatW)? viewPortDelegatW: (viewground)? viewground.width : 0
|
||||||
height: (viewPortDelegatH)? viewPortDelegatH: (viewground)?viewground.height * 0.1 : 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 {
|
Flickable {
|
||||||
id: flickable
|
id: flickable
|
||||||
|
contentY: -(parent.contentY - delegateItem.y)
|
||||||
|
contentX: -(parent.contentX - delegateItem.x)
|
||||||
|
|
||||||
contentWidth: viewground.width
|
contentWidth: viewground.width
|
||||||
contentHeight: viewground.height
|
contentHeight: viewground.height
|
||||||
@ -62,7 +50,6 @@ ViewSolutionsControl {
|
|||||||
|
|
||||||
fillMode: Image.PreserveAspectFit
|
fillMode: Image.PreserveAspectFit
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
Loading…
x
Reference in New Issue
Block a user