2023-09-12 09:37:48 -04:00
|
|
|
const { Window, EventBox } = ags.Widget;
|
2023-09-12 14:42:53 -04:00
|
|
|
const { closeWindow } = ags.App;
|
|
|
|
|
2023-09-25 12:43:36 -04:00
|
|
|
const ALWAYS_OPEN = [
|
|
|
|
'closer',
|
|
|
|
'bar',
|
|
|
|
'notifications',
|
|
|
|
];
|
|
|
|
|
2023-09-14 13:33:59 -04:00
|
|
|
// TODO: close on scroll event too?
|
2023-09-13 19:04:23 -04:00
|
|
|
export const closeAll = () => {
|
|
|
|
ags.App.windows.forEach(w => {
|
2023-09-25 12:43:36 -04:00
|
|
|
if (!ALWAYS_OPEN.some(window => window === w.name))
|
2023-09-13 19:04:23 -04:00
|
|
|
ags.App.closeWindow(w.name)
|
|
|
|
});
|
2023-09-25 12:43:36 -04:00
|
|
|
closeWindow('closer');
|
2023-09-13 19:04:23 -04:00
|
|
|
};
|
2023-09-12 09:37:48 -04:00
|
|
|
|
|
|
|
export const Closer = Window({
|
2023-09-11 19:57:21 -04:00
|
|
|
name: 'closer',
|
|
|
|
popup: true,
|
|
|
|
layer: 'top',
|
|
|
|
anchor: 'top bottom left right',
|
|
|
|
|
2023-09-12 09:37:48 -04:00
|
|
|
child: EventBox({
|
2023-09-12 14:42:53 -04:00
|
|
|
onPrimaryClickRelease: () => closeAll(),
|
2023-09-25 12:43:36 -04:00
|
|
|
connections: [[ags.App, (_b, _w, _v) => {
|
|
|
|
if (!Array.from(ags.App.windows).some(w => w[1].visible &&
|
|
|
|
!ALWAYS_OPEN.some(window => window === w[0]))) {
|
2023-09-18 17:39:10 -04:00
|
|
|
closeWindow('closer');
|
|
|
|
}
|
|
|
|
}]],
|
2023-09-11 19:57:21 -04:00
|
|
|
}),
|
|
|
|
});
|