2023-10-31 08:32:40 -04:00
|
|
|
import App from 'resource:///com/github/Aylur/ags/app.js';
|
|
|
|
import { Revealer, Box, Window } from 'resource:///com/github/Aylur/ags/widget.js';
|
2023-10-02 12:06:35 -04:00
|
|
|
|
2023-09-21 20:01:14 -04:00
|
|
|
|
2023-10-17 13:47:02 -04:00
|
|
|
export default ({
|
2023-10-30 19:53:50 -04:00
|
|
|
// Revealer props
|
|
|
|
transition = 'slide_down',
|
|
|
|
transitionDuration = 500,
|
|
|
|
// Optional: execute a function whenever the window pops up
|
|
|
|
onOpen = () => {},
|
|
|
|
|
|
|
|
// Window props
|
2023-10-17 13:47:02 -04:00
|
|
|
name,
|
2023-10-20 23:11:21 -04:00
|
|
|
child,
|
2023-10-24 17:26:38 -04:00
|
|
|
closeOnUnfocus = 'released',
|
2023-10-30 19:53:50 -04:00
|
|
|
visible = false,
|
|
|
|
layer = 'overlay',
|
2023-10-20 23:11:21 -04:00
|
|
|
...props
|
|
|
|
}) => {
|
|
|
|
const window = Window({
|
|
|
|
name,
|
2023-10-30 19:53:50 -04:00
|
|
|
layer,
|
2023-10-20 23:11:21 -04:00
|
|
|
popup: true,
|
|
|
|
visible: false,
|
|
|
|
...props,
|
2023-09-22 01:34:36 -04:00
|
|
|
|
2023-10-30 19:53:50 -04:00
|
|
|
// Add way to make window open on startup
|
|
|
|
setup: () => {
|
|
|
|
const id = App.connect('config-parsed', () => {
|
|
|
|
if (visible)
|
|
|
|
App.openWindow(name);
|
|
|
|
App.disconnect(id);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
// Wrapping the revealer inside a box is needed
|
|
|
|
// to allocate some space for it even when not revealed
|
2023-10-20 23:11:21 -04:00
|
|
|
child: Box({
|
2023-10-21 14:39:37 -04:00
|
|
|
style: `min-height:1px;
|
|
|
|
min-width:1px;
|
|
|
|
padding: 1px;`,
|
2023-10-20 23:11:21 -04:00
|
|
|
child: Revealer({
|
|
|
|
transition,
|
2023-10-30 19:53:50 -04:00
|
|
|
transitionDuration,
|
2023-10-20 23:11:21 -04:00
|
|
|
connections: [[App, (rev, currentName, visible) => {
|
|
|
|
if (currentName === name) {
|
2023-10-30 19:53:50 -04:00
|
|
|
rev.revealChild = visible;
|
2023-10-20 23:11:21 -04:00
|
|
|
onOpen(child);
|
|
|
|
}
|
|
|
|
}]],
|
|
|
|
child: child,
|
|
|
|
}),
|
|
|
|
}),
|
|
|
|
});
|
2023-10-30 19:53:50 -04:00
|
|
|
|
|
|
|
// Make getting the original child passed in
|
|
|
|
// this function easier when making more code
|
|
|
|
// for the widget
|
2023-10-20 23:11:21 -04:00
|
|
|
window.getChild = () => child;
|
2023-10-30 19:53:50 -04:00
|
|
|
|
|
|
|
// This is for my custom pointers.js
|
2023-10-24 17:26:38 -04:00
|
|
|
window.closeOnUnfocus = closeOnUnfocus;
|
2023-10-30 19:53:50 -04:00
|
|
|
|
2023-10-20 23:11:21 -04:00
|
|
|
return window;
|
|
|
|
};
|