Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions shell/Ui/BarIconButton.qml
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,10 @@ WidgetButton {
font.family: root.fontFamily
font.pixelSize: root.fontSize
color: root.active && root.useActiveColor ? root.activeColor : root.foreground
y: (parent.height - height) / 2
+ (labelMetrics.descent - labelMetrics.ascent + labelMetrics.tightBoundingRect("0").height) / 2
// Center the figures' ink from the baseline. The rounded line box can
// include leading beyond ascent + descent, so it is not the ink's center.
y: parent.height / 2 - labelMetrics.ascent
- labelMetrics.tightBoundingRect("0").top - labelMetrics.tightBoundingRect("0").height / 2
Comment on lines +57 to +58

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Live visual check is missing. This changes where BarIconButton draws percentage labels, but the PR states that only offscreen Qt was checked. The repository requires visual changes to be verified in the running UI in addition to automated tests. Check this branch in the running desktop and attach before/after captures of the bar; offscreen component captures do not satisfy that requirement.

File Used: AGENTS.md (source)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

renderType: Text.NativeRendering
}

Expand Down
16 changes: 16 additions & 0 deletions test/shell.d/bar-icon-geometry-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,21 @@ ShellRoot {
return false
}
if (!checkPaintedBounds(labelledPower, "battery percentage")) return false
for (var labelledButton of [labelledPower, labelledCaption]) {
var figureLabel = findItem(labelledButton, function(item) {
return item.text === labelledButton.labelText && item.textFormat !== undefined
})
var figureMetrics = Qt.createQmlObject("import QtQuick; FontMetrics {}", labelledButton)
figureMetrics.font = figureLabel.font
var figureInk = figureMetrics.tightBoundingRect("0")
var inkCenter = figureLabel.mapToItem(labelledButton, 0,
figureLabel.baselineOffset + figureInk.top + figureInk.height / 2).y
figureMetrics.destroy()
if (Math.abs(inkCenter - labelledButton.height / 2) > 0.05) {
fail("bar icon label figures center at " + inkCenter + ", not " + labelledButton.height / 2)
return false
}
}
if (Math.abs(labelledPower.glyphPaintedWidth - power.glyphPaintedWidth) > 0.05
|| Math.abs(labelledPower.glyphPaintedHeight - power.glyphPaintedHeight) > 0.05) {
fail("the battery percentage changes the icon's size")
Expand Down Expand Up @@ -435,6 +450,7 @@ ShellRoot {
}
}
BarIconButton { id: labelledPower; bar: testBar; text: "󰁹"; labelText: "100%"; slotSize: Style.bar.iconSlot * 2 }
BarIconButton { id: labelledCaption; bar: testBar; text: "󰁹"; labelText: "12%"; fontSize: Style.font.caption; slotSize: Style.bar.iconSlot * 2 }
BarIconButton { id: rotatedIcon; bar: verticalBar; text: "\uf053"; textRotation: 90 }
OpticalGlyph { id: plainLabel; width: 30; height: 20; text: "12"; fontSize: 12 }
DropboxIcon { id: dropbox; iconSize: Style.bar.iconSize / aspectRatio; artworkScale: 1 }
Expand Down