refactor(ags popups): use setters properly and add on_* func props
All checks were successful
Discord / discord commits (push) Has been skipped
All checks were successful
Discord / discord commits (push) Has been skipped
This commit is contained in:
parent
6881d583b7
commit
dd7b67e811
1 changed files with 44 additions and 16 deletions
|
@ -24,26 +24,54 @@ export class PopupWindow<
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
#close_on_unfocus: CloseType;
|
|
||||||
#transition: HyprTransition;
|
private _close_on_unfocus: CloseType;
|
||||||
|
|
||||||
get close_on_unfocus() {
|
get close_on_unfocus() {
|
||||||
return this.#close_on_unfocus;
|
return this._close_on_unfocus;
|
||||||
}
|
}
|
||||||
|
|
||||||
set close_on_unfocus(value: CloseType) {
|
set close_on_unfocus(value: CloseType) {
|
||||||
this.#close_on_unfocus = value;
|
this._close_on_unfocus = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private _transition = 'unset' as HyprTransition;
|
||||||
|
|
||||||
get transition() {
|
get transition() {
|
||||||
return this.#transition;
|
return this._transition;
|
||||||
}
|
}
|
||||||
|
|
||||||
set transition(t: HyprTransition) {
|
set transition(t: HyprTransition) {
|
||||||
this.#transition = t;
|
Hyprland.messageAsync(
|
||||||
Hyprland.messageAsync(`keyword layerrule animation ${t}, ${this.name}`);
|
`keyword layerrule animation ${t}, ${this.name}`,
|
||||||
|
).catch(logError);
|
||||||
|
this._transition = t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private _on_open: (self: PopupWindow<Child, Attr>) => void;
|
||||||
|
|
||||||
|
get on_open() {
|
||||||
|
return this._on_open;
|
||||||
|
}
|
||||||
|
|
||||||
|
set on_open(fun: (self: PopupWindow<Child, Attr>) => void) {
|
||||||
|
this._on_open = fun;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private _on_close: (self: PopupWindow<Child, Attr>) => void;
|
||||||
|
|
||||||
|
get on_close() {
|
||||||
|
return this._on_close;
|
||||||
|
}
|
||||||
|
|
||||||
|
set on_close(fun: (self: PopupWindow<Child, Attr>) => void) {
|
||||||
|
this._on_close = fun;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
constructor({
|
constructor({
|
||||||
transition = 'slide top',
|
transition = 'slide top',
|
||||||
on_open = () => {/**/},
|
on_open = () => {/**/},
|
||||||
|
@ -70,29 +98,29 @@ export class PopupWindow<
|
||||||
App.openWindow(`win-${name}`);
|
App.openWindow(`win-${name}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Make sure Hyprland got the message
|
||||||
|
this.transition = transition;
|
||||||
|
|
||||||
// This connection should always run only once
|
// This connection should always run only once
|
||||||
App.disconnect(id);
|
App.disconnect(id);
|
||||||
});
|
});
|
||||||
|
|
||||||
Hyprland.messageAsync(
|
|
||||||
`keyword layerrule animation ${transition}, win-${name}`,
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this._close_on_unfocus = close_on_unfocus;
|
||||||
|
this._on_open = on_open;
|
||||||
|
this._on_close = on_close;
|
||||||
|
|
||||||
this.hook(App, (_, currentName, isOpen) => {
|
this.hook(App, (_, currentName, isOpen) => {
|
||||||
if (currentName === `win-${name}`) {
|
if (currentName === `win-${name}`) {
|
||||||
if (isOpen) {
|
if (isOpen) {
|
||||||
on_open(this);
|
this.on_open(this);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
on_close(this);
|
this.on_close(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.#close_on_unfocus = close_on_unfocus;
|
|
||||||
this.#transition = transition;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
set_x_pos(
|
set_x_pos(
|
||||||
|
|
Loading…
Reference in a new issue