summaryrefslogtreecommitdiffstats
path: root/src/display
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2012-11-25 19:41:24 +0000
committerTed Gould <ted@gould.cx>2012-11-25 19:41:24 +0000
commit18be0e5e3ab74823043e19dd6ea46c4b6b130e86 (patch)
treea62925ec4473c1a21e1c99d1415f4cccab59b432 /src/display
parentGetting all the filter headers (diff)
parentFix for 1036059 : Keyboard shortcut editor (diff)
downloadinkscape-18be0e5e3ab74823043e19dd6ea46c4b6b130e86.tar.gz
inkscape-18be0e5e3ab74823043e19dd6ea46c4b6b130e86.zip
Update to current trunk
(bzr r11804.1.8)
Diffstat (limited to 'src/display')
-rw-r--r--src/display/canvas-arena.cpp8
-rw-r--r--src/display/canvas-axonomgrid.cpp116
-rw-r--r--src/display/canvas-axonomgrid.h15
-rw-r--r--src/display/canvas-grid.cpp19
-rw-r--r--src/display/canvas-text.cpp4
-rw-r--r--src/display/curve.cpp2
-rw-r--r--src/display/drawing-shape.cpp2
-rw-r--r--src/display/drawing-text.cpp2
-rw-r--r--src/display/guideline.cpp8
-rw-r--r--src/display/nr-filter-composite.cpp9
-rw-r--r--src/display/nr-filter-image.cpp2
-rw-r--r--src/display/nr-filter-merge.cpp2
-rw-r--r--src/display/nr-filter-skeleton.cpp3
-rw-r--r--src/display/nr-svgfonts.cpp67
-rw-r--r--src/display/sodipodi-ctrl.cpp8
-rw-r--r--src/display/sodipodi-ctrlrect.cpp11
-rw-r--r--src/display/sp-canvas.cpp10
-rw-r--r--src/display/sp-ctrlpoint.cpp4
-rw-r--r--src/display/sp-ctrlquadr.cpp4
19 files changed, 155 insertions, 141 deletions
diff --git a/src/display/canvas-arena.cpp b/src/display/canvas-arena.cpp
index 809f14500..8e25c1843 100644
--- a/src/display/canvas-arena.cpp
+++ b/src/display/canvas-arena.cpp
@@ -316,13 +316,17 @@ sp_canvas_arena_event (SPCanvasItem *item, GdkEvent *event)
ret = sp_canvas_arena_send_event (arena, event);
break;
- case GDK_SCROLL:
- if (event->scroll.state & GDK_CONTROL_MASK) {
+ case GDK_SCROLL: {
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ bool wheelzooms = prefs->getBool("/options/wheelzooms/value");
+ bool ctrl = (event->scroll.state & GDK_CONTROL_MASK);
+ if ((ctrl && !wheelzooms) || (!ctrl && wheelzooms)) {
/* Zoom is emitted by the canvas as well, ignore here */
return FALSE;
}
ret = sp_canvas_arena_send_event (arena, event);
break;
+ }
default:
/* Just send event */
diff --git a/src/display/canvas-axonomgrid.cpp b/src/display/canvas-axonomgrid.cpp
index d4e15f475..bfc6f27c4 100644
--- a/src/display/canvas-axonomgrid.cpp
+++ b/src/display/canvas-axonomgrid.cpp
@@ -2,7 +2,7 @@
* Authors:
* Johan Engelen <j.b.c.engelen@alumnus.utwente.nl>
*
- * Copyright (C) 2006-2011 Authors
+ * Copyright (C) 2006-2012 Authors
* Released under GNU GPL, read the file 'COPYING' for more information
*/
@@ -12,47 +12,37 @@
* smaller than 90 degrees (measured from horizontal, 0 degrees being a line extending
* to the right). The x-axis will always have an angle between 0 and 90 degrees.
*/
+
- /*
- * TODO:
- * THIS FILE AND THE HEADER FILE NEED CLEANING UP. PLEASE DO NOT HESISTATE TO DO SO.
- */
-
+#include <gtkmm/box.h>
+#include <gtkmm/label.h>
+#include <gtkmm/table.h>
#include <glibmm/i18n.h>
-#include "ui/widget/registered-widget.h"
#include "display/canvas-axonomgrid.h"
-#include "2geom/line.h"
+
+#include "ui/widget/registered-widget.h"
#include "desktop.h"
-#include "canvas-grid.h"
#include "desktop-handles.h"
#include "display/cairo-utils.h"
#include "display/canvas-grid.h"
#include "display/sp-canvas-util.h"
+#include "display/sp-canvas.h"
#include "document.h"
-#include "helper/units.h"
#include "inkscape.h"
#include "preferences.h"
#include "sp-namedview.h"
#include "sp-object.h"
#include "svg/svg-color.h"
+#include "2geom/line.h"
+#include "2geom/angle.h"
#include "util/mathfns.h"
-#include "xml/node-event-vector.h"
#include "round.h"
-#include "display/sp-canvas.h"
+#include "helper/units.h"
-#include <gtkmm/box.h>
-#include <gtkmm/label.h>
-#include <gtkmm/table.h>
enum Dim3 { X=0, Y, Z };
-#ifndef M_PI
-# define M_PI 3.14159265358979323846
-#endif
-
-static double deg_to_rad(double deg) { return deg*M_PI/180.0;}
-
/**
* This function calls Cairo to render a line on a particular canvas buffer.
* Coordinates are interpreted as SCREENcoordinates
@@ -138,9 +128,9 @@ CanvasAxonomGrid::CanvasAxonomGrid (SPNamedView * nv, Inkscape::XML::Node * in_r
angle_deg[Z] = prefs->getDouble("/options/grids/axonom/angle_z", 30.0);
angle_deg[Y] = 0;
- angle_rad[X] = deg_to_rad(angle_deg[X]);
+ angle_rad[X] = Geom::deg_to_rad(angle_deg[X]);
tan_angle[X] = tan(angle_rad[X]);
- angle_rad[Z] = deg_to_rad(angle_deg[Z]);
+ angle_rad[Z] = Geom::deg_to_rad(angle_deg[Z]);
tan_angle[Z] = tan(angle_rad[Z]);
snapper = new CanvasAxonomGridSnapper(this, &namedview->snap_manager, 0);
@@ -251,17 +241,17 @@ CanvasAxonomGrid::readRepr()
if ( (value = repr->attribute("gridanglex")) ) {
angle_deg[X] = g_ascii_strtod(value, NULL);
- if (angle_deg[X] < 1.0) angle_deg[X] = 1.0;
+ if (angle_deg[X] < 0.) angle_deg[X] = 0.;
if (angle_deg[X] > 89.0) angle_deg[X] = 89.0;
- angle_rad[X] = deg_to_rad(angle_deg[X]);
+ angle_rad[X] = Geom::deg_to_rad(angle_deg[X]);
tan_angle[X] = tan(angle_rad[X]);
}
if ( (value = repr->attribute("gridanglez")) ) {
angle_deg[Z] = g_ascii_strtod(value, NULL);
- if (angle_deg[Z] < 1.0) angle_deg[Z] = 1.0;
+ if (angle_deg[Z] < 0.) angle_deg[Z] = 0.;
if (angle_deg[Z] > 89.0) angle_deg[Z] = 89.0;
- angle_rad[Z] = deg_to_rad(angle_deg[Z]);
+ angle_rad[Z] = Geom::deg_to_rad(angle_deg[Z]);
tan_angle[Z] = tan(angle_rad[Z]);
}
@@ -477,8 +467,8 @@ CanvasAxonomGrid::Update (Geom::Affine const &affine, unsigned int /*flags*/)
spacing_ylines = sw[Geom::X] /(tan_angle[X] + tan_angle[Z]);
lyw = sw[Geom::Y];
- lxw_x = sw[Geom::X] / tan_angle[X];
- lxw_z = sw[Geom::X] / tan_angle[Z];
+ lxw_x = Geom::are_near(tan_angle[X],0.) ? Geom::infinity() : sw[Geom::X] / tan_angle[X];
+ lxw_z = Geom::are_near(tan_angle[Z],0.) ? Geom::infinity() : sw[Geom::X] / tan_angle[Z];
if (empspacing == 0) {
scaled = true;
@@ -526,8 +516,12 @@ CanvasAxonomGrid::Render (SPCanvasBuf *buf)
for (gdouble y = xstart_y_sc; y < buf->rect.bottom(); y += lyw, xlinenum++) {
gint const x0 = buf->rect.left();
gint const y0 = round(y);
- gint const x1 = x0 + round( (buf->rect.bottom() - y) / tan_angle[X] );
- gint const y1 = buf->rect.bottom();
+ gint x1 = x0 + round( (buf->rect.bottom() - y) / tan_angle[X] );
+ gint y1 = buf->rect.bottom();
+ if ( Geom::are_near(tan_angle[X],0.) ) {
+ x1 = buf->rect.right();
+ y1 = y0;
+ }
if (!scaled && (xlinenum % empspacing) != 0) {
sp_caxonomgrid_drawline (buf, x0, y0, x1, y1, color);
@@ -536,18 +530,21 @@ CanvasAxonomGrid::Render (SPCanvasBuf *buf)
}
}
// lines starting from top side
- gdouble const xstart_x_sc = buf->rect.left() + (lxw_x - (xstart_y_sc - buf->rect.top()) / tan_angle[X]) ;
- xlinenum = xlinestart-1;
- for (gdouble x = xstart_x_sc; x < buf->rect.right(); x += lxw_x, xlinenum--) {
- gint const y0 = buf->rect.top();
- gint const y1 = buf->rect.bottom();
- gint const x0 = round(x);
- gint const x1 = x0 + round( (y1 - y0) / tan_angle[X] );
-
- if (!scaled && (xlinenum % empspacing) != 0) {
- sp_caxonomgrid_drawline (buf, x0, y0, x1, y1, color);
- } else {
- sp_caxonomgrid_drawline (buf, x0, y0, x1, y1, _empcolor);
+ if (!Geom::are_near(tan_angle[X],0.))
+ {
+ gdouble const xstart_x_sc = buf->rect.left() + (lxw_x - (xstart_y_sc - buf->rect.top()) / tan_angle[X]) ;
+ xlinenum = xlinestart-1;
+ for (gdouble x = xstart_x_sc; x < buf->rect.right(); x += lxw_x, xlinenum--) {
+ gint const y0 = buf->rect.top();
+ gint const y1 = buf->rect.bottom();
+ gint const x0 = round(x);
+ gint const x1 = x0 + round( (y1 - y0) / tan_angle[X] );
+
+ if (!scaled && (xlinenum % empspacing) != 0) {
+ sp_caxonomgrid_drawline (buf, x0, y0, x1, y1, color);
+ } else {
+ sp_caxonomgrid_drawline (buf, x0, y0, x1, y1, _empcolor);
+ }
}
}
@@ -575,8 +572,12 @@ CanvasAxonomGrid::Render (SPCanvasBuf *buf)
for (gdouble y = zstart_y_sc; y < buf->rect.bottom(); y += lyw, zlinenum++, next_y = y) {
gint const x0 = buf->rect.left();
gint const y0 = round(y);
- gint const x1 = x0 + round( (y - buf->rect.top() ) / tan_angle[Z] );
- gint const y1 = buf->rect.top();
+ gint x1 = x0 + round( (y - buf->rect.top() ) / tan_angle[Z] );
+ gint y1 = buf->rect.top();
+ if ( Geom::are_near(tan_angle[Z],0.) ) {
+ x1 = buf->rect.right();
+ y1 = y0;
+ }
if (!scaled && (zlinenum % empspacing) != 0) {
sp_caxonomgrid_drawline (buf, x0, y0, x1, y1, color);
@@ -585,17 +586,20 @@ CanvasAxonomGrid::Render (SPCanvasBuf *buf)
}
}
// draw lines from bottom-up
- gdouble const zstart_x_sc = buf->rect.left() + (next_y - buf->rect.bottom()) / tan_angle[Z] ;
- for (gdouble x = zstart_x_sc; x < buf->rect.right(); x += lxw_z, zlinenum++) {
- gint const y0 = buf->rect.bottom();
- gint const y1 = buf->rect.top();
- gint const x0 = round(x);
- gint const x1 = x0 + round(buf->rect.height() / tan_angle[Z] );
-
- if (!scaled && (zlinenum % empspacing) != 0) {
- sp_caxonomgrid_drawline (buf, x0, y0, x1, y1, color);
- } else {
- sp_caxonomgrid_drawline (buf, x0, y0, x1, y1, _empcolor);
+ if (!Geom::are_near(tan_angle[Z],0.))
+ {
+ gdouble const zstart_x_sc = buf->rect.left() + (next_y - buf->rect.bottom()) / tan_angle[Z] ;
+ for (gdouble x = zstart_x_sc; x < buf->rect.right(); x += lxw_z, zlinenum++) {
+ gint const y0 = buf->rect.bottom();
+ gint const y1 = buf->rect.top();
+ gint const x0 = round(x);
+ gint const x1 = x0 + round(buf->rect.height() / tan_angle[Z] );
+
+ if (!scaled && (zlinenum % empspacing) != 0) {
+ sp_caxonomgrid_drawline (buf, x0, y0, x1, y1, color);
+ } else {
+ sp_caxonomgrid_drawline (buf, x0, y0, x1, y1, _empcolor);
+ }
}
}
diff --git a/src/display/canvas-axonomgrid.h b/src/display/canvas-axonomgrid.h
index 04919f947..0e24d3f56 100644
--- a/src/display/canvas-axonomgrid.h
+++ b/src/display/canvas-axonomgrid.h
@@ -2,9 +2,12 @@
#define CANVAS_AXONOMGRID_H
/*
- * Copyright (C) 2006-2007 Johan Engelen <johan@shouraizou.nl>
+ * Authors:
+ * Johan Engelen <j.b.c.engelen@alumnus.utwente.nl>
*
- */
+ * Copyright (C) 2006-2012 Authors
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
#include "line-snapper.h"
#include "canvas-grid.h"
@@ -15,7 +18,7 @@ struct SPNamedView;
namespace Inkscape {
namespace XML {
- class Node;
+ class Node;
};
class CanvasAxonomGrid : public CanvasGrid {
@@ -36,6 +39,9 @@ public:
bool scaled; /**< Whether the grid is in scaled mode */
+protected:
+ friend class CanvasAxonomGridSnapper;
+
Geom::Point ow; /**< Transformed origin by the affine for the zoom */
double lyw; /**< Transformed length y by the affine for the zoom */
double lxw_x;
@@ -44,7 +50,6 @@ public:
Geom::Point sw; /**< the scaling factors of the affine transform */
-protected:
virtual Gtk::Widget * newSpecificWidget();
private:
@@ -63,7 +68,7 @@ public:
bool ThisSnapperMightSnap() const;
Geom::Coord getSnapperTolerance() const; //returns the tolerance of the snapper in screen pixels (i.e. independent of zoom)
- bool getSnapperAlwaysSnap() const; //if true, then the snapper will always snap, regardless of its tolerance
+ bool getSnapperAlwaysSnap() const; //if true, then the snapper will always snap, regardless of its tolerance
private:
LineList _getSnapLines(Geom::Point const &p) const;
diff --git a/src/display/canvas-grid.cpp b/src/display/canvas-grid.cpp
index 498958f08..329b621ae 100644
--- a/src/display/canvas-grid.cpp
+++ b/src/display/canvas-grid.cpp
@@ -14,6 +14,9 @@
*/
#include <glibmm/i18n.h>
+#include <gtkmm/box.h>
+#include <gtkmm/label.h>
+#include <gtkmm/table.h>
#include "ui/widget/registered-widget.h"
#include "desktop.h"
@@ -37,10 +40,6 @@
#include "verbs.h"
#include "display/sp-canvas.h"
-#include <gtkmm/box.h>
-#include <gtkmm/label.h>
-#include <gtkmm/table.h>
-
using Inkscape::DocumentUndo;
namespace Inkscape {
@@ -275,9 +274,9 @@ CanvasGrid::NewGrid(SPNamedView * nv, Inkscape::XML::Node * repr, SPDocument * d
switch (gridtype) {
case GRID_RECTANGULAR:
- return (CanvasGrid*) new CanvasXYGrid(nv, repr, doc);
+ return dynamic_cast<CanvasGrid*>(new CanvasXYGrid(nv, repr, doc));
case GRID_AXONOMETRIC:
- return (CanvasGrid*) new CanvasAxonomGrid(nv, repr, doc);
+ return dynamic_cast<CanvasGrid*>(new CanvasAxonomGrid(nv, repr, doc));
}
return NULL;
@@ -351,12 +350,13 @@ CanvasGrid::newWidget()
_rcb_enabled->setSlaveWidgets(slaves);
// set widget values
+ _wr.setUpdating (true);
_rcb_visible->setActive(visible);
if (snapper != NULL) {
_rcb_enabled->setActive(snapper->getEnabled());
_rcb_snap_visible_only->setActive(snapper->getSnapVisibleOnly());
}
-
+ _wr.setUpdating (false);
return dynamic_cast<Gtk::Widget *> (vbox);
}
@@ -366,7 +366,7 @@ CanvasGrid::on_repr_attr_changed(Inkscape::XML::Node *repr, gchar const *key, gc
if (!data)
return;
- ((CanvasGrid*) data)->onReprAttrChanged(repr, key, oldval, newval, is_interactive);
+ (static_cast<CanvasGrid*>(data))->onReprAttrChanged(repr, key, oldval, newval, is_interactive);
}
bool CanvasGrid::isEnabled()
@@ -735,7 +735,6 @@ _wr.setUpdating (true);
new Inkscape::UI::Widget::RegisteredCheckButton( _("_Show dots instead of lines"),
_("If set, displays dots at gridpoints instead of gridlines"),
"dotted", _wr, false, repr, doc) );
-_wr.setUpdating (false);
Gtk::Widget const *const widget_array[] = {
0, _rumg,
@@ -775,6 +774,8 @@ _wr.setUpdating (false);
_rcb_dotted->setActive(render_dotted);
+ _wr.setUpdating (false);
+
_rsu_ox->setProgrammatically = false;
_rsu_oy->setProgrammatically = false;
_rsu_sx->setProgrammatically = false;
diff --git a/src/display/canvas-text.cpp b/src/display/canvas-text.cpp
index ddc946d5d..fe60d9c65 100644
--- a/src/display/canvas-text.cpp
+++ b/src/display/canvas-text.cpp
@@ -58,9 +58,9 @@ sp_canvastext_get_type (void)
static void sp_canvastext_class_init(SPCanvasTextClass *klass)
{
- SPCanvasItemClass *item_class = (SPCanvasItemClass *) klass;
+ SPCanvasItemClass *item_class = SP_CANVAS_ITEM_CLASS(klass);
- parent_class_ct = (SPCanvasItemClass*)g_type_class_peek_parent (klass);
+ parent_class_ct = SP_CANVAS_ITEM_CLASS(g_type_class_peek_parent(klass));
item_class->destroy = sp_canvastext_destroy;
item_class->update = sp_canvastext_update;
diff --git a/src/display/curve.cpp b/src/display/curve.cpp
index 1a788b59a..ae243853e 100644
--- a/src/display/curve.cpp
+++ b/src/display/curve.cpp
@@ -150,7 +150,7 @@ SPCurve::concat(GSList const *list)
SPCurve *new_curve = new SPCurve();
for (GSList const *l = list; l != NULL; l = l->next) {
- SPCurve *c = (SPCurve *) l->data;
+ SPCurve *c = static_cast<SPCurve *>(l->data);
new_curve->_pathv.insert( new_curve->_pathv.end(), c->get_pathvector().begin(), c->get_pathvector().end() );
}
diff --git a/src/display/drawing-shape.cpp b/src/display/drawing-shape.cpp
index 4ca306092..e80f12486 100644
--- a/src/display/drawing-shape.cpp
+++ b/src/display/drawing-shape.cpp
@@ -167,7 +167,7 @@ DrawingShape::_renderItem(DrawingContext &ct, Geom::IntRect const &area, unsigne
{ Inkscape::DrawingContext::Save save(ct);
ct.setSource(rgba);
ct.setLineWidth(0.5);
- ct.setTolerance(1.25);
+ ct.setTolerance(0.5);
ct.stroke();
}
} else {
diff --git a/src/display/drawing-text.cpp b/src/display/drawing-text.cpp
index 7f63c555a..2a6505c67 100644
--- a/src/display/drawing-text.cpp
+++ b/src/display/drawing-text.cpp
@@ -162,7 +162,7 @@ unsigned DrawingText::_renderItem(DrawingContext &ct, Geom::IntRect const &/*are
guint32 rgba = _drawing.outlinecolor;
Inkscape::DrawingContext::Save save(ct);
ct.setSource(rgba);
- ct.setTolerance(1.25); // low quality, but good enough for outline mode
+ ct.setTolerance(0.5); // low quality, but good enough for outline mode
for (ChildrenList::iterator i = _children.begin(); i != _children.end(); ++i) {
DrawingGlyphs *g = dynamic_cast<DrawingGlyphs *>(&*i);
diff --git a/src/display/guideline.cpp b/src/display/guideline.cpp
index d3385978a..f71bc82ef 100644
--- a/src/display/guideline.cpp
+++ b/src/display/guideline.cpp
@@ -66,9 +66,9 @@ GType sp_guideline_get_type()
static void sp_guideline_class_init(SPGuideLineClass *c)
{
- parent_class = (SPCanvasItemClass*) g_type_class_peek_parent(c);
+ parent_class = SP_CANVAS_ITEM_CLASS(g_type_class_peek_parent(c));
- SPCanvasItemClass *item_class = (SPCanvasItemClass *) c;
+ SPCanvasItemClass *item_class = SP_CANVAS_ITEM_CLASS(c);
item_class->destroy = sp_guideline_destroy;
item_class->update = sp_guideline_update;
item_class->render = sp_guideline_render;
@@ -191,8 +191,8 @@ static void sp_guideline_update(SPCanvasItem *item, Geom::Affine const &affine,
{
SPGuideLine *gl = SP_GUIDELINE(item);
- if (((SPCanvasItemClass *) parent_class)->update) {
- ((SPCanvasItemClass *) parent_class)->update(item, affine, flags);
+ if ((SP_CANVAS_ITEM_CLASS(parent_class))->update) {
+ (SP_CANVAS_ITEM_CLASS(parent_class))->update(item, affine, flags);
}
gl->affine = affine;
diff --git a/src/display/nr-filter-composite.cpp b/src/display/nr-filter-composite.cpp
index b25ecdf2c..040424cb3 100644
--- a/src/display/nr-filter-composite.cpp
+++ b/src/display/nr-filter-composite.cpp
@@ -48,10 +48,11 @@ struct ComposeArithmetic {
gint32 go = _k1*ga*gb + _k2*ga + _k3*gb + _k4;
gint32 bo = _k1*ba*bb + _k2*ba + _k3*bb + _k4;
- ao = (pxclamp(ao, 0, 255*255*255) + (255*255/2)) / (255*255);
- ro = (pxclamp(ro, 0, 255*255*255) + (255*255/2)) / (255*255);
- go = (pxclamp(go, 0, 255*255*255) + (255*255/2)) / (255*255);
- bo = (pxclamp(bo, 0, 255*255*255) + (255*255/2)) / (255*255);
+ ao = pxclamp(ao, 0, 255*255*255); // r, g and b are premultiplied, so should be clamped to the alpha channel
+ ro = (pxclamp(ro, 0, ao) + (255*255/2)) / (255*255);
+ go = (pxclamp(go, 0, ao) + (255*255/2)) / (255*255);
+ bo = (pxclamp(bo, 0, ao) + (255*255/2)) / (255*255);
+ ao = (ao + (255*255/2)) / (255*255);
ASSEMBLE_ARGB32(pxout, ao, ro, go, bo)
return pxout;
diff --git a/src/display/nr-filter-image.cpp b/src/display/nr-filter-image.cpp
index e03a56964..bc18cbcc6 100644
--- a/src/display/nr-filter-image.cpp
+++ b/src/display/nr-filter-image.cpp
@@ -99,8 +99,10 @@ void FilterImage::render_cairo(FilterSlot &slot)
Geom::Rect area = *optarea;
Geom::Affine user2pb = slot.get_units().get_matrix_user2pb();
+ /* FIXME: These variables are currently unused. Why were they calculated?
double scaleX = feImageWidth / area.width();
double scaleY = feImageHeight / area.height();
+ */
Geom::Rect sa = slot.get_slot_area();
cairo_surface_t *out = cairo_image_surface_create(CAIRO_FORMAT_ARGB32,
diff --git a/src/display/nr-filter-merge.cpp b/src/display/nr-filter-merge.cpp
index f1fbd7d33..759d7d6d1 100644
--- a/src/display/nr-filter-merge.cpp
+++ b/src/display/nr-filter-merge.cpp
@@ -31,7 +31,7 @@ FilterMerge::~FilterMerge()
void FilterMerge::render_cairo(FilterSlot &slot)
{
- if (_input_image.size() == 0) return;
+ if (_input_image.empty()) return;
// output is RGBA if at least one input is RGBA
bool rgba32 = false;
diff --git a/src/display/nr-filter-skeleton.cpp b/src/display/nr-filter-skeleton.cpp
index 0c455a818..86ab8141e 100644
--- a/src/display/nr-filter-skeleton.cpp
+++ b/src/display/nr-filter-skeleton.cpp
@@ -42,7 +42,8 @@ FilterSkeleton::~FilterSkeleton()
void FilterSkeleton::render_cairo(FilterSlot &slot) {
cairo_surface_t *in = slot.getcairo(_input);
cairo_surface_t *out = ink_cairo_surface_create_identical(in);
- cairo_t *ct = cairo_create(out);
+
+// cairo_t *ct = cairo_create(out);
// cairo_set_source_surface(ct, in, offset[X], offset[Y]);
// cairo_paint(ct);
diff --git a/src/display/nr-svgfonts.cpp b/src/display/nr-svgfonts.cpp
index e095fb9a9..d0c6d2d56 100644
--- a/src/display/nr-svgfonts.cpp
+++ b/src/display/nr-svgfonts.cpp
@@ -43,10 +43,9 @@
static cairo_user_data_key_t key;
static cairo_status_t font_init_cb (cairo_scaled_font_t *scaled_font,
- cairo_t */*cairo*/, cairo_font_extents_t *metrics){
- cairo_font_face_t* face;
- face = cairo_scaled_font_get_font_face(scaled_font);
- SvgFont* instance = (SvgFont*) cairo_font_face_get_user_data(face, &key);
+ cairo_t * /*cairo*/, cairo_font_extents_t *metrics){
+ cairo_font_face_t* face = cairo_scaled_font_get_font_face(scaled_font);
+ SvgFont* instance = static_cast<SvgFont*>(cairo_font_face_get_user_data(face, &key));
return instance->scaled_font_init(scaled_font, metrics);
}
@@ -58,9 +57,8 @@ static cairo_status_t font_text_to_glyphs_cb ( cairo_scaled_font_t *scaled_font
cairo_text_cluster_t **clusters,
int *num_clusters,
cairo_text_cluster_flags_t *flags){
- cairo_font_face_t* face;
- face = cairo_scaled_font_get_font_face(scaled_font);
- SvgFont* instance = (SvgFont*) cairo_font_face_get_user_data(face, &key);
+ cairo_font_face_t* face = cairo_scaled_font_get_font_face(scaled_font);
+ SvgFont* instance = static_cast<SvgFont*>(cairo_font_face_get_user_data(face, &key));
return instance->scaled_font_text_to_glyphs(scaled_font, utf8, utf8_len, glyphs, num_glyphs, clusters, num_clusters, flags);
}
@@ -68,9 +66,8 @@ static cairo_status_t font_render_glyph_cb (cairo_scaled_font_t *scaled_font,
unsigned long glyph,
cairo_t *cr,
cairo_text_extents_t *metrics){
- cairo_font_face_t* face;
- face = cairo_scaled_font_get_font_face(scaled_font);
- SvgFont* instance = (SvgFont*) cairo_font_face_get_user_data(face, &key);
+ cairo_font_face_t* face = cairo_scaled_font_get_font_face(scaled_font);
+ SvgFont* instance = static_cast<SvgFont*>(cairo_font_face_get_user_data(face, &key));
return instance->scaled_font_render_glyph(scaled_font, glyph, cr, metrics);
}
@@ -116,15 +113,15 @@ unsigned int size_of_substring(const char* substring, gchar* str){
}
//TODO: in these macros, verify what happens when using unicode strings.
-#define Match_VKerning_Rule (((SPVkern*)node)->u1->contains(previous_unicode[0])\
- || ((SPVkern*)node)->g1->contains(previous_glyph_name)) &&\
- (((SPVkern*)node)->u2->contains(this->glyphs[i]->unicode[0])\
- || ((SPVkern*)node)->g2->contains(this->glyphs[i]->glyph_name.c_str()))
+#define Match_VKerning_Rule ((SP_VKERN(node))->u1->contains(previous_unicode[0])\
+ || (SP_VKERN(node))->g1->contains(previous_glyph_name)) &&\
+ ((SP_VKERN(node))->u2->contains(this->glyphs[i]->unicode[0])\
+ || (SP_VKERN(node))->g2->contains(this->glyphs[i]->glyph_name.c_str()))
-#define Match_HKerning_Rule (((SPHkern*)node)->u1->contains(previous_unicode[0])\
- || ((SPHkern*)node)->g1->contains(previous_glyph_name)) &&\
- (((SPHkern*)node)->u2->contains(this->glyphs[i]->unicode[0])\
- || ((SPHkern*)node)->g2->contains(this->glyphs[i]->glyph_name.c_str()))
+#define Match_HKerning_Rule ((SP_HKERN(node))->u1->contains(previous_unicode[0])\
+ || (SP_HKERN(node))->g1->contains(previous_glyph_name)) &&\
+ ((SP_HKERN(node))->u2->contains(this->glyphs[i]->unicode[0])\
+ || (SP_HKERN(node))->g2->contains(this->glyphs[i]->glyph_name.c_str()))
cairo_status_t
SvgFont::scaled_font_text_to_glyphs (cairo_scaled_font_t */*scaled_font*/,
@@ -187,14 +184,14 @@ SvgFont::scaled_font_text_to_glyphs (cairo_scaled_font_t */*scaled_font*/,
for(SPObject* node = this->font->children;previous_unicode && node;node=node->next){
//apply glyph kerning if appropriate
if (SP_IS_HKERN(node) && is_horizontal_text && Match_HKerning_Rule ){
- x -= (((SPHkern*)node)->k / 1000.0);//TODO: use here the height of the font
+ x -= ((SP_HKERN(node))->k / 1000.0);//TODO: use here the height of the font
}
if (SP_IS_VKERN(node) && !is_horizontal_text && Match_VKerning_Rule ){
- y -= (((SPVkern*)node)->k / 1000.0);//TODO: use here the "height" of the font
+ y -= ((SP_VKERN(node))->k / 1000.0);//TODO: use here the "height" of the font
}
}
- previous_unicode = (char*) this->glyphs[i]->unicode.c_str();//used for kerning checking
- previous_glyph_name = (char*) this->glyphs[i]->glyph_name.c_str();//used for kerning checking
+ previous_unicode = const_cast<char*>(this->glyphs[i]->unicode.c_str());//used for kerning checking
+ previous_glyph_name = const_cast<char*>(this->glyphs[i]->glyph_name.c_str());//used for kerning checking
(*glyphs)[count].index = i;
(*glyphs)[count].x = x;
(*glyphs)[count++].y = y;
@@ -251,7 +248,7 @@ Geom::PathVector
SvgFont::flip_coordinate_system(SPFont* spfont, Geom::PathVector pathv){
double units_per_em = 1000;
SPObject* obj;
- for (obj = ((SPObject*) spfont)->children; obj; obj=obj->next){
+ for (obj = (SP_OBJECT(spfont))->children; obj; obj=obj->next){
if (SP_IS_FONTFACE(obj)){
//XML Tree being directly used here while it shouldn't be.
sp_repr_get_double(obj->getRepr(), "units_per_em", &units_per_em);
@@ -282,16 +279,16 @@ SvgFont::scaled_font_render_glyph (cairo_scaled_font_t */*scaled_font*/,
SPObject* node;
if (glyph == this->glyphs.size()){
if (!this->missingglyph) return CAIRO_STATUS_SUCCESS;
- node = (SPObject*) this->missingglyph;
+ node = SP_OBJECT(this->missingglyph);
} else {
- node = (SPObject*) this->glyphs[glyph];
+ node = SP_OBJECT(this->glyphs[glyph]);
}
if (!SP_IS_GLYPH(node) && !SP_IS_MISSING_GLYPH(node)) {
return CAIRO_STATUS_SUCCESS; // FIXME: is this the right code to return?
}
- SPFont* spfont = (SPFont*) node->parent;
+ SPFont* spfont = SP_FONT(node->parent);
if (!spfont) {
return CAIRO_STATUS_SUCCESS; // FIXME: is this the right code to return?
}
@@ -300,12 +297,12 @@ SvgFont::scaled_font_render_glyph (cairo_scaled_font_t */*scaled_font*/,
// or using the d attribute of a glyph node.
// pathv stores the path description from the d attribute:
Geom::PathVector pathv;
- if (SP_IS_GLYPH(node) && ((SPGlyph*)node)->d) {
- pathv = sp_svg_read_pathv(((SPGlyph*)node)->d);
+ if (SP_IS_GLYPH(node) && (SP_GLYPH(node))->d) {
+ pathv = sp_svg_read_pathv((SP_GLYPH(node))->d);
pathv = flip_coordinate_system(spfont, pathv);
this->render_glyph_path(cr, &pathv);
- } else if (SP_IS_MISSING_GLYPH(node) && ((SPMissingGlyph*)node)->d) {
- pathv = sp_svg_read_pathv(((SPMissingGlyph*)node)->d);
+ } else if (SP_IS_MISSING_GLYPH(node) && (SP_MISSING_GLYPH(node))->d) {
+ pathv = sp_svg_read_pathv((SP_MISSING_GLYPH(node))->d);
pathv = flip_coordinate_system(spfont, pathv);
this->render_glyph_path(cr, &pathv);
}
@@ -314,7 +311,7 @@ SvgFont::scaled_font_render_glyph (cairo_scaled_font_t */*scaled_font*/,
//render the SVG described on this glyph's child nodes.
for(node = node->children; node; node=node->next){
if (SP_IS_PATH(node)){
- pathv = ((SPShape*)node)->_curve->get_pathvector();
+ pathv = (SP_SHAPE(node))->_curve->get_pathvector();
pathv = flip_coordinate_system(spfont, pathv);
this->render_glyph_path(cr, &pathv);
}
@@ -324,12 +321,12 @@ SvgFont::scaled_font_render_glyph (cairo_scaled_font_t */*scaled_font*/,
if (SP_IS_USE(node)){
SPItem* item = SP_USE(node)->ref->getObject();
if (SP_IS_PATH(item)){
- pathv = ((SPShape*)item)->_curve->get_pathvector();
+ pathv = (SP_SHAPE(item))->_curve->get_pathvector();
pathv = flip_coordinate_system(spfont, pathv);
this->render_glyph_path(cr, &pathv);
}
- glyph_modified_connection = ((SPObject*) item)->connectModified(sigc::mem_fun(*this, &SvgFont::glyph_modified));
+ glyph_modified_connection = (SP_OBJECT(item))->connectModified(sigc::mem_fun(*this, &SvgFont::glyph_modified));
}
}
}
@@ -342,10 +339,10 @@ SvgFont::get_font_face(){
if (!this->userfont) {
for(SPObject* node = this->font->children;node;node=node->next){
if (SP_IS_GLYPH(node)){
- this->glyphs.push_back((SPGlyph*)node);
+ this->glyphs.push_back(SP_GLYPH(node));
}
if (SP_IS_MISSING_GLYPH(node)){
- this->missingglyph=(SPMissingGlyph*)node;
+ this->missingglyph=SP_MISSING_GLYPH(node);
}
}
this->userfont = new UserFont(this);
diff --git a/src/display/sodipodi-ctrl.cpp b/src/display/sodipodi-ctrl.cpp
index e21bdff15..45dc38a37 100644
--- a/src/display/sodipodi-ctrl.cpp
+++ b/src/display/sodipodi-ctrl.cpp
@@ -63,10 +63,10 @@ sp_ctrl_get_type (void)
static void
sp_ctrl_class_init (SPCtrlClass *klass)
{
- SPCanvasItemClass *item_class = (SPCanvasItemClass *) klass;
+ SPCanvasItemClass *item_class = SP_CANVAS_ITEM_CLASS(klass);
GObjectClass *g_object_class = (GObjectClass *) klass;
- parent_class = (SPCanvasItemClass *)g_type_class_peek_parent (klass);
+ parent_class = SP_CANVAS_ITEM_CLASS(g_type_class_peek_parent (klass));
g_object_class->set_property = sp_ctrl_set_property;
g_object_class->get_property = sp_ctrl_get_property;
@@ -287,8 +287,8 @@ sp_ctrl_update (SPCanvasItem *item, Geom::Affine const &affine, unsigned int fla
ctrl = SP_CTRL (item);
- if (((SPCanvasItemClass *) parent_class)->update)
- (* ((SPCanvasItemClass *) parent_class)->update) (item, affine, flags);
+ if ((SP_CANVAS_ITEM_CLASS(parent_class))->update)
+ (* (SP_CANVAS_ITEM_CLASS(parent_class))->update) (item, affine, flags);
sp_canvas_item_reset_bounds (item);
diff --git a/src/display/sodipodi-ctrlrect.cpp b/src/display/sodipodi-ctrlrect.cpp
index b0c997a92..c350e4614 100644
--- a/src/display/sodipodi-ctrlrect.cpp
+++ b/src/display/sodipodi-ctrlrect.cpp
@@ -61,9 +61,9 @@ GType sp_ctrlrect_get_type()
static void sp_ctrlrect_class_init(SPCtrlRectClass *c)
{
- SPCanvasItemClass *item_class = (SPCanvasItemClass *) c;
+ SPCanvasItemClass *item_class = SP_CANVAS_ITEM_CLASS(c);
- parent_class = (SPCanvasItemClass*) g_type_class_peek_parent(c);
+ parent_class = SP_CANVAS_ITEM_CLASS(g_type_class_peek_parent(c));
item_class->destroy = sp_ctrlrect_destroy;
item_class->update = sp_ctrlrect_update;
@@ -119,8 +119,6 @@ void CtrlRect::render(SPCanvasBuf *buf)
using Geom::X;
using Geom::Y;
- static double const dashes[2] = {4.0, 4.0};
-
if (!_area) {
return;
}
@@ -129,6 +127,7 @@ void CtrlRect::render(SPCanvasBuf *buf)
area[X].max() + _shadow_size, area[Y].max() + _shadow_size);
if ( area_w_shadow.intersects(buf->rect) )
{
+ static double const dashes[2] = {4.0, 4.0};
cairo_save(buf->ct);
cairo_translate(buf->ct, -buf->rect.left(), -buf->rect.top());
cairo_set_line_width(buf->ct, 1);
@@ -161,8 +160,8 @@ void CtrlRect::update(Geom::Affine const &affine, unsigned int flags)
using Geom::X;
using Geom::Y;
- if (((SPCanvasItemClass *) parent_class)->update) {
- ((SPCanvasItemClass *) parent_class)->update(this, affine, flags);
+ if ((SP_CANVAS_ITEM_CLASS(parent_class))->update) {
+ (SP_CANVAS_ITEM_CLASS(parent_class))->update(this, affine, flags);
}
sp_canvas_item_reset_bounds(this);
diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp
index 6d4d01e33..536c54609 100644
--- a/src/display/sp-canvas.cpp
+++ b/src/display/sp-canvas.cpp
@@ -1081,7 +1081,7 @@ void SPCanvasGroup::update(SPCanvasItem *item, Geom::Affine const &affine, unsig
Geom::OptRect bounds;
for (GList *list = group->items; list; list = list->next) {
- SPCanvasItem *i = (SPCanvasItem *)list->data;
+ SPCanvasItem *i = SP_CANVAS_ITEM(list->data);
sp_canvas_item_invoke_update (i, affine, flags);
@@ -1118,7 +1118,7 @@ double SPCanvasGroup::point(SPCanvasItem *item, Geom::Point p, SPCanvasItem **ac
double dist = 0.0;
for (GList *list = group->items; list; list = list->next) {
- SPCanvasItem *child = (SPCanvasItem *)list->data;
+ SPCanvasItem *child = SP_CANVAS_ITEM(list->data);
if ((child->x1 <= x2) && (child->y1 <= y2) && (child->x2 >= x1) && (child->y2 >= y1)) {
SPCanvasItem *point_item = NULL; // cater for incomplete item implementations
@@ -1152,7 +1152,7 @@ void SPCanvasGroup::render(SPCanvasItem *item, SPCanvasBuf *buf)
SPCanvasGroup const *group = SP_CANVAS_GROUP(item);
for (GList *list = group->items; list; list = list->next) {
- SPCanvasItem *child = (SPCanvasItem *)list->data;
+ SPCanvasItem *child = SP_CANVAS_ITEM(list->data);
if (child->visible) {
if ((child->x1 < buf->rect.right()) &&
(child->y1 < buf->rect.bottom()) &&
@@ -1171,7 +1171,7 @@ void SPCanvasGroup::viewboxChanged(SPCanvasItem *item, Geom::IntRect const &new_
SPCanvasGroup *group = SP_CANVAS_GROUP(item);
for (GList *list = group->items; list; list = list->next) {
- SPCanvasItem *child = (SPCanvasItem *)list->data;
+ SPCanvasItem *child = SP_CANVAS_ITEM(list->data);
if (child->visible) {
if (SP_CANVAS_ITEM_GET_CLASS(child)->viewbox_changed) {
SP_CANVAS_ITEM_GET_CLASS(child)->viewbox_changed(child, new_area);
@@ -1649,7 +1649,6 @@ int SPCanvasImpl::emitEvent(SPCanvas *canvas, GdkEvent *event)
int SPCanvasImpl::pickCurrentItem(SPCanvas *canvas, GdkEvent *event)
{
int button_down = 0;
- double x, y;
if (!canvas->root) // canvas may have already be destroyed by closing desktop durring interrupted display!
return FALSE;
@@ -1709,6 +1708,7 @@ int SPCanvasImpl::pickCurrentItem(SPCanvas *canvas, GdkEvent *event)
// LeaveNotify means that there is no current item, so we don't look for one
if (canvas->pick_event.type != GDK_LEAVE_NOTIFY) {
// these fields don't have the same offsets in both types of events
+ double x, y;
if (canvas->pick_event.type == GDK_ENTER_NOTIFY) {
x = canvas->pick_event.crossing.x;
diff --git a/src/display/sp-ctrlpoint.cpp b/src/display/sp-ctrlpoint.cpp
index d07e9385b..026cc7589 100644
--- a/src/display/sp-ctrlpoint.cpp
+++ b/src/display/sp-ctrlpoint.cpp
@@ -52,9 +52,9 @@ sp_ctrlpoint_get_type (void)
static void sp_ctrlpoint_class_init(SPCtrlPointClass *klass)
{
- SPCanvasItemClass *item_class = (SPCanvasItemClass *) klass;
+ SPCanvasItemClass *item_class = SP_CANVAS_ITEM_CLASS(klass);
- parent_class = (SPCanvasItemClass*)g_type_class_peek_parent (klass);
+ parent_class = SP_CANVAS_ITEM_CLASS(g_type_class_peek_parent(klass));
item_class->destroy = sp_ctrlpoint_destroy;
item_class->update = sp_ctrlpoint_update;
diff --git a/src/display/sp-ctrlquadr.cpp b/src/display/sp-ctrlquadr.cpp
index ae15d620a..b6a0da109 100644
--- a/src/display/sp-ctrlquadr.cpp
+++ b/src/display/sp-ctrlquadr.cpp
@@ -61,9 +61,9 @@ sp_ctrlquadr_get_type (void)
static void
sp_ctrlquadr_class_init (SPCtrlQuadrClass *klass)
{
- SPCanvasItemClass *item_class = (SPCanvasItemClass *) klass;
+ SPCanvasItemClass *item_class = SP_CANVAS_ITEM_CLASS(klass);
- parent_class = (SPCanvasItemClass*)g_type_class_peek_parent (klass);
+ parent_class = SP_CANVAS_ITEM_CLASS(g_type_class_peek_parent(klass));
item_class->destroy = sp_ctrlquadr_destroy;
item_class->update = sp_ctrlquadr_update;