osds: config show value

This commit is contained in:
2 * r + 2 * t 2025-01-16 12:14:22 +11:00
parent d2457db2c3
commit f2945d0715
2 changed files with 26 additions and 19 deletions

View file

@ -28,11 +28,13 @@ export const osds = {
position: Astal.WindowAnchor.RIGHT, position: Astal.WindowAnchor.RIGHT,
margin: 20, margin: 20,
hideDelay: 1500, hideDelay: 1500,
showValue: true,
}, },
brightness: { brightness: {
position: Astal.WindowAnchor.LEFT, position: Astal.WindowAnchor.LEFT,
margin: 20, margin: 20,
hideDelay: 1500, hideDelay: 1500,
showValue: true,
}, },
}; };

View file

@ -131,8 +131,11 @@ const SliderOsd = ({
cr.setAntialias(cairo.Antialias.BEST); cr.setAntialias(cairo.Antialias.BEST);
// Progress number, at top/right // Progress number, at top/right
let nw = 0;
let nh = 0;
if (config[type].showValue) {
const numLayout = parent.create_pango_layout(String(Math.round(progressValue * 100))); const numLayout = parent.create_pango_layout(String(Math.round(progressValue * 100)));
const [nw, nh] = numLayout.get_pixel_size(); [nw, nh] = numLayout.get_pixel_size();
let diff; let diff;
if (vertical) { if (vertical) {
diff = ((1 - progressValue) * height) / nh; diff = ((1 - progressValue) * height) / nh;
@ -151,6 +154,7 @@ const SliderOsd = ({
); );
PangoCairo.show_layout(cr, numLayout); PangoCairo.show_layout(cr, numLayout);
}
// Progress icon, follows progress // Progress icon, follows progress
if (fontDesc === null) { if (fontDesc === null) {
@ -168,6 +172,7 @@ const SliderOsd = ({
iconLayout.set_text(icon.get(), -1); iconLayout.set_text(icon.get(), -1);
const [iw, ih] = iconLayout.get_pixel_size(); const [iw, ih] = iconLayout.get_pixel_size();
let diff;
if (vertical) { if (vertical) {
diff = (progressValue * height) / ih; diff = (progressValue * height) / ih;
cr.moveTo( cr.moveTo(