aboutsummaryrefslogtreecommitdiffstats
path: root/widgets
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2010-10-17 20:15:07 +0800
committerMatthew Barnes <mbarnes@redhat.com>2010-10-30 01:50:01 +0800
commit8811cd67d3643f5fcdc46ea787ccab8bfbe2cf3c (patch)
treeea7ed366b9288173e7e6cbc8cd3766cfad31f1ba /widgets
parent7fe898ab0f07b516b6472a78ea1583c4cf014233 (diff)
downloadgsoc2013-evolution-8811cd67d3643f5fcdc46ea787ccab8bfbe2cf3c.tar
gsoc2013-evolution-8811cd67d3643f5fcdc46ea787ccab8bfbe2cf3c.tar.gz
gsoc2013-evolution-8811cd67d3643f5fcdc46ea787ccab8bfbe2cf3c.tar.bz2
gsoc2013-evolution-8811cd67d3643f5fcdc46ea787ccab8bfbe2cf3c.tar.lz
gsoc2013-evolution-8811cd67d3643f5fcdc46ea787ccab8bfbe2cf3c.tar.xz
gsoc2013-evolution-8811cd67d3643f5fcdc46ea787ccab8bfbe2cf3c.tar.zst
gsoc2013-evolution-8811cd67d3643f5fcdc46ea787ccab8bfbe2cf3c.zip
gnome-canvas: Convert canvas item transformation matrix to cairo
Also update the GnomeCanvasItem.update vfunc to take a cairo_matrix_t and no longer pass the clip_path (what was it used for anyway?).
Diffstat (limited to 'widgets')
-rw-r--r--widgets/misc/e-calendar-item.c8
-rw-r--r--widgets/misc/e-canvas-utils.c7
-rw-r--r--widgets/misc/e-canvas.c30
-rw-r--r--widgets/table/e-table-field-chooser-item.c34
-rw-r--r--widgets/table/e-table-header-item.c35
-rw-r--r--widgets/table/e-table-item.c63
-rw-r--r--widgets/text/e-reflow.c6
-rw-r--r--widgets/text/e-text.c4
8 files changed, 80 insertions, 107 deletions
diff --git a/widgets/misc/e-calendar-item.c b/widgets/misc/e-calendar-item.c
index 5ca1143c96..40d2c2d247 100644
--- a/widgets/misc/e-calendar-item.c
+++ b/widgets/misc/e-calendar-item.c
@@ -62,8 +62,7 @@ static void e_calendar_item_realize (GnomeCanvasItem *item);
static void e_calendar_item_unrealize (GnomeCanvasItem *item);
static void e_calendar_item_unmap (GnomeCanvasItem *item);
static void e_calendar_item_update (GnomeCanvasItem *item,
- gdouble *affine,
- ArtSVP *clip_path,
+ const cairo_matrix_t *i2c,
gint flags);
static void e_calendar_item_draw (GnomeCanvasItem *item,
GdkDrawable *drawable,
@@ -891,8 +890,7 @@ e_calendar_item_unmap (GnomeCanvasItem *item)
static void
e_calendar_item_update (GnomeCanvasItem *item,
- gdouble *affine,
- ArtSVP *clip_path,
+ const cairo_matrix_t *i2c,
gint flags)
{
GnomeCanvasItemClass *item_class;
@@ -906,7 +904,7 @@ e_calendar_item_update (GnomeCanvasItem *item,
item_class = GNOME_CANVAS_ITEM_CLASS (e_calendar_item_parent_class);
if (item_class->update != NULL)
- item_class->update (item, affine, clip_path, flags);
+ item_class->update (item, i2c, flags);
calitem = E_CALENDAR_ITEM (item);
style = gtk_widget_get_style (GTK_WIDGET (item->canvas));
diff --git a/widgets/misc/e-canvas-utils.c b/widgets/misc/e-canvas-utils.c
index 29dc21d3b3..8189dc1240 100644
--- a/widgets/misc/e-canvas-utils.c
+++ b/widgets/misc/e-canvas-utils.c
@@ -26,14 +26,13 @@
void
e_canvas_item_move_absolute (GnomeCanvasItem *item, gdouble dx, gdouble dy)
{
- gdouble translate[6];
+ cairo_matrix_t translate;
- g_return_if_fail (item != NULL);
g_return_if_fail (GNOME_IS_CANVAS_ITEM (item));
- art_affine_translate (translate, dx, dy);
+ cairo_matrix_init_translate (&translate, dx, dy);
- gnome_canvas_item_affine_absolute (item, translate);
+ gnome_canvas_item_set_matrix (item, &translate);
}
static double
diff --git a/widgets/misc/e-canvas.c b/widgets/misc/e-canvas.c
index 0b24b84cb9..21a7796b15 100644
--- a/widgets/misc/e-canvas.c
+++ b/widgets/misc/e-canvas.c
@@ -165,8 +165,6 @@ canvas_emit_event (GnomeCanvas *canvas,
* should be in the parent's item-relative coordinate system. This routine
* applies the inverse of the item's transform, maintaining the affine
* invariant. */
-#define HACKISH_AFFINE
-
static GnomeCanvasItem *
gnome_canvas_item_invoke_point (GnomeCanvasItem *item,
gdouble x,
@@ -174,25 +172,19 @@ gnome_canvas_item_invoke_point (GnomeCanvasItem *item,
gint cx,
gint cy)
{
-#ifdef HACKISH_AFFINE
- gdouble i2w[6], w2c[6], i2c[6], c2i[6];
- ArtPoint c, i;
-#endif
+ cairo_matrix_t inverse;
-#ifdef HACKISH_AFFINE
- gnome_canvas_item_i2w_affine (item, i2w);
- gnome_canvas_w2c_affine (item->canvas, w2c);
- art_affine_multiply (i2c, i2w, w2c);
- art_affine_invert (c2i, i2c);
- c.x = cx;
- c.y = cy;
- art_affine_point (&i, &c, c2i);
- x = i.x;
- y = i.y;
-#endif
+ /* Calculate x & y in item local coordinates */
+ inverse = item->matrix;
+ if (cairo_matrix_invert (&inverse) != CAIRO_STATUS_SUCCESS)
+ return NULL;
+
+ cairo_matrix_transform_point (&inverse, &x, &y);
+
+ if (GNOME_CANVAS_ITEM_GET_CLASS (item)->point)
+ return GNOME_CANVAS_ITEM_GET_CLASS (item)->point (item, x, y, cx, cy);
- return (* GNOME_CANVAS_ITEM_CLASS (G_OBJECT_GET_CLASS (item))->point) (
- item, x, y, cx, cy);
+ return NULL;
}
/* Re-picks the current item in the canvas, based on the event's coordinates.
diff --git a/widgets/table/e-table-field-chooser-item.c b/widgets/table/e-table-field-chooser-item.c
index 3c28434205..fb8f2babca 100644
--- a/widgets/table/e-table-field-chooser-item.c
+++ b/widgets/table/e-table-field-chooser-item.c
@@ -176,38 +176,34 @@ etfci_reflow (GnomeCanvasItem *item, gint flags)
static void
etfci_update (GnomeCanvasItem *item,
- gdouble *affine,
- ArtSVP *clip_path,
+ const cairo_matrix_t *i2c,
gint flags)
{
ETableFieldChooserItem *etfci = E_TABLE_FIELD_CHOOSER_ITEM (item);
- gdouble i2c[6];
- ArtPoint c1, c2, i1, i2;
+ double x1, y1, x2, y2;
if (GNOME_CANVAS_ITEM_CLASS (etfci_parent_class)->update)
GNOME_CANVAS_ITEM_CLASS (etfci_parent_class)->update (
- item, affine, clip_path, flags);
+ item, i2c, flags);
- i1.x = i1.y = 0;
- i2.x = etfci->width;
- i2.y = etfci->height;
+ x1 = y1 = 0;
+ x2 = etfci->width;
+ y2 = etfci->height;
- gnome_canvas_item_i2c_affine (item, i2c);
- art_affine_point (&c1, &i1, i2c);
- art_affine_point (&c2, &i2, i2c);
+ gnome_canvas_matrix_transform_rect (i2c, &x1, &y1, &x2, &y2);
- if (item->x1 != c1.x ||
- item->y1 != c1.y ||
- item->x2 != c2.x ||
- item->y2 != c2.y)
+ if (item->x1 != x1 ||
+ item->y1 != y1 ||
+ item->x2 != x2 ||
+ item->y2 != y2)
{
gnome_canvas_request_redraw (
item->canvas, item->x1,
item->y1, item->x2, item->y2);
- item->x1 = c1.x;
- item->y1 = c1.y;
- item->x2 = c2.x;
- item->y2 = c2.y;
+ item->x1 = x1;
+ item->y1 = y1;
+ item->x2 = x2;
+ item->y2 = y2;
/* FIXME: Group Child bounds !? */
#if 0
gnome_canvas_group_child_bounds (
diff --git a/widgets/table/e-table-header-item.c b/widgets/table/e-table-header-item.c
index cf4cc9468a..e1c6c57198 100644
--- a/widgets/table/e-table-header-item.c
+++ b/widgets/table/e-table-header-item.c
@@ -184,18 +184,15 @@ e_table_header_item_get_height (ETableHeaderItem *ethi)
static void
ethi_update (GnomeCanvasItem *item,
- gdouble *affine,
- ArtSVP *clip_path,
+ const cairo_matrix_t *i2c,
gint flags)
{
ETableHeaderItem *ethi = E_TABLE_HEADER_ITEM (item);
-
- gdouble i2c[6];
- ArtPoint c1, c2, i1, i2;
+ double x1, y1, x2, y2;
if (GNOME_CANVAS_ITEM_CLASS (ethi_parent_class)->update)
GNOME_CANVAS_ITEM_CLASS (ethi_parent_class)->update (
- item, affine, clip_path, flags);
+ item, i2c, flags);
if (ethi->sort_info)
ethi->group_indent_width =
@@ -208,27 +205,25 @@ ethi_update (GnomeCanvasItem *item,
e_table_header_total_width (ethi->eth) +
ethi->group_indent_width;
- i1.x = i1.y = 0;
- i2.x = ethi->width;
- i2.y = ethi->height;
+ x1 = y1 = 0;
+ x2 = ethi->width;
+ y2 = ethi->height;
- gnome_canvas_item_i2c_affine (item, i2c);
- art_affine_point (&c1, &i1, i2c);
- art_affine_point (&c2, &i2, i2c);
+ gnome_canvas_matrix_transform_rect (i2c, &x1, &y1, &x2, &y2);
- if (item->x1 != c1.x ||
- item->y1 != c1.y ||
- item->x2 != c2.x ||
- item->y2 != c2.y)
+ if (item->x1 != x1 ||
+ item->y1 != y1 ||
+ item->x2 != x2 ||
+ item->y2 != y2)
{
gnome_canvas_request_redraw (
item->canvas,
item->x1, item->y1,
item->x2, item->y2);
- item->x1 = c1.x;
- item->y1 = c1.y;
- item->x2 = c2.x;
- item->y2 = c2.y;
+ item->x1 = x1;
+ item->y1 = y1;
+ item->x2 = x2;
+ item->y2 = y2;
/* FIXME: Group Child bounds !? (FOO BAA) */
#if 0
gnome_canvas_group_child_bounds (GNOME_CANVAS_GROUP (item->parent), item);
diff --git a/widgets/table/e-table-item.c b/widgets/table/e-table-item.c
index b6dc6ad188..5598f45419 100644
--- a/widgets/table/e-table-item.c
+++ b/widgets/table/e-table-item.c
@@ -435,25 +435,18 @@ eti_detach_cell_views (ETableItem *eti)
static void
eti_bounds (GnomeCanvasItem *item, gdouble *x1, gdouble *y1, gdouble *x2, gdouble *y2)
{
- gdouble i2c[6];
- ArtPoint c1, c2, i1, i2;
+ cairo_matrix_t i2c;
ETableItem *eti = E_TABLE_ITEM (item);
/* Wrong BBox's are the source of redraw nightmares */
- gnome_canvas_item_i2c_affine (GNOME_CANVAS_ITEM (eti), i2c);
-
- i1.x = 0;
- i1.y = 0;
- i2.x = eti->width;
- i2.y = eti->height;
- art_affine_point (&c1, &i1, i2c);
- art_affine_point (&c2, &i2, i2c);
+ *x1 = 0;
+ *y1 = 0;
+ *x2 = eti->width;
+ *y2 = eti->height;
- *x1 = c1.x;
- *y1 = c1.y;
- *x2 = c2.x + 1;
- *y2 = c2.y + 1;
+ gnome_canvas_item_i2c_matrix (GNOME_CANVAS_ITEM (eti), &i2c);
+ gnome_canvas_matrix_transform_rect (&i2c, x1, y1, x2, y2);
}
static void
@@ -488,25 +481,25 @@ eti_reflow (GnomeCanvasItem *item, gint flags)
* GnomeCanvasItem::update method
*/
static void
-eti_update (GnomeCanvasItem *item, gdouble *affine, ArtSVP *clip_path, gint flags)
+eti_update (GnomeCanvasItem *item, const cairo_matrix_t *i2c, gint flags)
{
- ArtPoint o1, o2;
ETableItem *eti = E_TABLE_ITEM (item);
+ double x1, x2, y1, y2;
if (GNOME_CANVAS_ITEM_CLASS (eti_parent_class)->update)
- (*GNOME_CANVAS_ITEM_CLASS (eti_parent_class)->update)(item, affine, clip_path, flags);
+ (*GNOME_CANVAS_ITEM_CLASS (eti_parent_class)->update)(item, i2c, flags);
- o1.x = item->x1;
- o1.y = item->y1;
- o2.x = item->x2;
- o2.y = item->y2;
+ x1 = item->x1;
+ y1 = item->y1;
+ x2 = item->x2;
+ y2 = item->y2;
eti_bounds (item, &item->x1, &item->y1, &item->x2, &item->y2);
- if (item->x1 != o1.x ||
- item->y1 != o1.y ||
- item->x2 != o2.x ||
- item->y2 != o2.y) {
- gnome_canvas_request_redraw (item->canvas, o1.x, o1.y, o2.x, o2.y);
+ if (item->x1 != x1 ||
+ item->y1 != y1 ||
+ item->x2 != x1 ||
+ item->y2 != y1) {
+ gnome_canvas_request_redraw (item->canvas, x1, y1, x2, y2);
eti->needs_redraw = 1;
}
@@ -799,18 +792,18 @@ static void
eti_item_region_redraw (ETableItem *eti, gint x0, gint y0, gint x1, gint y1)
{
GnomeCanvasItem *item = GNOME_CANVAS_ITEM (eti);
- ArtDRect rect;
- gdouble i2c[6];
+ double dx1, dy1, dx2, dy2;
+ cairo_matrix_t i2c;
- rect.x0 = x0;
- rect.y0 = y0;
- rect.x1 = x1;
- rect.y1 = y1;
+ dx1 = x0;
+ dy1 = y0;
+ dx2 = x1;
+ dy2 = y1;
- gnome_canvas_item_i2c_affine (item, i2c);
- art_drect_affine_transform (&rect, &rect, i2c);
+ gnome_canvas_item_i2c_matrix (item, &i2c);
+ gnome_canvas_matrix_transform_rect (&i2c, &dx1, &dy1, &dx2, &dy2);
- gnome_canvas_request_redraw (item->canvas, rect.x0, rect.y0, rect.x1, rect.y1);
+ gnome_canvas_request_redraw (item->canvas, floor (dx1), floor (dy1), ceil (dx2), ceil (dy2));
}
/*
diff --git a/widgets/text/e-reflow.c b/widgets/text/e-reflow.c
index 4974fd8f04..88e3a89a8b 100644
--- a/widgets/text/e-reflow.c
+++ b/widgets/text/e-reflow.c
@@ -42,7 +42,7 @@ static void e_reflow_realize (GnomeCanvasItem *item);
static void e_reflow_unrealize (GnomeCanvasItem *item);
static void e_reflow_draw (GnomeCanvasItem *item, GdkDrawable *drawable,
gint x, gint y, gint width, gint height);
-static void e_reflow_update (GnomeCanvasItem *item, gdouble affine[6], ArtSVP *clip_path, gint flags);
+static void e_reflow_update (GnomeCanvasItem *item, const cairo_matrix_t *i2c, gint flags);
static GnomeCanvasItem *e_reflow_point (GnomeCanvasItem *item, gdouble x, gdouble y, gint cx, gint cy);
static void e_reflow_reflow (GnomeCanvasItem *item, gint flags);
static void set_empty (EReflow *reflow);
@@ -1258,7 +1258,7 @@ static void e_reflow_draw (GnomeCanvasItem *item, GdkDrawable *drawable,
}
static void
-e_reflow_update (GnomeCanvasItem *item, gdouble affine[6], ArtSVP *clip_path, gint flags)
+e_reflow_update (GnomeCanvasItem *item, const cairo_matrix_t *i2c, gint flags)
{
EReflow *reflow;
gdouble x0, x1, y0, y1;
@@ -1266,7 +1266,7 @@ e_reflow_update (GnomeCanvasItem *item, gdouble affine[6], ArtSVP *clip_path, gi
reflow = E_REFLOW (item);
if (GNOME_CANVAS_ITEM_CLASS (e_reflow_parent_class)->update)
- GNOME_CANVAS_ITEM_CLASS (e_reflow_parent_class)->update (item, affine, clip_path, flags);
+ GNOME_CANVAS_ITEM_CLASS (e_reflow_parent_class)->update (item, i2c, flags);
x0 = item->x1;
y0 = item->y1;
diff --git a/widgets/text/e-text.c b/widgets/text/e-text.c
index 2f3e567a4a..a21bde7d8b 100644
--- a/widgets/text/e-text.c
+++ b/widgets/text/e-text.c
@@ -1131,7 +1131,7 @@ e_text_reflow (GnomeCanvasItem *item, gint flags)
/* Update handler for the text item */
static void
-e_text_update (GnomeCanvasItem *item, gdouble *affine, ArtSVP *clip_path, gint flags)
+e_text_update (GnomeCanvasItem *item, const cairo_matrix_t *i2c, gint flags)
{
EText *text;
gdouble x1, y1, x2, y2;
@@ -1140,7 +1140,7 @@ e_text_update (GnomeCanvasItem *item, gdouble *affine, ArtSVP *clip_path, gint f
if (GNOME_CANVAS_ITEM_CLASS (e_text_parent_class)->update)
GNOME_CANVAS_ITEM_CLASS (e_text_parent_class)->update (
- item, affine, clip_path, flags);
+ item, i2c, flags);
if ( text->needs_recalc_bounds
|| (flags & GNOME_CANVAS_UPDATE_AFFINE)) {