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;
|
||||
}
|
||||
|
||||
Loader {
|
||||
anchors.fill: parent
|
||||
active: parent.scaleVisible
|
||||
sourceComponent: Item {
|
||||
id: scaleParent
|
||||
anchors.fill: parent
|
||||
|
||||
TimelineText {
|
||||
id: scaleTopLabel
|
||||
visible: parent.scaleVisible
|
||||
font.pixelSize: 8
|
||||
anchors.top: parent.top
|
||||
anchors.leftMargin: 2
|
||||
@@ -109,11 +115,11 @@ Item {
|
||||
}
|
||||
|
||||
Repeater {
|
||||
model: parent.scaleVisible ? row.valDiff / row.stepVal : 0
|
||||
model: row.valDiff / row.stepVal
|
||||
|
||||
Item {
|
||||
anchors.left: row.left
|
||||
anchors.right: row.right
|
||||
anchors.left: scaleParent.left
|
||||
anchors.right: scaleParent.right
|
||||
height: row.stepVal * row.height / row.valDiff
|
||||
y: row.height - (index + 1) * height
|
||||
visible: y > scaleTopLabel.height
|
||||
@@ -139,3 +145,5 @@ Item {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user