2023-11-16 00:48:50 -05:00
|
|
|
import Hyprland from 'resource:///com/github/Aylur/ags/service/hyprland.js';
|
|
|
|
import Variable from 'resource:///com/github/Aylur/ags/variable.js';
|
|
|
|
|
|
|
|
import { Box, EventBox, Revealer, Window } from 'resource:///com/github/Aylur/ags/widget.js';
|
|
|
|
|
|
|
|
|
2023-12-18 18:00:30 -05:00
|
|
|
/** @param {import('types/variable.js').Variable} variable */
|
2023-11-21 01:29:46 -05:00
|
|
|
const BarCloser = (variable) => Window({
|
2023-11-16 00:48:50 -05:00
|
|
|
name: 'bar-closer',
|
|
|
|
visible: false,
|
|
|
|
anchor: ['top', 'bottom', 'left', 'right'],
|
|
|
|
layer: 'overlay',
|
2023-11-21 01:29:46 -05:00
|
|
|
|
2023-11-16 00:48:50 -05:00
|
|
|
child: EventBox({
|
2023-12-18 18:00:30 -05:00
|
|
|
on_hover: (self) => {
|
2023-11-16 00:48:50 -05:00
|
|
|
variable.value = false;
|
2023-12-18 18:00:30 -05:00
|
|
|
// @ts-expect-error
|
2023-11-16 00:48:50 -05:00
|
|
|
self.get_parent().visible = false;
|
|
|
|
},
|
2023-11-21 01:29:46 -05:00
|
|
|
|
2023-11-16 00:48:50 -05:00
|
|
|
child: Box({
|
|
|
|
css: 'padding: 1px',
|
|
|
|
}),
|
|
|
|
}),
|
2023-10-21 01:15:21 -04:00
|
|
|
});
|
2023-10-17 13:47:02 -04:00
|
|
|
|
2023-12-18 18:00:30 -05:00
|
|
|
/** @param {import('types/widgets/revealer').RevealerProps} props */
|
2023-11-21 01:29:46 -05:00
|
|
|
export default (props) => {
|
2023-11-16 00:48:50 -05:00
|
|
|
const Revealed = Variable(true);
|
|
|
|
const barCloser = BarCloser(Revealed);
|
|
|
|
|
|
|
|
return Box({
|
|
|
|
css: 'min-height: 1px',
|
|
|
|
hexpand: true,
|
|
|
|
vertical: true,
|
2023-11-21 01:29:46 -05:00
|
|
|
|
2023-12-17 00:01:58 -05:00
|
|
|
setup: (self) => {
|
2023-12-19 12:28:29 -05:00
|
|
|
const checkCurrentWsFsState = () => {
|
|
|
|
const workspace = Hyprland.getWorkspace(
|
|
|
|
Hyprland.active.workspace.id,
|
|
|
|
);
|
|
|
|
|
|
|
|
if (workspace) {
|
|
|
|
Revealed.value = !workspace['hasfullscreen'];
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param {import('types/widgets/box').default} _
|
|
|
|
* @param {boolean} fullscreen
|
|
|
|
*/
|
|
|
|
const checkGlobalFsState = (_, fullscreen) => {
|
|
|
|
Revealed.value = !fullscreen;
|
|
|
|
};
|
|
|
|
|
2023-12-17 00:01:58 -05:00
|
|
|
self
|
2023-12-19 12:28:29 -05:00
|
|
|
.hook(Hyprland.active, checkCurrentWsFsState)
|
|
|
|
.hook(Hyprland, checkGlobalFsState, 'fullscreen');
|
2023-12-17 00:01:58 -05:00
|
|
|
},
|
2023-11-21 01:29:46 -05:00
|
|
|
|
2023-11-16 00:48:50 -05:00
|
|
|
children: [
|
|
|
|
Revealer({
|
2023-11-21 01:29:46 -05:00
|
|
|
...props,
|
2023-11-16 00:48:50 -05:00
|
|
|
transition: 'slide_down',
|
2023-12-18 18:00:30 -05:00
|
|
|
reveal_child: true,
|
2023-11-21 01:29:46 -05:00
|
|
|
|
2023-11-16 00:48:50 -05:00
|
|
|
binds: [['revealChild', Revealed, 'value']],
|
2023-10-20 23:11:21 -04:00
|
|
|
}),
|
2023-11-06 20:38:16 -05:00
|
|
|
|
2023-11-16 00:48:50 -05:00
|
|
|
Revealer({
|
2023-11-21 01:29:46 -05:00
|
|
|
binds: [['revealChild', Revealed, 'value', (v) => !v]],
|
|
|
|
|
2023-11-16 00:48:50 -05:00
|
|
|
child: EventBox({
|
2023-12-18 18:00:30 -05:00
|
|
|
on_hover: () => {
|
2023-11-16 00:48:50 -05:00
|
|
|
barCloser.visible = true;
|
|
|
|
Revealed.value = true;
|
|
|
|
},
|
2023-11-21 01:29:46 -05:00
|
|
|
|
2023-11-16 00:48:50 -05:00
|
|
|
child: Box({
|
|
|
|
css: 'min-height: 5px;',
|
|
|
|
}),
|
2023-10-20 23:11:21 -04:00
|
|
|
}),
|
|
|
|
}),
|
2023-11-16 00:48:50 -05:00
|
|
|
],
|
|
|
|
});
|
|
|
|
};
|