Improve the osd update code
- More logical relationship between volume level and bar length - No unnecessary drawing - Volume bar shrinks properly even when volume is lowered very quickly
This commit is contained in:
parent
96ec41a88f
commit
a0af850b29
1 changed files with 13 additions and 9 deletions
22
wmix/ui_x.c
22
wmix/ui_x.c
|
@ -417,16 +417,20 @@ void update_osd(float volume, bool up)
|
||||||
static int bar;
|
static int bar;
|
||||||
|
|
||||||
if (config.osd) {
|
if (config.osd) {
|
||||||
foo =
|
foo = (dockapp.osd_width - 20) * volume / 20.0;
|
||||||
(((dockapp.osd_width / 100) * (volume * 100)) / 20) + 1;
|
|
||||||
|
|
||||||
if ((foo != bar) || up) {
|
if (up) {
|
||||||
XClearArea(display, dockapp.osd, ((bar - 1) * 20), 30,
|
for (i = 1; i <= foo; i++)
|
||||||
(foo * 20), 25, 1);
|
XFillRectangle(display, dockapp.osd, dockapp.osd_gc,
|
||||||
for (i = 1; i < foo; i++)
|
i * 20, 30, 5, 25);
|
||||||
XFillRectangle(display, dockapp.osd, dockapp.osd_gc,
|
} else if (foo < bar) {
|
||||||
i * 20, 30, 5, 25);
|
XClearArea(display, dockapp.osd, ((foo+1) * 20), 30,
|
||||||
}
|
((bar-foo) * 20), 25, 1);
|
||||||
|
} else if (foo > bar) {
|
||||||
|
for (i = (bar > 0 ? bar : 1); i <= foo; i++)
|
||||||
|
XFillRectangle(display, dockapp.osd, dockapp.osd_gc,
|
||||||
|
i * 20, 30, 5, 25);
|
||||||
|
}
|
||||||
bar = foo;
|
bar = foo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue