mirror of
https://github.com/noctalia-dev/noctalia-shell.git
synced 2026-05-11 17:08:27 +08:00
Sizing: ensure bar and capsule height are always odd.
This commit is contained in:
+23
-8
@@ -87,30 +87,40 @@ Singleton {
|
||||
|
||||
// Bar Dimensions
|
||||
readonly property real barHeight: {
|
||||
let h;
|
||||
switch (Settings.data.bar.density) {
|
||||
case "mini":
|
||||
return (Settings.data.bar.position === "left" || Settings.data.bar.position === "right") ? 22 : 20;
|
||||
h = (Settings.data.bar.position === "left" || Settings.data.bar.position === "right") ? 22 : 20;
|
||||
break;
|
||||
case "compact":
|
||||
return (Settings.data.bar.position === "left" || Settings.data.bar.position === "right") ? 27 : 25;
|
||||
h = (Settings.data.bar.position === "left" || Settings.data.bar.position === "right") ? 27 : 25;
|
||||
break;
|
||||
case "comfortable":
|
||||
return (Settings.data.bar.position === "left" || Settings.data.bar.position === "right") ? 39 : 37;
|
||||
h = (Settings.data.bar.position === "left" || Settings.data.bar.position === "right") ? 39 : 37;
|
||||
break;
|
||||
default:
|
||||
case "default":
|
||||
return (Settings.data.bar.position === "left" || Settings.data.bar.position === "right") ? 33 : 31;
|
||||
h = (Settings.data.bar.position === "left" || Settings.data.bar.position === "right") ? 33 : 31;
|
||||
}
|
||||
return toOdd(h);
|
||||
}
|
||||
readonly property real capsuleHeight: {
|
||||
let h;
|
||||
switch (Settings.data.bar.density) {
|
||||
case "mini":
|
||||
return Math.round(barHeight * 1.0);
|
||||
h = Math.round(barHeight * 1.0);
|
||||
break;
|
||||
case "compact":
|
||||
return Math.round(barHeight * 0.85);
|
||||
h = Math.round(barHeight * 0.85);
|
||||
break;
|
||||
case "comfortable":
|
||||
return Math.round(barHeight * 0.73);
|
||||
h = Math.round(barHeight * 0.73);
|
||||
break;
|
||||
default:
|
||||
case "default":
|
||||
return Math.round(barHeight * 0.82);
|
||||
h = Math.round(barHeight * 0.82);
|
||||
}
|
||||
return toOdd(h);
|
||||
}
|
||||
readonly property color capsuleColor: Settings.data.bar.showCapsule ? Qt.alpha(Color.mSurfaceVariant, Settings.data.bar.capsuleOpacity) : Color.transparent
|
||||
|
||||
@@ -121,4 +131,9 @@ Singleton {
|
||||
function pixelAlignCenter(containerSize, contentSize) {
|
||||
return Math.round((containerSize - contentSize) / 2);
|
||||
}
|
||||
|
||||
// Ensures a number is always odd (rounds down to nearest odd)
|
||||
function toOdd(n) {
|
||||
return Math.floor(n / 2) * 2 + 1;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user