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,41 +97,49 @@ Item {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
TimelineText {
|
Loader {
|
||||||
id: scaleTopLabel
|
anchors.fill: parent
|
||||||
visible: parent.scaleVisible
|
active: parent.scaleVisible
|
||||||
font.pixelSize: 8
|
sourceComponent: Item {
|
||||||
anchors.top: parent.top
|
id: scaleParent
|
||||||
anchors.leftMargin: 2
|
anchors.fill: parent
|
||||||
anchors.topMargin: 2
|
|
||||||
anchors.left: parent.left
|
|
||||||
text: prettyPrintScale(row.maxVal)
|
|
||||||
}
|
|
||||||
|
|
||||||
Repeater {
|
|
||||||
model: parent.scaleVisible ? row.valDiff / row.stepVal : 0
|
|
||||||
|
|
||||||
Item {
|
|
||||||
anchors.left: row.left
|
|
||||||
anchors.right: row.right
|
|
||||||
height: row.stepVal * row.height / row.valDiff
|
|
||||||
y: row.height - (index + 1) * height
|
|
||||||
visible: y > scaleTopLabel.height
|
|
||||||
TimelineText {
|
TimelineText {
|
||||||
|
id: scaleTopLabel
|
||||||
font.pixelSize: 8
|
font.pixelSize: 8
|
||||||
anchors.bottom: parent.bottom
|
anchors.top: parent.top
|
||||||
anchors.bottomMargin: 2
|
|
||||||
anchors.leftMargin: 2
|
anchors.leftMargin: 2
|
||||||
|
anchors.topMargin: 2
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
text: prettyPrintScale(index * row.stepVal)
|
text: prettyPrintScale(row.maxVal)
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle {
|
Repeater {
|
||||||
height: 1
|
model: row.valDiff / row.stepVal
|
||||||
anchors.left: parent.left
|
|
||||||
anchors.right: parent.right
|
Item {
|
||||||
anchors.bottom: parent.bottom
|
anchors.left: scaleParent.left
|
||||||
color: Theme.color(Theme.Timeline_DividerColor)
|
anchors.right: scaleParent.right
|
||||||
|
height: row.stepVal * row.height / row.valDiff
|
||||||
|
y: row.height - (index + 1) * height
|
||||||
|
visible: y > scaleTopLabel.height
|
||||||
|
TimelineText {
|
||||||
|
font.pixelSize: 8
|
||||||
|
anchors.bottom: parent.bottom
|
||||||
|
anchors.bottomMargin: 2
|
||||||
|
anchors.leftMargin: 2
|
||||||
|
anchors.left: parent.left
|
||||||
|
text: prettyPrintScale(index * row.stepVal)
|
||||||
|
}
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
height: 1
|
||||||
|
anchors.left: parent.left
|
||||||
|
anchors.right: parent.right
|
||||||
|
anchors.bottom: parent.bottom
|
||||||
|
color: Theme.color(Theme.Timeline_DividerColor)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user