-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmouse.go
91 lines (71 loc) · 1.43 KB
/
mouse.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
package main
import (
"gioui.org/f32"
"gioui.org/io/pointer"
"gioui.org/unit"
)
type Mouse struct {
x, y float64
px, py float64
force float64
scrollY unit.Dp
maxScrollY unit.Dp
leftDown bool
rightDown bool
isDragging bool
ctrlDown bool
}
func (m *Mouse) updatePosition(x, y float64) {
m.px = m.x
m.py = m.y
m.x = x
m.y = y
}
func (m *Mouse) getCurrentPosition(ev pointer.Event) f32.Point {
return ev.Position
}
func (m *Mouse) setLeftButton() {
m.leftDown = true
}
func (m *Mouse) releaseLeftButton() {
m.leftDown = false
}
func (m *Mouse) getLeftButton() bool {
return m.leftDown
}
func (m *Mouse) setRightButton() {
m.rightDown = true
}
func (m *Mouse) releaseRightButton() {
m.rightDown = false
}
func (m *Mouse) getRightButton() bool {
return m.rightDown
}
func (m *Mouse) setDragging(dragging bool) {
m.isDragging = dragging
}
func (m *Mouse) getDragging() bool {
return m.isDragging
}
func (m *Mouse) setCtrlDown(status bool) {
m.ctrlDown = status
}
func (m *Mouse) getCtrlDown() bool {
return m.ctrlDown
}
func (m *Mouse) setForce(force float64) {
m.force = force
}
func (m *Mouse) getForce() float64 {
return m.force
}
func (m *Mouse) resetForce() {
m.force = 0
}
func (m *Mouse) setScrollY(scrollY unit.Dp) {
m.scrollY = scrollY
}
func (m *Mouse) getScrollY() unit.Dp {
return m.scrollY
}