forked from qt-creator/qt-creator
Timeline: Only load the scale for rows that need it
Typically at most a handful of rows have scales, but the creation of the Text elements is expensive. Put the whole scale handling into a loader and condition it on scaleActive. Change-Id: I0e0cc349f5c6b88953a96b87ba37331586ec702f Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -97,9 +97,15 @@ Item {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loader {
|
||||||
|
anchors.fill: parent
|
||||||
|
active: parent.scaleVisible
|
||||||
|
sourceComponent: Item {
|
||||||
|
id: scaleParent
|
||||||
|
anchors.fill: parent
|
||||||
|
|
||||||
TimelineText {
|
TimelineText {
|
||||||
id: scaleTopLabel
|
id: scaleTopLabel
|
||||||
visible: parent.scaleVisible
|
|
||||||
font.pixelSize: 8
|
font.pixelSize: 8
|
||||||
anchors.top: parent.top
|
anchors.top: parent.top
|
||||||
anchors.leftMargin: 2
|
anchors.leftMargin: 2
|
||||||
@@ -109,11 +115,11 @@ Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Repeater {
|
Repeater {
|
||||||
model: parent.scaleVisible ? row.valDiff / row.stepVal : 0
|
model: row.valDiff / row.stepVal
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
anchors.left: row.left
|
anchors.left: scaleParent.left
|
||||||
anchors.right: row.right
|
anchors.right: scaleParent.right
|
||||||
height: row.stepVal * row.height / row.valDiff
|
height: row.stepVal * row.height / row.valDiff
|
||||||
y: row.height - (index + 1) * height
|
y: row.height - (index + 1) * height
|
||||||
visible: y > scaleTopLabel.height
|
visible: y > scaleTopLabel.height
|
||||||
@@ -138,4 +144,6 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user