2023-10-31 08:32:40 -04:00
|
|
|
import Audio from 'resource:///com/github/Aylur/ags/service/audio.js';
|
2023-11-21 01:29:46 -05:00
|
|
|
|
2023-12-05 09:42:06 -05:00
|
|
|
import { Label, Box, EventBox, Icon, Revealer } from 'resource:///com/github/Aylur/ags/widget.js';
|
2023-09-11 19:57:21 -04:00
|
|
|
|
2023-11-16 00:48:50 -05:00
|
|
|
import { SpeakerIcon } from '../../misc/audio-icons.js';
|
|
|
|
import Separator from '../../misc/separator.js';
|
2023-09-08 16:00:38 -04:00
|
|
|
|
2023-10-02 12:06:35 -04:00
|
|
|
|
2023-11-21 01:29:46 -05:00
|
|
|
const SpeakerIndicator = (props) => Icon({
|
2023-10-20 23:11:21 -04:00
|
|
|
...props,
|
2023-11-13 16:19:09 -05:00
|
|
|
binds: [['icon', SpeakerIcon, 'value']],
|
2023-09-08 15:23:52 -04:00
|
|
|
});
|
|
|
|
|
2023-11-21 01:29:46 -05:00
|
|
|
const SpeakerPercentLabel = (props) => Label({
|
2023-10-20 23:11:21 -04:00
|
|
|
...props,
|
2023-12-17 00:01:58 -05:00
|
|
|
setup: (self) => {
|
|
|
|
self.hook(Audio, (label) => {
|
|
|
|
if (Audio.speaker) {
|
|
|
|
label.label = `${Math.round(Audio.speaker.volume * 100)}%`;
|
|
|
|
}
|
|
|
|
}, 'speaker-changed');
|
|
|
|
},
|
2023-09-08 15:23:52 -04:00
|
|
|
});
|
|
|
|
|
2023-11-21 01:29:46 -05:00
|
|
|
const SPACING = 5;
|
|
|
|
|
2023-12-05 09:42:06 -05:00
|
|
|
export default () => {
|
|
|
|
const rev = Revealer({
|
|
|
|
transition: 'slide_right',
|
|
|
|
child: Box({
|
|
|
|
children: [
|
|
|
|
Separator(SPACING),
|
|
|
|
SpeakerPercentLabel(),
|
|
|
|
],
|
|
|
|
}),
|
|
|
|
});
|
|
|
|
|
|
|
|
const widget = EventBox({
|
|
|
|
onHover: () => {
|
|
|
|
rev.revealChild = true;
|
|
|
|
},
|
|
|
|
onHoverLost: () => {
|
|
|
|
rev.revealChild = false;
|
|
|
|
},
|
|
|
|
child: Box({
|
|
|
|
className: 'audio',
|
|
|
|
children: [
|
|
|
|
SpeakerIndicator(),
|
|
|
|
|
|
|
|
rev,
|
|
|
|
],
|
|
|
|
}),
|
|
|
|
});
|
|
|
|
|
|
|
|
widget.rev = rev;
|
|
|
|
|
|
|
|
return widget;
|
|
|
|
};
|