summaryrefslogtreecommitdiff
path: root/core/src/widget/button.vala
diff options
context:
space:
mode:
authorAylur <[email protected]>2024-10-15 01:26:32 +0200
committerAylur <[email protected]>2024-10-15 01:26:32 +0200
commit2f71cd4c08bb4514efe43533e6a5d03535204c29 (patch)
treefc991a12e159ad645187862c90f40731794d6e47 /core/src/widget/button.vala
parent9fab13452a26ed55c01047d4225f699f43bba20d (diff)
refactor lua and gjs lib
Diffstat (limited to 'core/src/widget/button.vala')
-rw-r--r--core/src/widget/button.vala101
1 files changed, 0 insertions, 101 deletions
diff --git a/core/src/widget/button.vala b/core/src/widget/button.vala
deleted file mode 100644
index ad60da1..0000000
--- a/core/src/widget/button.vala
+++ /dev/null
@@ -1,101 +0,0 @@
-namespace Astal {
-public class Button : Gtk.Button {
- public signal void hover (HoverEvent event);
- public signal void hover_lost (HoverEvent event);
- public signal void click (ClickEvent event);
- public signal void click_release (ClickEvent event);
- public signal void scroll (ScrollEvent event);
-
- construct {
- add_events(Gdk.EventMask.SCROLL_MASK);
- add_events(Gdk.EventMask.SMOOTH_SCROLL_MASK);
-
- enter_notify_event.connect((self, event) => {
- hover(HoverEvent(event) { lost = false });
- });
-
- leave_notify_event.connect((self, event) => {
- hover_lost(HoverEvent(event) { lost = true });
- });
-
- button_press_event.connect((event) => {
- click(ClickEvent(event) { release = false });
- });
-
- button_release_event.connect((event) => {
- click_release(ClickEvent(event) { release = true });
- });
-
- scroll_event.connect((event) => {
- scroll(ScrollEvent(event));
- });
- }
-}
-
-public enum MouseButton {
- PRIMARY = 1,
- MIDDLE = 2,
- SECONDARY = 3,
- BACK = 4,
- FORWARD = 5,
-}
-
-// these structs are here because gjs converts every event
-// into a union Gdk.Event, which cannot be destructured
-// and are not as convinent to work with as a struct
-public struct ClickEvent {
- bool release;
- uint time;
- double x;
- double y;
- Gdk.ModifierType modifier;
- MouseButton button;
-
- public ClickEvent(Gdk.EventButton event) {
- this.time = event.time;
- this.x = event.x;
- this.y = event.y;
- this.button = (MouseButton)event.button;
- this.modifier = event.state;
- }
-}
-
-public struct HoverEvent {
- bool lost;
- uint time;
- double x;
- double y;
- Gdk.ModifierType modifier;
- Gdk.CrossingMode mode;
- Gdk.NotifyType detail;
-
- public HoverEvent(Gdk.EventCrossing event) {
- this.time = event.time;
- this.x = event.x;
- this.y = event.y;
- this.modifier = event.state;
- this.mode = event.mode;
- this.detail = event.detail;
- }
-}
-
-public struct ScrollEvent {
- uint time;
- double x;
- double y;
- Gdk.ModifierType modifier;
- Gdk.ScrollDirection direction;
- double delta_x;
- double delta_y;
-
- public ScrollEvent(Gdk.EventScroll event) {
- this.time = event.time;
- this.x = event.x;
- this.y = event.y;
- this.modifier = event.state;
- this.direction = event.direction;
- this.delta_x = event.delta_x;
- this.delta_y = event.delta_y;
- }
-}
-}