2023-11-06 21:41:30 -05:00
|
|
|
import { Button, EventBox } from 'resource:///com/github/Aylur/ags/widget.js';
|
2023-10-02 12:06:35 -04:00
|
|
|
|
2023-09-04 22:27:34 -04:00
|
|
|
import Gdk from 'gi://Gdk';
|
|
|
|
const display = Gdk.Display.get_default();
|
|
|
|
|
2023-10-02 12:06:35 -04:00
|
|
|
|
2023-10-17 13:47:02 -04:00
|
|
|
export default ({
|
2023-11-06 18:37:23 -05:00
|
|
|
isButton = false,
|
2023-10-20 23:11:21 -04:00
|
|
|
reset = true,
|
2023-11-08 11:41:07 -05:00
|
|
|
onHover = () => {},
|
|
|
|
onHoverLost = () => {},
|
2023-10-20 23:11:21 -04:00
|
|
|
...props
|
2023-10-17 13:47:02 -04:00
|
|
|
}) => {
|
2023-11-06 18:37:23 -05:00
|
|
|
if (!isButton) {
|
2023-11-06 21:41:30 -05:00
|
|
|
return EventBox({
|
2023-10-20 23:11:21 -04:00
|
|
|
...props,
|
|
|
|
onHover: self => {
|
|
|
|
if (!self.child.sensitive || !self.sensitive)
|
|
|
|
self.window.set_cursor(Gdk.Cursor.new_from_name(display, 'not-allowed'));
|
|
|
|
|
|
|
|
else
|
|
|
|
self.window.set_cursor(Gdk.Cursor.new_from_name(display, 'pointer'));
|
2023-11-08 11:41:07 -05:00
|
|
|
|
|
|
|
onHover(self);
|
2023-10-20 23:11:21 -04:00
|
|
|
},
|
|
|
|
onHoverLost: self => {
|
|
|
|
if (reset)
|
|
|
|
self.window.set_cursor(null);
|
2023-11-08 11:41:07 -05:00
|
|
|
|
|
|
|
onHoverLost(self);
|
2023-10-20 23:11:21 -04:00
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
|
|
|
else {
|
2023-11-06 21:41:30 -05:00
|
|
|
return Button({
|
2023-10-20 23:11:21 -04:00
|
|
|
...props,
|
|
|
|
onHover: self => {
|
|
|
|
if (!self.child.sensitive || !self.sensitive)
|
|
|
|
self.window.set_cursor(Gdk.Cursor.new_from_name(display, 'not-allowed'));
|
|
|
|
else
|
|
|
|
self.window.set_cursor(Gdk.Cursor.new_from_name(display, 'pointer'));
|
|
|
|
},
|
|
|
|
onHoverLost: self => {
|
|
|
|
if (reset)
|
|
|
|
self.window.set_cursor(null);
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|