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-11-16 15:02:00 -05:00
|
|
|
import { Box, Slider, Icon } from 'resource:///com/github/Aylur/ags/widget.js';
|
2023-09-12 15:27:39 -04:00
|
|
|
|
2023-11-21 01:29:46 -05:00
|
|
|
import Brightness from '../../services/brightness.js';
|
2023-11-13 16:19:09 -05:00
|
|
|
import { SpeakerIcon } from '../misc/audio-icons.js';
|
2023-09-12 15:27:39 -04:00
|
|
|
|
2023-10-02 12:06:35 -04:00
|
|
|
|
2023-10-17 13:47:02 -04:00
|
|
|
export default () => Box({
|
2023-10-20 23:11:21 -04:00
|
|
|
className: 'slider-box',
|
|
|
|
vertical: true,
|
2023-11-06 18:37:23 -05:00
|
|
|
hpack: 'center',
|
2023-10-20 23:11:21 -04:00
|
|
|
children: [
|
2023-09-12 15:27:39 -04:00
|
|
|
|
2023-10-20 23:11:21 -04:00
|
|
|
Box({
|
|
|
|
className: 'slider',
|
2023-11-06 18:37:23 -05:00
|
|
|
vpack: 'start',
|
|
|
|
hpack: 'center',
|
2023-11-21 01:29:46 -05:00
|
|
|
|
2023-10-20 23:11:21 -04:00
|
|
|
children: [
|
|
|
|
Icon({
|
|
|
|
size: 26,
|
|
|
|
className: 'slider-label',
|
2023-11-13 16:19:09 -05:00
|
|
|
binds: [['icon', SpeakerIcon, 'value']],
|
2023-10-20 23:11:21 -04:00
|
|
|
}),
|
2023-09-12 15:27:39 -04:00
|
|
|
|
2023-10-20 23:11:21 -04:00
|
|
|
Slider({
|
2023-11-16 15:02:00 -05:00
|
|
|
cursor: 'pointer',
|
|
|
|
vpack: 'center',
|
2023-11-21 01:29:46 -05:00
|
|
|
max: 0.999,
|
|
|
|
draw_value: false,
|
|
|
|
|
|
|
|
onChange: ({ value }) => {
|
|
|
|
Audio.speaker.volume = value;
|
|
|
|
},
|
|
|
|
|
2023-11-16 15:02:00 -05:00
|
|
|
connections: [
|
2023-11-21 01:29:46 -05:00
|
|
|
[Audio, (slider) => {
|
2023-11-16 15:02:00 -05:00
|
|
|
slider.value = Audio.speaker?.volume;
|
|
|
|
}, 'speaker-changed'],
|
|
|
|
|
2023-11-21 01:29:46 -05:00
|
|
|
['button-press-event', (s) => {
|
|
|
|
s.cursor = 'grabbing';
|
|
|
|
}],
|
|
|
|
['button-release-event', (s) => {
|
|
|
|
s.cursor = 'pointer';
|
|
|
|
}],
|
2023-11-16 15:02:00 -05:00
|
|
|
],
|
2023-10-20 23:11:21 -04:00
|
|
|
}),
|
|
|
|
],
|
2023-09-12 15:27:39 -04:00
|
|
|
}),
|
|
|
|
|
2023-10-20 23:11:21 -04:00
|
|
|
Box({
|
|
|
|
className: 'slider',
|
2023-11-06 18:37:23 -05:00
|
|
|
vpack: 'start',
|
|
|
|
hpack: 'center',
|
2023-11-21 01:29:46 -05:00
|
|
|
|
2023-10-20 23:11:21 -04:00
|
|
|
children: [
|
|
|
|
Icon({
|
|
|
|
className: 'slider-label',
|
|
|
|
icon: 'display-brightness-symbolic',
|
|
|
|
}),
|
2023-09-12 15:27:39 -04:00
|
|
|
|
2023-11-16 15:02:00 -05:00
|
|
|
Slider({
|
|
|
|
cursor: 'pointer',
|
|
|
|
vpack: 'center',
|
2023-11-21 01:29:46 -05:00
|
|
|
draw_value: false,
|
|
|
|
|
|
|
|
onChange: ({ value }) => {
|
|
|
|
Brightness.screen = value;
|
|
|
|
},
|
|
|
|
|
2023-11-16 15:02:00 -05:00
|
|
|
connections: [
|
2023-11-21 01:29:46 -05:00
|
|
|
[Brightness, (slider) => {
|
2023-11-16 15:02:00 -05:00
|
|
|
slider.value = Brightness.screen;
|
|
|
|
}, 'screen'],
|
|
|
|
|
2023-11-21 01:29:46 -05:00
|
|
|
['button-press-event', (s) => {
|
|
|
|
s.cursor = 'grabbing';
|
|
|
|
}],
|
|
|
|
['button-release-event', (s) => {
|
|
|
|
s.cursor = 'pointer';
|
|
|
|
}],
|
2023-11-16 15:02:00 -05:00
|
|
|
],
|
2023-10-20 23:11:21 -04:00
|
|
|
}),
|
2023-09-12 16:44:47 -04:00
|
|
|
],
|
2023-09-12 15:27:39 -04:00
|
|
|
}),
|
|
|
|
|
2023-10-20 23:11:21 -04:00
|
|
|
],
|
2023-09-12 15:27:39 -04:00
|
|
|
});
|