summaryrefslogtreecommitdiff
path: root/gtk/gtktextlayout.c
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.van.berkom@gmail.com>2011-02-09 23:41:39 +0900
committerMatthias Clasen <mclasen@redhat.com>2011-05-06 17:05:10 -0400
commitd399a4acabf9904118ea4481d057bde39bf0ab0e (patch)
treef5e0a553cbf7f0e73f64de6d6439ba5bb6548d50 /gtk/gtktextlayout.c
parent297e7393953264b4c7c67562146a7b89dbaf43b2 (diff)
downloadgtk+-d399a4acabf9904118ea4481d057bde39bf0ab0e.tar.gz
Added GdkRGBA properties to GtkTextTag.
This now allows text view to render text with alpha values in the text foreground and backgrounds, the work is almost complete, currently the error-underline-color is still a GdkColor style property and since we use only GdkRGBA for rendering it needs to be converted and applied, probably a new rgba version of the style property should also be introduced. This commit adds tests/testtextview that must be run from the tests/ directory to show translucent text in action.
Diffstat (limited to 'gtk/gtktextlayout.c')
-rw-r--r--gtk/gtktextlayout.c28
1 files changed, 26 insertions, 2 deletions
diff --git a/gtk/gtktextlayout.c b/gtk/gtktextlayout.c
index 35809873d5..f19ab618d2 100644
--- a/gtk/gtktextlayout.c
+++ b/gtk/gtktextlayout.c
@@ -1424,9 +1424,27 @@ gtk_text_attr_appearance_destroy (PangoAttribute *attr)
{
GtkTextAttrAppearance *appearance_attr = (GtkTextAttrAppearance *)attr;
+ if (appearance_attr->appearance.rgba[0])
+ gdk_rgba_free (appearance_attr->appearance.rgba[0]);
+
+ if (appearance_attr->appearance.rgba[1])
+ gdk_rgba_free (appearance_attr->appearance.rgba[1]);
+
g_slice_free (GtkTextAttrAppearance, appearance_attr);
}
+static gboolean
+rgba_equal (const GdkRGBA *rgba1, const GdkRGBA *rgba2)
+{
+ if (rgba1 && rgba2)
+ return gdk_rgba_equal (rgba1, rgba2);
+
+ if (rgba1 || rgba2)
+ return FALSE;
+
+ return TRUE;
+}
+
static gboolean
gtk_text_attr_appearance_compare (const PangoAttribute *attr1,
const PangoAttribute *attr2)
@@ -1434,8 +1452,8 @@ gtk_text_attr_appearance_compare (const PangoAttribute *attr1,
const GtkTextAppearance *appearance1 = &((const GtkTextAttrAppearance *)attr1)->appearance;
const GtkTextAppearance *appearance2 = &((const GtkTextAttrAppearance *)attr2)->appearance;
- return (gdk_color_equal (&appearance1->fg_color, &appearance2->fg_color) &&
- gdk_color_equal (&appearance1->bg_color, &appearance2->bg_color) &&
+ return (rgba_equal (appearance1->rgba[0], appearance2->rgba[0]) &&
+ rgba_equal (appearance1->rgba[1], appearance2->rgba[1]) &&
appearance1->underline == appearance2->underline &&
appearance1->strikethrough == appearance2->strikethrough &&
appearance1->draw_bg == appearance2->draw_bg);
@@ -1472,6 +1490,12 @@ gtk_text_attr_appearance_new (const GtkTextAppearance *appearance)
result->appearance = *appearance;
+ if (appearance->rgba[0])
+ result->appearance.rgba[0] = gdk_rgba_copy (appearance->rgba[0]);
+
+ if (appearance->rgba[1])
+ result->appearance.rgba[1] = gdk_rgba_copy (appearance->rgba[1]);
+
return (PangoAttribute *)result;
}