mirror of
https://github.com/noctalia-dev/noctalia-shell.git
synced 2026-05-11 17:08:27 +08:00
NIconButton + NPill: improved vertical centering
This commit is contained in:
@@ -37,16 +37,14 @@ Rectangle {
|
||||
border.width: Math.max(1, Style.borderS * scaling)
|
||||
|
||||
NIcon {
|
||||
anchors.centerIn: parent
|
||||
// Little hack to keep things centered at high scaling
|
||||
anchors.horizontalCenterOffset: -1 * (scaling - 1.0)
|
||||
anchors.verticalCenterOffset: 0
|
||||
text: root.icon
|
||||
font.pointSize: root.fontPointSize * scaling
|
||||
color: root.hovering ? colorFgHover : colorFg
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
opacity: root.enabled ? Style.opacityFull : Style.opacityMedium
|
||||
// Center horizontally
|
||||
x: (root.width - width) / 2
|
||||
// Center vertically accounting for font metrics
|
||||
y: (root.height - height) / 2 + (height - contentHeight) / 2
|
||||
}
|
||||
|
||||
NTooltip {
|
||||
|
||||
+4
-1
@@ -103,7 +103,10 @@ Item {
|
||||
font.pointSize: Style.fontSizeM * scaling
|
||||
// When forced shown, use pill text color; otherwise accent color when hovered
|
||||
color: forceOpen ? textColor : (showPill ? iconTextColor : Color.mOnSurface)
|
||||
anchors.centerIn: parent
|
||||
// Center horizontally
|
||||
x: (iconCircle.width - width) / 2
|
||||
// Center vertically accounting for font metrics
|
||||
y: (iconCircle.height - height) / 2 + (height - contentHeight) / 2
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user