Skip to content

Commit 2bc7621

Browse files
committed
Migrated window.go, box.go, button.go, and checkbox.go back.
1 parent 8096624 commit 2bc7621

File tree

6 files changed

+37
-22
lines changed

6 files changed

+37
-22
lines changed

BBB_GOFILES/box.go renamed to box.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"unsafe"
77
)
88

9-
// #include "ui.h"
9+
// #include "pkgui.h"
1010
import "C"
1111

1212
// Box is a Control that holds a group of Controls horizontally

BBB_GOFILES/button.go renamed to button.go

+4-7
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@ import (
66
"unsafe"
77
)
88

9-
// #include "ui.h"
10-
// extern void doButtonOnClicked(uiButton *, void *);
11-
// // see golang/go#19835
12-
// typedef void (*buttonCallback)(uiButton *, void *);
9+
// #include "pkgui.h"
1310
import "C"
1411

1512
// Button is a Control that represents a button that the user can
@@ -29,7 +26,7 @@ func NewButton(text string) *Button {
2926
b.b = C.uiNewButton(ctext)
3027
freestr(ctext)
3128

32-
C.uiButtonOnClicked(b.b, C.buttonCallback(C.doButtonOnClicked), nil)
29+
C.pkguiButtonOnClicked(b.b)
3330

3431
b.ControlBase = NewControlBase(b, uintptr(unsafe.Pointer(b.b)))
3532
return b
@@ -56,8 +53,8 @@ func (b *Button) OnClicked(f func(*Button)) {
5653
b.onClicked = f
5754
}
5855

59-
//export doButtonOnClicked
60-
func doButtonOnClicked(bb *C.uiButton, data unsafe.Pointer) {
56+
//export pkguiDoButtonOnClicked
57+
func pkguiDoButtonOnClicked(bb *C.uiButton, data unsafe.Pointer) {
6158
b := ControlFromLibui(uintptr(unsafe.Pointer(bb))).(*Button)
6259
if b.onClicked != nil {
6360
b.onClicked(b)

BBB_GOFILES/checkbox.go renamed to checkbox.go

+4-7
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@ import (
66
"unsafe"
77
)
88

9-
// #include "ui.h"
10-
// extern void doCheckboxOnToggled(uiCheckbox *, void *);
11-
// // see golang/go#19835
12-
// typedef void (*checkboxCallback)(uiCheckbox *, void *);
9+
// #include "pkgui.h"
1310
import "C"
1411

1512
// Checkbox is a Control that represents a box with a text label at its
@@ -30,7 +27,7 @@ func NewCheckbox(text string) *Checkbox {
3027
c.c = C.uiNewCheckbox(ctext)
3128
freestr(ctext)
3229

33-
C.uiCheckboxOnToggled(c.c, C.checkboxCallback(C.doCheckboxOnToggled), nil)
30+
C.pkguiCheckboxOnToggled(c.c)
3431

3532
c.ControlBase = NewControlBase(c, uintptr(unsafe.Pointer(c.c)))
3633
return c
@@ -57,8 +54,8 @@ func (c *Checkbox) OnToggled(f func(*Checkbox)) {
5754
c.onToggled = f
5855
}
5956

60-
//export doCheckboxOnToggled
61-
func doCheckboxOnToggled(cc *C.uiCheckbox, data unsafe.Pointer) {
57+
//export pkguiDoCheckboxOnToggled
58+
func pkguiDoCheckboxOnToggled(cc *C.uiCheckbox, data unsafe.Pointer) {
6259
c := ControlFromLibui(uintptr(unsafe.Pointer(cc))).(*Checkbox)
6360
if c.onToggled != nil {
6461
c.onToggled(c)

pkgui.c

+15
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,18 @@ void pkguiOnShouldQuit(void)
2121
{
2222
uiOnShouldQuit(pkguiDoOnShouldQuit, NULL);
2323
}
24+
25+
void pkguiWindowOnClosing(uiWindow *w)
26+
{
27+
uiWindowOnClosing(w, pkguiDoWindowOnClosing, NULL);
28+
}
29+
30+
void pkguiButtonOnClicked(uiButton *b)
31+
{
32+
uiButtonOnClicked(b, pkguiDoButtonOnClicked, NULL);
33+
}
34+
35+
void pkguiCheckboxOnToggled(uiCheckbox *c)
36+
{
37+
uiCheckboxOnToggled(c, pkguiDoCheckboxOnToggled, NULL);
38+
}

pkgui.h

+9
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,12 @@ extern uiInitOptions *pkguiAllocInitOptions(void);
77
extern void pkguiFreeInitOptions(uiInitOptions *o);
88
extern void pkguiQueueMain(uintptr_t n);
99
extern void pkguiOnShouldQuit(void);
10+
11+
// window.go
12+
extern void pkguiWindowOnClosing(uiWindow *w);
13+
14+
// button.go
15+
extern void pkguiButtonOnClicked(uiButton *b);
16+
17+
// checkbox.go
18+
extern void pkguiCheckboxOnToggled(uiCheckbox *c);

BBB_GOFILES/window.go renamed to window.go

+4-7
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@ import (
66
"unsafe"
77
)
88

9-
// #include "ui.h"
10-
// extern int doWindowOnClosing(uiWindow *, void *);
11-
// // see golang/go#19835
12-
// typedef int (*windowOnClosingCallback)(uiWindow *, void *);
9+
// #include "pkgui.h"
1310
import "C"
1411

1512
// Window is a Control that represents a top-level window.
@@ -31,7 +28,7 @@ func NewWindow(title string, width int, height int, hasMenubar bool) *Window {
3128
w.w = C.uiNewWindow(ctitle, C.int(width), C.int(height), frombool(hasMenubar))
3229
freestr(ctitle)
3330

34-
C.uiWindowOnClosing(w.w, C.windowOnClosingCallback(C.doWindowOnClosing), nil)
31+
C.pkguiWindowOnClosing(w.w)
3532

3633
w.ControlBase = NewControlBase(w, uintptr(unsafe.Pointer(w.w)))
3734
return w
@@ -79,8 +76,8 @@ func (w *Window) OnClosing(f func(*Window) bool) {
7976
w.onClosing = f
8077
}
8178

82-
//export doWindowOnClosing
83-
func doWindowOnClosing(ww *C.uiWindow, data unsafe.Pointer) C.int {
79+
//export pkguiDoWindowOnClosing
80+
func pkguiDoWindowOnClosing(ww *C.uiWindow, data unsafe.Pointer) C.int {
8481
w := ControlFromLibui(uintptr(unsafe.Pointer(ww))).(*Window)
8582
if w.onClosing == nil {
8683
return 0

0 commit comments

Comments
 (0)