-
Notifications
You must be signed in to change notification settings - Fork 3
/
uiAction_darwin.go
107 lines (87 loc) · 2.62 KB
/
uiAction_darwin.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
package qframelesswindow
import (
"github.com/akiyosi/qt/core"
"github.com/akiyosi/qt/gui"
)
func (f *QFramelessWindow) SetupTitleBarActions() {
t := f.TitleBar
// TitleBar Actions
t.ConnectMousePressEvent(func(e *gui.QMouseEvent) {
f.Widget.Raise()
f.IsTitleBarPressed = true
f.TitleBarMousePos = e.GlobalPos()
f.Position = f.Pos()
})
t.ConnectMouseReleaseEvent(func(e *gui.QMouseEvent) {
f.IsTitleBarPressed = false
})
t.ConnectMouseMoveEvent(func(e *gui.QMouseEvent) {
if !f.IsTitleBarPressed {
return
}
x := f.Position.X() + e.GlobalPos().X() - f.TitleBarMousePos.X()
y := f.Position.Y() + e.GlobalPos().Y() - f.TitleBarMousePos.Y()
newPos := core.NewQPoint2(x, y)
f.Move(newPos)
})
t.ConnectMouseDoubleClickEvent(func(e *gui.QMouseEvent) {
if f.WindowState() == core.Qt__WindowFullScreen {
f.WindowRestore()
} else {
f.ShowFullScreen()
}
})
// // Button Actions
// f.BtnMinimize.ConnectMousePressEvent(func(e *gui.QMouseEvent) {
// f.IsTitleBarPressed = false
// })
// f.BtnMaximize.ConnectMousePressEvent(func(e *gui.QMouseEvent) {
// f.IsTitleBarPressed = false
// })
// f.BtnRestore.ConnectMousePressEvent(func(e *gui.QMouseEvent) {
// f.IsTitleBarPressed = false
// })
// f.BtnClose.ConnectMousePressEvent(func(e *gui.QMouseEvent) {
// f.IsTitleBarPressed = false
// })
// f.BtnMinimize.ConnectMouseReleaseEvent(func(e *gui.QMouseEvent) {
// f.WindowMinimize()
// f.Widget.Hide()
// f.Widget.Show()
// })
// f.BtnMaximize.ConnectMouseReleaseEvent(func(e *gui.QMouseEvent) {
// f.WindowMaximize()
// f.Widget.Hide()
// f.Widget.Show()
// })
// f.BtnRestore.ConnectMouseReleaseEvent(func(e *gui.QMouseEvent) {
// f.WindowRestore()
// f.Widget.Hide()
// f.Widget.Show()
// })
// f.BtnClose.ConnectMouseReleaseEvent(func(e *gui.QMouseEvent) {
// f.Close()
// })
}
func (f *QFramelessWindow) WindowFullScreen() {
// f.ShowFullScreen()
f.SetWindowState(f.WindowState() | core.Qt__WindowFullScreen)
}
func (f *QFramelessWindow) WindowExitFullScreen() {
f.SetWindowState(f.WindowState() & ^core.Qt__WindowFullScreen)
}
func (f *QFramelessWindow) WindowMinimize() {
f.SetWindowState(f.WindowState() | core.Qt__WindowMinimized)
}
func (f *QFramelessWindow) WindowMaximize() {
f.Layout.SetContentsMargins(0, 0, 0, 0)
f.SetWindowState(f.WindowState() | core.Qt__WindowMaximized)
}
func (f *QFramelessWindow) WindowExitMaximize() {
f.Layout.SetContentsMargins(0, 0, 0, 0)
f.SetWindowState(f.WindowState() & ^core.Qt__WindowMaximized)
}
func (f *QFramelessWindow) WindowRestore() {
f.Layout.SetContentsMargins(0, 0, 0, 0)
f.SetWindowState(core.Qt__WindowNoState)
}