[pango/wip/matthiasc/alpha: 1/4] Add attribute types for fg and bg alpha



commit 5dd3585270746fd88b267d06ce20eb9c19cab5e5
Author: Matthias Clasen <mclasen redhat com>
Date:   Tue Aug 11 15:48:25 2015 -0400

    Add attribute types for fg and bg alpha
    
    Add attributes types for foreground and background alpha.

 docs/pango-sections.txt  |    2 +
 pango/pango-attributes.c |   48 ++++++++++++++++++++++++++++++++++++++++++++++
 pango/pango-attributes.h |    8 ++++++-
 3 files changed, 57 insertions(+), 1 deletions(-)
---
diff --git a/docs/pango-sections.txt b/docs/pango-sections.txt
index 0401a15..fa45b24 100644
--- a/docs/pango-sections.txt
+++ b/docs/pango-sections.txt
@@ -381,6 +381,8 @@ pango_attr_fallback_new
 pango_attr_gravity_new
 pango_attr_gravity_hint_new
 pango_attr_font_features_new
+pango_attr_foreground_alpha_new
+pango_attr_background_alpha_new
 PangoColor
 PANGO_TYPE_COLOR
 pango_color_parse
diff --git a/pango/pango-attributes.c b/pango/pango-attributes.c
index da9fefe..b854431 100644
--- a/pango/pango-attributes.c
+++ b/pango/pango-attributes.c
@@ -1127,6 +1127,54 @@ pango_attr_font_features_new (const gchar *features)
   return pango_attr_string_new (&klass, features);
 }
 
+/**
+ * pango_attr_foreground_alpha_new:
+ * @alpha: the alpha value, between 1 and 65536
+ *
+ * Create a new foreground alpha attribute.
+ *
+ * Return value: (transfer full): the new allocated #PangoAttribute,
+ *               which should be freed with pango_attribute_destroy().
+ *
+ * Since: 1.38
+ */
+PangoAttribute *
+pango_attr_foreground_alpha_new (guint16 alpha)
+{
+  static const PangoAttrClass klass = {
+    PANGO_ATTR_FOREGROUND_ALPHA,
+    pango_attr_int_copy,
+    pango_attr_int_destroy,
+    pango_attr_int_equal
+  };
+
+  return pango_attr_int_new (&klass, (int)alpha);
+}
+
+/**
+ * pango_attr_background_alpha_new:
+ * @alpha: the alpha value, between 1 and 65536
+ *
+ * Create a new background alpha attribute.
+ *
+ * Return value: (transfer full): the new allocated #PangoAttribute,
+ *               which should be freed with pango_attribute_destroy().
+ *
+ * Since: 1.38
+ */
+PangoAttribute *
+pango_attr_background_alpha_new (guint16 alpha)
+{
+  static const PangoAttrClass klass = {
+    PANGO_ATTR_BACKGROUND_ALPHA,
+    pango_attr_int_copy,
+    pango_attr_int_destroy,
+    pango_attr_int_equal
+  };
+
+  return pango_attr_int_new (&klass, (int)alpha);
+}
+
 /*
  * Attribute List
  */
diff --git a/pango/pango-attributes.h b/pango/pango-attributes.h
index 3f783e4..1844fcd 100644
--- a/pango/pango-attributes.h
+++ b/pango/pango-attributes.h
@@ -137,6 +137,8 @@ typedef struct _PangoAttrIterator PangoAttrIterator;
  * @PANGO_ATTR_GRAVITY: base text gravity (#PangoAttrInt)
  * @PANGO_ATTR_GRAVITY_HINT: gravity hint (#PangoAttrInt)
  * @PANGO_ATTR_FONT_FEATURES: OpenType font features (#PangoAttrString). Since 1.38
+ * @PANGO_ATTR_FOREGROUND_ALPHA: foreground alpha (#PangoAttrInt). Since 1.38
+ * @PANGO_ATTR_BACKGROUND_ALPHA: background alpha (#PangoAttrInt). Since 1.38
  *
  * The #PangoAttrType
  * distinguishes between different types of attributes. Along with the
@@ -170,7 +172,9 @@ typedef enum
   PANGO_ATTR_ABSOLUTE_SIZE,    /* PangoAttrSize */
   PANGO_ATTR_GRAVITY,          /* PangoAttrInt */
   PANGO_ATTR_GRAVITY_HINT,     /* PangoAttrInt */
-  PANGO_ATTR_FONT_FEATURES     /* PangoAttrString */
+  PANGO_ATTR_FONT_FEATURES,    /* PangoAttrString */
+  PANGO_ATTR_FOREGROUND_ALPHA, /* PangoAttrInt */
+  PANGO_ATTR_BACKGROUND_ALPHA  /* PangoAttrInt */
 } PangoAttrType;
 
 /**
@@ -476,6 +480,8 @@ PangoAttribute *pango_attr_shape_new_with_data (const PangoRectangle       *ink_
 PangoAttribute *pango_attr_gravity_new      (PangoGravity     gravity);
 PangoAttribute *pango_attr_gravity_hint_new (PangoGravityHint hint);
 PangoAttribute *pango_attr_font_features_new (const gchar *features);
+PangoAttribute *pango_attr_foreground_alpha_new (guint16 alpha);
+PangoAttribute *pango_attr_background_alpha_new (guint16 alpha);
 
 GType              pango_attr_list_get_type      (void) G_GNUC_CONST;
 PangoAttrList *    pango_attr_list_new           (void);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]