[gnumeric] GnmSOLine: print arrows both ways.
- From: Morten Welinder <mortenw src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gnumeric] GnmSOLine: print arrows both ways.
- Date: Wed, 14 Oct 2009 19:54:29 +0000 (UTC)
commit 17c7308d689152b7748bfd293bb2b497b92a82f6
Author: Morten Welinder <terra gnome org>
Date: Wed Oct 14 15:53:45 2009 -0400
GnmSOLine: print arrows both ways.
ChangeLog | 1 +
src/gnm-so-line.c | 61 ++++++++++++++++++++++++++++++++--------------------
2 files changed, 38 insertions(+), 24 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 0ad5b0b..dae084c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,7 @@
* src/gnm-so-line.c: Move GOArrow to goffice.
(gnm_so_line_set_property): Eliminate is-arrow property.
+ (gnm_so_line_draw_cairo): Draw both arrows.
* configure.in (libspreadsheet_reqs): Require goffice 0.7.15 for
GOArrow.
diff --git a/src/gnm-so-line.c b/src/gnm-so-line.c
index 8f7ecd7..1090092 100644
--- a/src/gnm-so-line.c
+++ b/src/gnm-so-line.c
@@ -130,6 +130,7 @@ cb_gnm_so_line_changed (GnmSOLine const *sol,
goc_item_set (item,
"start-arrow", &sol->start_arrow,
"end-arrow", &sol->end_arrow,
+ "style", sol->style,
NULL);
}
@@ -152,14 +153,46 @@ gnm_so_line_new_view (SheetObject *so, SheetObjectViewContainer *container)
#endif /* GNM_WITH_GTK */
static void
+draw_arrow (GOArrow *arrow, cairo_t *cr,
+ double *x, double *y, double phi)
+{
+ switch (arrow->typ) {
+ case GO_ARROW_NONE:
+ return;
+
+ case GO_ARROW_TRIANGLE:
+ cairo_save (cr);
+ cairo_translate (cr, *x, *y);
+ cairo_rotate (cr, phi);
+ cairo_set_line_width (cr, 1.0);
+ cairo_new_path (cr);
+ cairo_move_to (cr, 0.0, 0.0);
+ cairo_line_to (cr, -arrow->c, -arrow->b);
+ cairo_line_to (cr, 0.0, -arrow->a);
+ cairo_line_to (cr, arrow->c, -arrow->b);
+ cairo_close_path (cr);
+ cairo_fill (cr);
+ cairo_restore (cr);
+
+ /* Make the line shorter so that the arrow won't be
+ * on top of a (perhaps quite fat) line. */
+ (*x) += arrow->a * sin (phi);
+ (*y) -= arrow->a * cos (phi);
+ }
+}
+
+static void
gnm_so_line_draw_cairo (SheetObject const *so, cairo_t *cr,
double width, double height)
{
GnmSOLine *sol = GNM_SO_LINE (so);
GOStyle const *style = sol->style;
double x1, y1, x2, y2;
+ double phi;
- if (style->line.color == 0 || style->line.width < 0 || style->line.dash_type == GO_LINE_NONE)
+ if (style->line.color == 0 ||
+ style->line.width < 0 ||
+ style->line.dash_type == GO_LINE_NONE)
return;
switch (so->anchor.base.direction) {
@@ -195,30 +228,10 @@ gnm_so_line_draw_cairo (SheetObject const *so, cairo_t *cr,
}
cairo_set_source_rgba (cr, GO_COLOR_TO_CAIRO (style->line.color));
-
- if (sol->end_arrow.c > 0.) {
- double phi;
-
- phi = atan2 (y2 - y1, x2 - x1) - M_PI_2;
-
- cairo_save (cr);
- cairo_translate (cr, x2, y2);
- cairo_rotate (cr, phi);
- cairo_set_line_width (cr, 1.0);
- cairo_new_path (cr);
- cairo_move_to (cr, 0.0, 0.0);
- cairo_line_to (cr, -sol->end_arrow.c, -sol->end_arrow.b);
- cairo_line_to (cr, 0.0, -sol->end_arrow.a);
- cairo_line_to (cr, sol->end_arrow.c, -sol->end_arrow.b);
- cairo_close_path (cr);
- cairo_fill (cr);
- cairo_restore (cr);
- /* Make the line shorter so that the arrow won't be
- * on top of a (perhaps quite fat) line. */
- x2 += sol->end_arrow.a * sin (phi);
- y2 -= sol->end_arrow.a * cos (phi);
- }
+ phi = atan2 (y2 - y1, x2 - x1) - M_PI_2;
+ draw_arrow (&sol->start_arrow, cr, &x1, &y1, phi + M_PI);
+ draw_arrow (&sol->end_arrow, cr, &x2, &y2, phi);
cairo_move_to (cr, x1, y1);
cairo_line_to (cr, x2, y2);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]