diff options
| author | srdusr <trevorgray@srdusr.com> | 2024-06-13 13:11:05 +0200 |
|---|---|---|
| committer | srdusr <trevorgray@srdusr.com> | 2024-06-13 13:11:05 +0200 |
| commit | d0fbb19623e4fb6097e1ff3ee49c6a76a0928d0e (patch) | |
| tree | 937531ddf423d3935c6e20c8a9227e39ce782241 /.config/ags/lib/cursorhover.js | |
| parent | 4ccbe0270c25ecab492508b5b0209ae53b9c35bd (diff) | |
| download | dotfiles-d0fbb19623e4fb6097e1ff3ee49c6a76a0928d0e.tar.gz dotfiles-d0fbb19623e4fb6097e1ff3ee49c6a76a0928d0e.zip | |
Add ags
Diffstat (limited to '.config/ags/lib/cursorhover.js')
| -rw-r--r-- | .config/ags/lib/cursorhover.js | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/.config/ags/lib/cursorhover.js b/.config/ags/lib/cursorhover.js new file mode 100644 index 0000000..d93d021 --- /dev/null +++ b/.config/ags/lib/cursorhover.js @@ -0,0 +1,86 @@ +const { Gdk, Gtk } = imports.gi; + +const CLICK_BRIGHTEN_AMOUNT = 0.13; + +export function setupCursorHover(button) { + const display = Gdk.Display.get_default(); + button.connect('enter-notify-event', () => { + const cursor = Gdk.Cursor.new_from_name(display, 'pointer'); + button.get_window().set_cursor(cursor); + }); + + button.connect('leave-notify-event', () => { + const cursor = Gdk.Cursor.new_from_name(display, 'default'); + button.get_window().set_cursor(cursor); + }); + +} + +export function setupCursorHoverAim(button) { + button.connect('enter-notify-event', () => { + const display = Gdk.Display.get_default(); + const cursor = Gdk.Cursor.new_from_name(display, 'crosshair'); + button.get_window().set_cursor(cursor); + }); + + button.connect('leave-notify-event', () => { + const display = Gdk.Display.get_default(); + const cursor = Gdk.Cursor.new_from_name(display, 'default'); + button.get_window().set_cursor(cursor); + }); +} + +export function setupCursorHoverGrab(button) { + button.connect('enter-notify-event', () => { + const display = Gdk.Display.get_default(); + const cursor = Gdk.Cursor.new_from_name(display, 'grab'); + button.get_window().set_cursor(cursor); + }); + + button.connect('leave-notify-event', () => { + const display = Gdk.Display.get_default(); + const cursor = Gdk.Cursor.new_from_name(display, 'default'); + button.get_window().set_cursor(cursor); + }); +} + +// failed radial ripple experiment +// +// var clicked = false; +// var dummy = false; +// var cursorX = 0; +// var cursorY = 0; +// const styleContext = button.get_style_context(); +// var clickColor = styleContext.get_property('background-color', Gtk.StateFlags.HOVER); +// clickColor.green += CLICK_BRIGHTEN_AMOUNT; +// clickColor.blue += CLICK_BRIGHTEN_AMOUNT; +// clickColor.red += CLICK_BRIGHTEN_AMOUNT; +// clickColor = clickColor.to_string(); +// button.add_events(Gdk.EventMask.POINTER_MOTION_MASK); +// button.connect('motion-notify-event', (widget, event) => { +// [dummy, cursorX, cursorY] = event.get_coords(); // Get the mouse coordinates relative to the widget +// if(!clicked) widget.css = ` +// background-image: radial-gradient(circle at ${cursorX}px ${cursorY}px, rgba(0,0,0,0), rgba(0,0,0,0) 0%, rgba(0,0,0,0) 0%, ${clickColor} 0%, ${clickColor} 0%, ${clickColor} 0%, ${clickColor} 0%, rgba(0,0,0,0) 0%, rgba(0,0,0,0) 0%); +// `; +// }); + +// button.connect('button-press-event', (widget, event) => { +// clicked = true; +// [dummy, cursorX, cursorY] = event.get_coords(); // Get the mouse coordinates relative to the widget +// cursorX = Math.round(cursorX); cursorY = Math.round(cursorY); +// widget.css = ` +// background-image: radial-gradient(circle at ${cursorX}px ${cursorY}px, rgba(0,0,0,0), rgba(0,0,0,0) 0%, rgba(0,0,0,0) 0%, ${clickColor} 0%, ${clickColor} 0%, ${clickColor} 0%, ${clickColor} 0%, rgba(0,0,0,0) 0%, rgba(0,0,0,0) 0%); +// `; +// widget.toggleClassName('growingRadial', true); +// widget.css = ` +// background-image: radial-gradient(circle at ${cursorX}px ${cursorY}px, rgba(0,0,0,0), rgba(0,0,0,0) 0%, rgba(0,0,0,0) 0%, ${clickColor} 0%, ${clickColor} 0%, ${clickColor} 70%, ${clickColor} 70%, rgba(0,0,0,0) 70%, rgba(0,0,0,0) 70%); +// ` +// }); +// button.connect('button-release-event', (widget, event) => { +// widget.toggleClassName('growingRadial', false); +// widget.toggleClassName('fadingRadial', false); +// widget.css = ` +// background-image: radial-gradient(circle at ${cursorX}px ${cursorY}px, rgba(0,0,0,0), rgba(0,0,0,0) 0%, rgba(0,0,0,0) 0%, rgba(0,0,0,0) 0%, rgba(0,0,0,0) 0%, rgba(0,0,0,0) 70%, rgba(0,0,0,0) 70%, rgba(0,0,0,0) 70%, rgba(0,0,0,0) 70%); +// ` +// clicked = false; +// }); |
