@@ -6,28 +6,7 @@ import (
66 "unsafe"
77)
88
9- // #include <stdlib.h>
10- // #include "ui.h"
11- // #include "util.h"
12- // extern void doColorButtonOnChanged(uiColorButton *, void *);
13- // // see golang/go#19835
14- // typedef void (*colorButtonCallback)(uiColorButton *, void *);
15- // typedef struct pkguiCColor pkguiCColor;
16- // struct pkguiCColor { double *r; double *g; double *b; double *a; };
17- // static inline pkguiCColor pkguiNewCColor(void)
18- // {
19- // pkguiCColor c;
20- //
21- // c.r = (double *) pkguiAlloc(4 * sizeof (double));
22- // c.g = c.r + 1;
23- // c.b = c.g + 1;
24- // c.a = c.b + 1;
25- // return c;
26- // }
27- // static inline void pkguiFreeCColor(pkguiCColor c)
28- // {
29- // free(c.r);
30- // }
9+ // #include "pkgui.h"
3110import "C"
3211
3312// ColorButton is a Control that represents a button that the user can
@@ -44,7 +23,7 @@ func NewColorButton() *ColorButton {
4423
4524 b .b = C .uiNewColorButton ()
4625
47- C .uiColorButtonOnChanged (b .b , C . colorButtonCallback ( C . doColorButtonOnChanged ), nil )
26+ C .pkguiColorButtonOnChanged (b .b )
4827
4928 b .ControlBase = NewControlBase (b , uintptr (unsafe .Pointer (b .b )))
5029 return b
@@ -54,8 +33,8 @@ func NewColorButton() *ColorButton {
5433// Colors are not alpha-premultiplied.
5534// TODO rename b or bl
5635func (b * ColorButton ) Color () (r , g , bl , a float64 ) {
57- c := C .pkguiNewCColor ()
58- defer C .pkguiFreeCColor (c )
36+ c := C .pkguiNewColorDoubles ()
37+ defer C .pkguiFreeColorDoubles (c )
5938 C .uiColorButtonColor (b .b , c .r , c .g , c .b , c .a )
6039 return float64 (* (c .r )), float64 (* (c .g )), float64 (* (c .b )), float64 (* (c .a ))
6140}
@@ -74,8 +53,8 @@ func (b *ColorButton) OnChanged(f func(*ColorButton)) {
7453 b .onChanged = f
7554}
7655
77- //export doColorButtonOnChanged
78- func doColorButtonOnChanged (bb * C.uiColorButton , data unsafe.Pointer ) {
56+ //export pkguiDoColorButtonOnChanged
57+ func pkguiDoColorButtonOnChanged (bb * C.uiColorButton , data unsafe.Pointer ) {
7958 b := ControlFromLibui (uintptr (unsafe .Pointer (bb ))).(* ColorButton )
8059 if b .onChanged != nil {
8160 b .onChanged (b )
0 commit comments