From b02c7b3145d4c5806c5ea89b0915d1c85873a29c Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Thu, 26 Oct 2017 15:36:43 +0200 Subject: Default: optimize SwitchIndicator Squeeze a few more frames in qmlbench by getting rid of one extra Item and optimizing the bindings. Before: running: qmlbench/benchmarks/auto/creation/quick.controls2/delegates_switch.qml [...] Average: 94.4 frames; using samples; MedianAll=94; StdDev=1.14018, CoV=0.0120781 After: running: qmlbench/benchmarks/auto/creation/quick.controls2/delegates_switch.qml [...] Average: 98.8 frames; using samples; MedianAll=99; StdDev=1.09545, CoV=0.0110875 Change-Id: I37bc9c7e75ec1620b6f575aa4aa97961367f79fd Reviewed-by: Mitch Curtis --- src/imports/controls/SwitchIndicator.qml | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/imports/controls/SwitchIndicator.qml b/src/imports/controls/SwitchIndicator.qml index 0aeaaffc..6b421bb6 100644 --- a/src/imports/controls/SwitchIndicator.qml +++ b/src/imports/controls/SwitchIndicator.qml @@ -38,19 +38,17 @@ import QtQuick 2.10 import QtQuick.Controls 2.3 import QtQuick.Controls.impl 2.3 -Item { +PaddedRectangle { implicitWidth: 56 implicitHeight: 28 - property Item control + property AbstractButton control - Rectangle { - y: parent.height / 2 - height / 2 - width: 56 - height: 16 - radius: 8 - color: control.checked ? control.palette.dark : control.palette.midlight - } + radius: 8 + leftPadding: 0 + rightPadding: 0 + padding: (height - 16) / 2 + color: control.checked ? control.palette.dark : control.palette.midlight Rectangle { x: Math.max(0, Math.min(parent.width - width, control.visualPosition * parent.width - (width / 2))) -- cgit v1.2.3