22
33package ui
44
5- // #include <stdlib.h>
6- // #include "ui.h"
7- // #include "util.h"
8- // typedef struct pkguiCColor pkguiCColor;
9- // struct pkguiCColor { double *r; double *g; double *b; double *a; };
10- // static inline pkguiCColor pkguiNewCColor(void)
11- // {
12- // pkguiCColor c;
13- //
14- // c.r = (double *) pkguiAlloc(4 * sizeof (double));
15- // c.g = c.r + 1;
16- // c.b = c.g + 1;
17- // c.a = c.b + 1;
18- // return c;
19- // }
20- // static inline void pkguiFreeCColor(pkguiCColor c)
21- // {
22- // free(c.r);
23- // }
24- // static inline uiUnderlineColor *pkguiNewUnderlineColor(void)
25- // {
26- // return (uiUnderlineColor *) pkguiAlloc(sizeof (uiUnderlineColor));
27- // }
28- // static inline void pkguiFreeUnderlineColor(uiUnderlineColor *c)
29- // {
30- // free(c);
31- // }
32- // static inline uiFontDescriptor *pkguiNewFontDescriptor(void)
33- // {
34- // return (uiFontDescriptor *) pkguiAlloc(sizeof (uiFontDescriptor));
35- // }
36- // static inline void pkguiFreeFontDescriptor(uiFontDescriptor *fd)
37- // {
38- // free(fd);
39- // }
40- // static inline uiDrawTextLayoutParams *pkguiNewDrawTextLayoutParams(void)
41- // {
42- // return (uiDrawTextLayoutParams *) pkguiAlloc(sizeof (uiDrawTextLayoutParams));
43- // }
44- // static inline void pkguiFreeDrawTextLayoutParams(uiDrawTextLayoutParams *fd)
45- // {
46- // free(fd);
47- // }
5+ // #include "pkgui.h"
486import "C"
497
508// Attribute stores information about an attribute in an
@@ -317,8 +275,8 @@ func attributeFromLibui(a *C.uiAttribute) Attribute {
317275 case C .uiAttributeTypeStretch :
318276 return TextStretch (C .uiAttributeStretch (a ))
319277 case C .uiAttributeTypeColor :
320- cc := C .pkguiNewCColor ()
321- defer C .pkguiFreeCColor (cc )
278+ cc := C .pkguiAllocColorDoubles ()
279+ defer C .pkguiFreeColorDoubles (cc )
322280 C .uiAttributeColor (a , cc .r , cc .g , cc .b , cc .a )
323281 return TextColor {
324282 R : float64 (* (cc .r )),
@@ -327,8 +285,8 @@ func attributeFromLibui(a *C.uiAttribute) Attribute {
327285 A : float64 (* (cc .a )),
328286 }
329287 case C .uiAttributeTypeBackground :
330- cc := C .pkguiNewCColor ()
331- defer C .pkguiFreeCColor (cc )
288+ cc := C .pkguiAllocColorDoubles ()
289+ defer C .pkguiFreeColorDoubles (cc )
332290 C .uiAttributeColor (a , cc .r , cc .g , cc .b , cc .a )
333291 return TextBackground {
334292 R : float64 (* (cc .r )),
@@ -341,8 +299,8 @@ func attributeFromLibui(a *C.uiAttribute) Attribute {
341299 case C .uiAttributeTypeUnderlineColor :
342300 cu := C .pkguiNewUnderlineColor ()
343301 defer C .pkguiFreeUnderlineColor (cu )
344- cc := C .pkguiNewCColor ()
345- defer C .pkguiFreeCColor (cc )
302+ cc := C .pkguiAllocColorDoubles ()
303+ defer C .pkguiFreeColorDoubles (cc )
346304 C .uiAttributeUnderlineColor (a , cu , cc .r , cc .g , cc .b , cc .a )
347305 if * cu == C .uiUnderlineColorCustom {
348306 return UnderlineColorCustom {
0 commit comments