mirror of
https://github.com/QuasarApp/ViewSolutions.git
synced 2025-04-26 17:54:41 +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)
|
||||
|
||||
if ( NOT DEFINED DISABLE_EXAMPLES )
|
||||
set(DISABLE_EXAMPLES OFF)
|
||||
endif()
|
||||
|
||||
if ( NOT DISABLE_EXAMPLES )
|
||||
message("DISABLE_EXAMPLES = ${DISABLE_EXAMPLES}")
|
||||
add_subdirectory(Examples)
|
||||
endif()
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -18,6 +18,7 @@ Page {
|
||||
width: viewPort.width
|
||||
title: "Test ViewPortPage"
|
||||
text: "Test ViewPortPage. General text and <i>html code</i>"
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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",
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user