nixos-configs/devices/wim/config/ags/ts/bar/fullscreen.ts

88 lines
2.3 KiB
TypeScript
Raw Normal View History

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-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;
const parent = self.get_parent();
if (parent) {
parent.visible = false;
}
2023-11-16 00:48:50 -05:00
},
2023-11-16 00:48:50 -05:00
child: Box({
css: 'padding: 1px',
}),
}),
});
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,
setup: (self) => {
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) => {
Revealed.value = !fullscreen;
};
self
.hook(Hyprland.active, checkCurrentWsFsState)
.hook(Hyprland, checkGlobalFsState, 'fullscreen');
},
2023-11-16 00:48:50 -05:00
children: [
Revealer({
...props,
2023-11-16 00:48:50 -05:00
transition: 'slide_down',
2023-12-18 18:00:30 -05:00
reveal_child: true,
}).bind('reveal_child', Revealed),
2023-11-16 00:48:50 -05:00
Revealer({
reveal_child: Revealed.bind()
.transform((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-16 00:48:50 -05:00
child: Box({
css: 'min-height: 5px;',
}),
}),
}),
2023-11-16 00:48:50 -05:00
],
});
};