[evolution/rendering-cleanup: 93/97] e-text: Fix color handling



commit d28cd6eb7bd6c128dd3b19e745a4cc2baa609615
Author: Benjamin Otte <otte redhat com>
Date:   Thu Oct 21 10:21:15 2010 +0200

    e-text: Fix color handling
    
    - "color" and "color-gdk" properties aren't readable (Their values would
      be wrong if an alpha channel was set).
    - Use the rgba color when rendering
    - Don't allocate the color in the colormap anymore.

 widgets/text/e-text.c |   37 +++++++++++++------------------------
 widgets/text/e-text.h |    3 ---
 2 files changed, 13 insertions(+), 27 deletions(-)
---
diff --git a/widgets/text/e-text.c b/widgets/text/e-text.c
index 353ad93..cc6e72e 100644
--- a/widgets/text/e-text.c
+++ b/widgets/text/e-text.c
@@ -659,7 +659,6 @@ e_text_set_property (GObject *object,
 	EText *text;
 	GdkColor color = { 0, 0, 0, 0, };
 	GdkColor *pcolor;
-	gboolean color_changed;
 
 	gboolean needs_update = 0;
 	gboolean needs_reflow = 0;
@@ -667,8 +666,6 @@ e_text_set_property (GObject *object,
 	item = GNOME_CANVAS_ITEM (object);
 	text = E_TEXT (object);
 
-	color_changed = FALSE;
-
 	switch (prop_id) {
 	case PROP_MODEL:
 
@@ -821,7 +818,8 @@ e_text_set_property (GObject *object,
 			      (color.green & 0xff00) << 8 |
 			      (color.blue & 0xff00) |
 			      0xff);
-		color_changed = TRUE;
+	        text->needs_redraw = 1;
+	        needs_update = 1;
 		break;
 
 	case PROP_FILL_COLOR_GDK:
@@ -834,7 +832,8 @@ e_text_set_property (GObject *object,
 			      (color.green & 0xff00) << 8 |
 			      (color.blue & 0xff00) |
 			      0xff);
-		color_changed = TRUE;
+	        text->needs_redraw = 1;
+	        needs_update = 1;
 		break;
 
         case PROP_FILL_COLOR_RGBA:
@@ -842,7 +841,8 @@ e_text_set_property (GObject *object,
 		color.red = ((text->rgba >> 24) & 0xff) * 0x101;
 		color.green = ((text->rgba >> 16) & 0xff) * 0x101;
 		color.blue = ((text->rgba >> 8) & 0xff) * 0x101;
-		color_changed = TRUE;
+	        text->needs_redraw = 1;
+	        needs_update = 1;
 		break;
 
 	case PROP_EDITABLE:
@@ -974,17 +974,6 @@ e_text_set_property (GObject *object,
 		return;
 	}
 
-	if (color_changed) {
-               GdkColormap *colormap = gtk_widget_get_colormap (
-			GTK_WIDGET (item->canvas));
-
-	       text->color = color;
-               gdk_rgb_find_color (colormap, &text->color);
-
-	       text->needs_redraw = 1;
-	       needs_update = 1;
-	}
-
 	if (needs_reflow)
 		e_canvas_item_request_reflow (item);
 	if (needs_update)
@@ -1056,10 +1045,6 @@ e_text_get_property (GObject *object,
 		g_value_set_double (value, text->yofs);
 		break;
 
-	case PROP_FILL_COLOR_GDK:
-		g_value_set_boxed (value, &text->color);
-		break;
-
 	case PROP_FILL_COLOR_RGBA:
 		g_value_set_uint (value, text->rgba);
 		break;
@@ -1362,7 +1347,11 @@ e_text_draw (GnomeCanvasItem *item, GdkDrawable *drawable,
 	if (text->draw_background || text->draw_button) {
 		gdk_cairo_set_source_color (cr, &style->fg[state]);
 	} else {
-		gdk_cairo_set_source_color (cr, &text->color);
+                cairo_set_source_rgba (cr,
+                                       ((text->rgba >> 24) & 0xff) / 255.0,
+                                       ((text->rgba >> 16) & 0xff) / 255.0,
+                                       ((text->rgba >>  8) & 0xff) / 255.0,
+                                       ( text->rgba        & 0xff) / 255.0);
 	}
 
 	if (text->draw_borders || text->draw_background) {
@@ -3341,14 +3330,14 @@ e_text_class_init (ETextClass *klass)
 							      "Fill color",
 							      "Fill color",
 							      NULL,
-							      G_PARAM_READWRITE));
+							      G_PARAM_READABLE));
 
 	g_object_class_install_property (gobject_class, PROP_FILL_COLOR_GDK,
 					 g_param_spec_boxed ("fill_color_gdk",
 							     "GDK fill color",
 							     "GDK fill color",
 							     GDK_TYPE_COLOR,
-							     G_PARAM_READWRITE));
+							     G_PARAM_READABLE));
 
 	g_object_class_install_property (gobject_class, PROP_FILL_COLOR_RGBA,
 					 g_param_spec_uint ("fill_color_rgba",
diff --git a/widgets/text/e-text.h b/widgets/text/e-text.h
index db097b2..1de11a4 100644
--- a/widgets/text/e-text.h
+++ b/widgets/text/e-text.h
@@ -121,8 +121,6 @@ struct _EText {
 
 	gdouble xofs, yofs;		/* Text offset distance from anchor position */
 
-	GdkColor color;		/* Fill color */
-
 	gint cx, cy;			/* Top-left canvas coordinates for text */
 	gint text_cx, text_cy;		/* Top-left canvas coordinates for text */
 	gint clip_cx, clip_cy;		/* Top-left canvas coordinates for clip rectangle */
@@ -132,7 +130,6 @@ struct _EText {
 	gint height;			/* Rendered text height in pixels */
 
 	guint32 rgba;			/* RGBA color for text */
-	gdouble affine[6];               /* The item -> canvas affine */
 
 	gchar *ellipsis;                 /* The ellipsis characters.  NULL = "...". */
 	gdouble ellipsis_width;          /* The width of the ellipsis. */



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