Make ButtonLayout faster and more precise

This commit is contained in:
miruka 2020-07-11 22:06:37 -04:00
parent 7227ac04a3
commit 1ad3de3917

View File

@ -5,19 +5,19 @@ import QtQuick.Layouts 1.12
import ".." import ".."
HGridLayout { HGridLayout {
readonly property int summedImplicitWidth: { readonly property real summedImplicitWidth: {
const widths = [] let sum = 0
for (let i = 0; i < visibleChildren.length; i++) { for (let i = 0; i < visibleChildren.length; i++) {
const item = visibleChildren[i] const item = visibleChildren[i]
if (item) widths.push(item.width > 0 ? item.implicitWidth : 0) if (item) sum += item.width > 0 ? item.implicitWidth : 0
} }
return utils.sum(widths) return sum
} }
flow: flow:
width >= summedImplicitWidth ? width >= summedImplicitWidth ?
GridLayout.LeftToRight : HGridLayout.LeftToRight :
GridLayout.TopToBottom HGridLayout.TopToBottom
} }