HMenu: Fix width calculation (padding)

This commit is contained in:
miruka 2019-09-09 11:21:31 -04:00
parent d7fc0ad0b8
commit 035ab1add6

View File

@ -6,21 +6,15 @@ Menu {
padding: theme.controls.menu.borderWidth
implicitWidth: {
let result = 0
let leftPadding = 0
let rightPadding = 0
let result = 0
for (let i = 0; i < count; ++i) {
let item = itemAt(i)
if (! item.visible) continue
result = Math.max(item.contentItem.implicitWidth, result)
leftPadding = Math.max(item.leftPadding, leftPadding)
rightPadding = Math.max(item.rightPadding, rightPadding)
result = Math.max(item.implicitWidth, result)
}
return Math.min(
result + leftPadding + rightPadding, window.width
)
return Math.min(result + menu.padding * 2, window.width)
}
background: Rectangle {