summaryrefslogtreecommitdiff
path: root/drawtext.go
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2018-08-16 22:25:47 -0400
committerPietro Gagliardi <[email protected]>2018-08-16 22:25:47 -0400
commit9678e60dd6fa1589ae1d94607c1380121466ce8a (patch)
tree951874a0a1ed38c9c3bae910245741399170115e /drawtext.go
parent9df762b10a5ced48a225a78a47a116fadd2e679c (diff)
More attributes.
Diffstat (limited to 'drawtext.go')
-rw-r--r--drawtext.go72
1 files changed, 38 insertions, 34 deletions
diff --git a/drawtext.go b/drawtext.go
index 874737e..0ec947d 100644
--- a/drawtext.go
+++ b/drawtext.go
@@ -16,9 +16,9 @@ import "C"
// - TextItalic
// - TextStretch
// - TextColor
-// - TextBackgroundColor
-// - TextUnderline
-// - TextUnderlineColor
+// - TextBackground
+// - Underline
+// - UnderlineColor
// - OpenTypeFeatures
//
// For every Unicode codepoint in the AttributedString, at most one
@@ -97,8 +97,6 @@ func (i TextItalic) toLibui() *C.uiAttribute {
return C.uiNewItalicAttribute(C.uiTextItalic(i))
}
-///// TODOTODO
-
// TextStretch is an Attribute that changes the stretch (also called
// "width") of the text it is applied to.
//
@@ -126,41 +124,47 @@ func (s TextStretch) toLibui() *C.uiAttribute {
return C.uiNewStretchAttribute(C.uiTextStretch(s))
}
-/////// TODOTODO
-
-// uiNewColorAttribute() creates a new uiAttribute that changes the
-// color of the text it is applied to. It is an error to specify an invalid
-// color.
-_UI_EXTERN uiAttribute *uiNewColorAttribute(double r, double g, double b, double a);
+// TextColor is an Attribute that changes the color of the text it is
+// applied to.
+type TextColor struct {
+ R float64
+ G float64
+ B float64
+ A float64
+}
-// uiAttributeColor() returns the text color stored in a. It is an
-// error to call this on a uiAttribute that does not hold a text color.
-_UI_EXTERN void uiAttributeColor(const uiAttribute *a, double *r, double *g, double *b, double *alpha);
+func (c TextColor) toLibui() *C.uiAttribute {
+ return C.uiNewColorAttribute(C.double(c.R), C.double(c.G), C.double(c.B), C.double(c.A))
+}
-// uiNewBackgroundAttribute() creates a new uiAttribute that
-// changes the background color of the text it is applied to. It is an
-// error to specify an invalid color.
-_UI_EXTERN uiAttribute *uiNewBackgroundAttribute(double r, double g, double b, double a);
+// TextBackground is an Attribute that changes the background
+// color of the text it is applied to.
+type TextBackground struct {
+ R float64
+ G float64
+ B float64
+ A float64
+}
-// TODO reuse uiAttributeColor() for background colors, or make a new function...
+func (b TextBackground) toLibui() *C.uiAttribute {
+ return C.uiNewBackgroundAttribute(C.double(b.R), C.double(b.G), C.double(b.b), C.double(b.A))
+}
-// uiUnderline specifies a type of underline to use on text.
-_UI_ENUM(uiUnderline) {
- uiUnderlineNone,
- uiUnderlineSingle,
- uiUnderlineDouble,
- uiUnderlineSuggestion, // wavy or dotted underlines used for spelling/grammar checkers
-};
+// Underline is an Attribute that specifies a type of underline to use
+// on text.
+type Underline int
+const (
+ UnderlineNone Underline = iota
+ UnderlineSingle
+ UnderlineDouble
+ UnderlineSuggestion // wavy or dotted underlines used for spelling/grammar checkers
+)
-// uiNewUnderlineAttribute() creates a new uiAttribute that changes
-// the type of underline on the text it is applied to. It is an error to
-// specify an underline type not specified in uiUnderline.
-_UI_EXTERN uiAttribute *uiNewUnderlineAttribute(uiUnderline u);
+func (u Underline) toLibui() *C.uiAttribute {
+ return C.uiNewUnderlineAttribute(C.uiUnderline(u))
+}
-// uiAttributeUnderline() returns the underline type stored in a. It is
-// an error to call this on a uiAttribute that does not hold an underline
-// style.
-_UI_EXTERN uiUnderline uiAttributeUnderline(const uiAttribute *a);
+////////// TODOTODO
// uiUnderlineColor specifies the color of any underline on the text it
// is applied to, regardless of the type of underline. In addition to