[goffice] little canvas fixes
- From: Jean Bréfort <jbrefort src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [goffice] little canvas fixes
- Date: Sun, 30 Aug 2009 13:35:30 +0000 (UTC)
commit 2acb6c1948f298a6484f8eae03df40954b80e18f
Author: Jean Brefort <jean brefort normalesup org>
Date: Sun Aug 30 15:35:08 2009 +0200
little canvas fixes
ChangeLog | 8 ++++++++
goffice/canvas/goc-line.c | 2 ++
goffice/canvas/goc-pixbuf.c | 7 +++++--
goffice/utils/go-styled-object.c | 6 ++++++
4 files changed, 21 insertions(+), 2 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index b808167..cc92cd8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2009-08-30 Jean Brefort <jean brefort normalesup org>
+
+ * goffice/canvas/goc-line.c (goc_line_update_bounds): take line cap
+ into account when needed.
+ * goffice/canvas/goc-pixbuf.c (goc_pixbuf_draw): fixed scaling.
+ * goffice/utils/go-styled-object.c
+ (go_styled_object_set_cairo_line): make dashes work.
+
2009-08-27 Jean Brefort <jean brefort normalesup org>
* goffice/canvas/goc-group.c (goc_group_realize),
diff --git a/goffice/canvas/goc-line.c b/goffice/canvas/goc-line.c
index af8e9e7..4ece365 100644
--- a/goffice/canvas/goc-line.c
+++ b/goffice/canvas/goc-line.c
@@ -134,6 +134,8 @@ goc_line_update_bounds (GocItem *item)
double extra_width = style->line.width /2.;
if (extra_width <= 0.)
extra_width = .5;
+ if (style->line.cap == CAIRO_LINE_CAP_SQUARE)
+ extra_width *= 1.5; /* 1.4142 should be enough */
if (line->startx < line->endx) {
item->x0 = line->startx - extra_width;
item->x1 = line->endx + extra_width;
diff --git a/goffice/canvas/goc-pixbuf.c b/goffice/canvas/goc-pixbuf.c
index 4defeb0..922cf27 100644
--- a/goffice/canvas/goc-pixbuf.c
+++ b/goffice/canvas/goc-pixbuf.c
@@ -182,6 +182,7 @@ goc_pixbuf_draw (GocItem const *item, cairo_t *cr)
double height, width;
double scalex = 1., scaley = 1.;
int x;
+ cairo_matrix_t mat;
if (pixbuf->pixbuf == NULL)
return;
@@ -205,8 +206,10 @@ goc_pixbuf_draw (GocItem const *item, cairo_t *cr)
pixbuf->x + pixbuf->width: pixbuf->x;
goc_group_cairo_transform (item->parent, cr, x, (int) pixbuf->y);
cairo_rotate (cr, pixbuf->rotation);
- if (scalex != 1. || scaley != 1.)
- cairo_scale (cr, scalex, scaley);
+ if (scalex != 1. || scaley != 1.) {
+ cairo_matrix_init_scale (&mat, 1. / scalex, 1. /scaley);
+ cairo_pattern_set_matrix (pat, &mat);
+ }
cairo_rectangle (cr, 0., 0., ceil (width), ceil (height));
cairo_set_source (cr, pat);
cairo_pattern_destroy (pat);
diff --git a/goffice/utils/go-styled-object.c b/goffice/utils/go-styled-object.c
index be4b610..f43c04a 100644
--- a/goffice/utils/go-styled-object.c
+++ b/goffice/utils/go-styled-object.c
@@ -157,6 +157,12 @@ go_styled_object_set_cairo_line (GOStyledObject const *so, cairo_t *cr)
cairo_set_line_join (cr, style->line.join);
cairo_set_miter_limit (cr, style->line.miter_limit);
line_dash = go_line_dash_get_sequence (style->line.dash_type, width);
+ if (style->line.cap == CAIRO_LINE_CAP_BUTT && style->line.dash_type != GO_LINE_SOLID) {
+ unsigned i;
+ for (i = 0; i < line_dash->n_dash; i++)
+ if (line_dash->dash[i] == 0.)
+ line_dash->dash[i] = width;
+ }
if (line_dash != NULL)
cairo_set_dash (cr,
line_dash->dash,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]