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';
|
|
|
|
|
2024-01-13 11:15:08 -05:00
|
|
|
// Types
|
|
|
|
import { Variable as Var } from 'types/variable';
|
|
|
|
import AgsBox from 'types/widgets/box';
|
|
|
|
import { RevealerProps } from 'types/widgets/revealer';
|
2023-11-16 00:48:50 -05:00
|
|
|
|
2024-01-13 11:15:08 -05:00
|
|
|
const BarCloser = (variable: Var<boolean>) => 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-19 13:44:12 -05:00
|
|
|
const parent = self.get_parent();
|
|
|
|
|
|
|
|
if (parent) {
|
|
|
|
parent.visible = false;
|
|
|
|
}
|
2023-11-16 00:48:50 -05:00
|
|
|
},
|
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
|
|
|
|
2024-01-13 11:15:08 -05:00
|
|
|
export default (props: RevealerProps) => {
|
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'];
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2024-01-13 11:15:08 -05:00
|
|
|
const checkGlobalFsState = (_: AgsBox, fullscreen: boolean) => {
|
2023-12-19 12:28:29 -05:00
|
|
|
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-12-19 13:44:12 -05:00
|
|
|
}).bind('reveal_child', Revealed),
|
2023-11-06 20:38:16 -05:00
|
|
|
|
2023-11-16 00:48:50 -05:00
|
|
|
Revealer({
|
2023-12-19 13:44:12 -05:00
|
|
|
reveal_child: Revealed.bind()
|
|
|
|
.transform((v) => !v),
|
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: () => {
|
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
|
|
|
],
|
|
|
|
});
|
|
|
|
};
|