[gnumeric] Arrows: match goffice changes.



commit 2ea526473dcfcb13ae53e0419b589cca007156a1
Author: Morten Welinder <terra gnome org>
Date:   Wed Feb 11 07:55:59 2015 -0500

    Arrows: match goffice changes.

 configure.ac                   |    2 +-
 src/dialogs/dialog-so-styled.c |    9 ++++---
 src/gnm-so-line.c              |   48 +++++++++------------------------------
 src/gnm-so-line.h              |    2 -
 4 files changed, 17 insertions(+), 44 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 3de46ca..c17f209 100644
--- a/configure.ac
+++ b/configure.ac
@@ -152,7 +152,7 @@ PKG_PROG_PKG_CONFIG(0.18)
 
 dnl *****************************
 libspreadsheet_reqs="
-       libgoffice-${GOFFICE_API_VER}   >= 0.10.14
+       libgoffice-${GOFFICE_API_VER}   >= 0.10.21
        libgsf-1                >= 1.14.24
        libxml-2.0              >= 2.4.12
 "
diff --git a/src/dialogs/dialog-so-styled.c b/src/dialogs/dialog-so-styled.c
index 9ac8de4..94f6ff8 100644
--- a/src/dialogs/dialog-so-styled.c
+++ b/src/dialogs/dialog-so-styled.c
@@ -150,14 +150,15 @@ cb_draw_arrow (GtkWidget *widget, cairo_t *cr, DialogSOStyled *state)
        GOStyle *style;
        guint width = gtk_widget_get_allocated_width (widget);
        guint height = gtk_widget_get_allocated_height (widget);
-       double x = width / 2;
-       double y = height / 2;
 
        g_object_get (state->so, "end-arrow", &arrow, "style", &style, NULL);
 
+       cairo_save (cr);
+       cairo_translate (cr, width / 2, height / 2);
+       /* cairo_scale (cr, 2, 2); */
        cairo_set_source_rgba (cr, GO_COLOR_TO_CAIRO (style->line.color));
-
-       gnm_so_line_draw_arrow (arrow, cr, &x, &y, 0);
+       go_arrow_draw (arrow, cr, NULL, NULL, 0);
+       cairo_restore (cr);
 
        g_object_unref (style);
        g_free (arrow);
diff --git a/src/gnm-so-line.c b/src/gnm-so-line.c
index d987e68..9ad839d 100644
--- a/src/gnm-so-line.c
+++ b/src/gnm-so-line.c
@@ -154,43 +154,17 @@ gnm_so_line_new_view (SheetObject *so, SheetObjectViewContainer *container)
 
 #endif /* GNM_WITH_GTK */
 
-void
-gnm_so_line_draw_arrow (const GOArrow *arrow, cairo_t *cr,
-                       double *x, double *y, double phi)
+static void
+draw_arrow (const GOArrow *arrow, cairo_t *cr,
+           double *x, double *y, double phi)
 {
-       cairo_save (cr);
-
-       switch (arrow->typ) {
-       case GO_ARROW_NONE:
-               return;
-
-       case GO_ARROW_KITE:
-               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);
-
-               /* 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);
-               break;
-
-       case GO_ARROW_OVAL:
-               cairo_translate (cr, *x, *y);
-               cairo_rotate (cr, phi);
-               cairo_scale (cr, arrow->a, arrow->b);
-               cairo_arc (cr, 0., 0., 1., 0., 2 * M_PI);
-               cairo_fill (cr);
-               break;
-       }
+       double dx, dy;
 
+       cairo_save (cr);
+       cairo_translate (cr, *x, *y);
+       go_arrow_draw (arrow, cr, &dx, &dy, phi);
+       *x += dx;
+       *y += dy;
        cairo_restore (cr);
 }
 
@@ -227,8 +201,8 @@ gnm_so_line_draw_cairo (SheetObject const *so, cairo_t *cr,
        cairo_set_source_rgba (cr, GO_COLOR_TO_CAIRO (style->line.color));
 
        phi = atan2 (y2 - y1, x2 - x1) - M_PI_2;
-       gnm_so_line_draw_arrow (&sol->start_arrow, cr, &x1, &y1, phi + M_PI);
-       gnm_so_line_draw_arrow (&sol->end_arrow, cr, &x2, &y2, phi);
+       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);
diff --git a/src/gnm-so-line.h b/src/gnm-so-line.h
index 9bbf670..e4183d9 100644
--- a/src/gnm-so-line.h
+++ b/src/gnm-so-line.h
@@ -10,8 +10,6 @@ G_BEGIN_DECLS
 #define IS_GNM_SO_LINE(o)      (G_TYPE_CHECK_INSTANCE_TYPE((o), GNM_SO_LINE_TYPE))
 GType gnm_so_line_get_type (void);
 
-void gnm_so_line_draw_arrow (const GOArrow *arrow, cairo_t *cr, double *x, double *y, double phi);
-
 G_END_DECLS
 
 #endif /* _GNM_SO_LINE_H_ */


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