summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2018-08-26 13:24:47 -0400
committerPietro Gagliardi <[email protected]>2018-08-26 13:24:47 -0400
commit2bc76219286dfe39949772ceee4dbd9560ec2c1f (patch)
tree28ae5f6f24c4a12ce349bc39490a7dda068d087a
parent809662459dcd2cbe0b42f338413b88fea0483086 (diff)
Migrated window.go, box.go, button.go, and checkbox.go back.
-rw-r--r--box.go (renamed from BBB_GOFILES/box.go)2
-rw-r--r--button.go (renamed from BBB_GOFILES/button.go)11
-rw-r--r--checkbox.go (renamed from BBB_GOFILES/checkbox.go)11
-rw-r--r--pkgui.c15
-rw-r--r--pkgui.h9
-rw-r--r--window.go (renamed from BBB_GOFILES/window.go)11
6 files changed, 37 insertions, 22 deletions
diff --git a/BBB_GOFILES/box.go b/box.go
index 65421d4..99be5cb 100644
--- a/BBB_GOFILES/box.go
+++ b/box.go
@@ -6,7 +6,7 @@ import (
"unsafe"
)
-// #include "ui.h"
+// #include "pkgui.h"
import "C"
// Box is a Control that holds a group of Controls horizontally
diff --git a/BBB_GOFILES/button.go b/button.go
index 630c684..9e39918 100644
--- a/BBB_GOFILES/button.go
+++ b/button.go
@@ -6,10 +6,7 @@ import (
"unsafe"
)
-// #include "ui.h"
-// extern void doButtonOnClicked(uiButton *, void *);
-// // see golang/go#19835
-// typedef void (*buttonCallback)(uiButton *, void *);
+// #include "pkgui.h"
import "C"
// Button is a Control that represents a button that the user can
@@ -29,7 +26,7 @@ func NewButton(text string) *Button {
b.b = C.uiNewButton(ctext)
freestr(ctext)
- C.uiButtonOnClicked(b.b, C.buttonCallback(C.doButtonOnClicked), nil)
+ C.pkguiButtonOnClicked(b.b)
b.ControlBase = NewControlBase(b, uintptr(unsafe.Pointer(b.b)))
return b
@@ -56,8 +53,8 @@ func (b *Button) OnClicked(f func(*Button)) {
b.onClicked = f
}
-//export doButtonOnClicked
-func doButtonOnClicked(bb *C.uiButton, data unsafe.Pointer) {
+//export pkguiDoButtonOnClicked
+func pkguiDoButtonOnClicked(bb *C.uiButton, data unsafe.Pointer) {
b := ControlFromLibui(uintptr(unsafe.Pointer(bb))).(*Button)
if b.onClicked != nil {
b.onClicked(b)
diff --git a/BBB_GOFILES/checkbox.go b/checkbox.go
index 8177226..22c4c5f 100644
--- a/BBB_GOFILES/checkbox.go
+++ b/checkbox.go
@@ -6,10 +6,7 @@ import (
"unsafe"
)
-// #include "ui.h"
-// extern void doCheckboxOnToggled(uiCheckbox *, void *);
-// // see golang/go#19835
-// typedef void (*checkboxCallback)(uiCheckbox *, void *);
+// #include "pkgui.h"
import "C"
// Checkbox is a Control that represents a box with a text label at its
@@ -30,7 +27,7 @@ func NewCheckbox(text string) *Checkbox {
c.c = C.uiNewCheckbox(ctext)
freestr(ctext)
- C.uiCheckboxOnToggled(c.c, C.checkboxCallback(C.doCheckboxOnToggled), nil)
+ C.pkguiCheckboxOnToggled(c.c)
c.ControlBase = NewControlBase(c, uintptr(unsafe.Pointer(c.c)))
return c
@@ -57,8 +54,8 @@ func (c *Checkbox) OnToggled(f func(*Checkbox)) {
c.onToggled = f
}
-//export doCheckboxOnToggled
-func doCheckboxOnToggled(cc *C.uiCheckbox, data unsafe.Pointer) {
+//export pkguiDoCheckboxOnToggled
+func pkguiDoCheckboxOnToggled(cc *C.uiCheckbox, data unsafe.Pointer) {
c := ControlFromLibui(uintptr(unsafe.Pointer(cc))).(*Checkbox)
if c.onToggled != nil {
c.onToggled(c)
diff --git a/pkgui.c b/pkgui.c
index 586f5e9..b6871a3 100644
--- a/pkgui.c
+++ b/pkgui.c
@@ -21,3 +21,18 @@ void pkguiOnShouldQuit(void)
{
uiOnShouldQuit(pkguiDoOnShouldQuit, NULL);
}
+
+void pkguiWindowOnClosing(uiWindow *w)
+{
+ uiWindowOnClosing(w, pkguiDoWindowOnClosing, NULL);
+}
+
+void pkguiButtonOnClicked(uiButton *b)
+{
+ uiButtonOnClicked(b, pkguiDoButtonOnClicked, NULL);
+}
+
+void pkguiCheckboxOnToggled(uiCheckbox *c)
+{
+ uiCheckboxOnToggled(c, pkguiDoCheckboxOnToggled, NULL);
+}
diff --git a/pkgui.h b/pkgui.h
index 9aaa394..6a0261b 100644
--- a/pkgui.h
+++ b/pkgui.h
@@ -7,3 +7,12 @@ extern uiInitOptions *pkguiAllocInitOptions(void);
extern void pkguiFreeInitOptions(uiInitOptions *o);
extern void pkguiQueueMain(uintptr_t n);
extern void pkguiOnShouldQuit(void);
+
+// window.go
+extern void pkguiWindowOnClosing(uiWindow *w);
+
+// button.go
+extern void pkguiButtonOnClicked(uiButton *b);
+
+// checkbox.go
+extern void pkguiCheckboxOnToggled(uiCheckbox *c);
diff --git a/BBB_GOFILES/window.go b/window.go
index a40ddd9..d597323 100644
--- a/BBB_GOFILES/window.go
+++ b/window.go
@@ -6,10 +6,7 @@ import (
"unsafe"
)
-// #include "ui.h"
-// extern int doWindowOnClosing(uiWindow *, void *);
-// // see golang/go#19835
-// typedef int (*windowOnClosingCallback)(uiWindow *, void *);
+// #include "pkgui.h"
import "C"
// 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 {
w.w = C.uiNewWindow(ctitle, C.int(width), C.int(height), frombool(hasMenubar))
freestr(ctitle)
- C.uiWindowOnClosing(w.w, C.windowOnClosingCallback(C.doWindowOnClosing), nil)
+ C.pkguiWindowOnClosing(w.w)
w.ControlBase = NewControlBase(w, uintptr(unsafe.Pointer(w.w)))
return w
@@ -79,8 +76,8 @@ func (w *Window) OnClosing(f func(*Window) bool) {
w.onClosing = f
}
-//export doWindowOnClosing
-func doWindowOnClosing(ww *C.uiWindow, data unsafe.Pointer) C.int {
+//export pkguiDoWindowOnClosing
+func pkguiDoWindowOnClosing(ww *C.uiWindow, data unsafe.Pointer) C.int {
w := ControlFromLibui(uintptr(unsafe.Pointer(ww))).(*Window)
if w.onClosing == nil {
return 0