From 1aa94f627221dff927966c6df8f9e53d917b57df Mon Sep 17 00:00:00 2001 From: "Liam P. White" Date: Fri, 15 Jan 2016 22:17:48 -0500 Subject: Remove buggy and presumptuous usage of SP_ACTIVE_DESKTOP in renderer code; fixes 1526701 Fixed bugs: - https://launchpad.net/bugs/1526701 (bzr r14585.1.1) --- src/display/guideline.cpp | 48 +++++++++++++++++++++-------------------------- src/display/guideline.h | 5 +++-- src/sp-guide.cpp | 5 +++-- 3 files changed, 27 insertions(+), 31 deletions(-) (limited to 'src') diff --git a/src/display/guideline.cpp b/src/display/guideline.cpp index 4b573a586..00fcfea6a 100644 --- a/src/display/guideline.cpp +++ b/src/display/guideline.cpp @@ -17,13 +17,8 @@ #include <2geom/coord.h> #include <2geom/transforms.h> #include "sp-canvas-util.h" -#include "knot.h" #include "guideline.h" #include "display/cairo-utils.h" - -#include "inkscape.h" // for inkscape_active_desktop() -#include "desktop.h" -#include "sp-namedview.h" #include "display/sp-canvas.h" #include "display/sodipodi-ctrl.h" #include "ui/control-manager.h" @@ -37,7 +32,7 @@ static void sp_guideline_render(SPCanvasItem *item, SPCanvasBuf *buf); static double sp_guideline_point(SPCanvasItem *item, Geom::Point p, SPCanvasItem **actual_item); -static gboolean sp_guideline_origin_move(SPKnot *knot, Geom::Point *position, guint state, SPGuideLine *data); +//static gboolean sp_guideline_origin_move(SPKnot *knot, Geom::Point *position, guint state, SPGuideLine *data); static void sp_guideline_drawline (SPCanvasBuf *buf, gint x0, gint y0, gint x1, gint y1, guint32 rgba); G_DEFINE_TYPE(SPGuideLine, sp_guideline, SP_TYPE_CANVAS_ITEM); @@ -72,8 +67,8 @@ static void sp_guideline_destroy(SPCanvasItem *object) SPGuideLine *gl = SP_GUIDELINE(object); - if (gl->origin != NULL && SP_IS_KNOT(gl->origin)) { - knot_unref(gl->origin); + if (gl->origin) { + sp_canvas_item_destroy(SP_CANVAS_ITEM(gl->origin)); } if (gl->label) { @@ -172,28 +167,19 @@ static void sp_guideline_update(SPCanvasItem *item, Geom::Affine const &affine, if ((SP_CANVAS_ITEM_CLASS(sp_guideline_parent_class))->update) { (SP_CANVAS_ITEM_CLASS(sp_guideline_parent_class))->update(item, affine, flags); } - SPDesktop *desktop = SP_ACTIVE_DESKTOP; - if (desktop && item->visible) { - if (!gl->origin) { - gl->origin = new SPKnot(desktop, "No tip yet!! XXX"); - - gl->origin->setAnchor(SP_ANCHOR_CENTER); - gl->origin->setMode(SP_CTRL_MODE_COLOR); - gl->origin->setFill(0xffffff80, 0xffffffff, 0xffffff80); - gl->origin->request_signal.connect(sigc::bind(sigc::ptr_fun(sp_guideline_origin_move), gl)); - } + if (item->visible) { if (gl->locked) { - gl->origin->setStroke(0x0000ff88, 0x0000ff88, 0x0000ff88); - gl->origin->setShape(SP_CTRL_SHAPE_CROSS); - gl->origin->setSize(6); + g_object_set(G_OBJECT(gl->origin), "stroke_color", 0x0000ff88, + "shape", SP_CTRL_SHAPE_CROSS, + "size", 6., NULL); } else { - gl->origin->setStroke(0xff000088, 0xff0000ff, 0xff0000ff); - gl->origin->setShape(SP_CTRL_SHAPE_CIRCLE); - gl->origin->setSize(4); + g_object_set(G_OBJECT(gl->origin), "stroke_color", 0xff000088, + "shape", SP_CTRL_SHAPE_CIRCLE, + "size", 4., NULL); } gl->origin->moveto(gl->point_on_line); - gl->origin->updateCtrl(); + sp_canvas_item_request_update(SP_CANVAS_ITEM(gl->origin)); } gl->affine = affine; @@ -236,17 +222,24 @@ SPCanvasItem *sp_guideline_new(SPCanvasGroup *parent, char* label, Geom::Point p gl->angle = tan( -gl->normal_to_line[Geom::X] / gl->normal_to_line[Geom::Y]); sp_guideline_set_position(gl, point_on_line); + gl->origin = (SPCtrl *)sp_canvas_item_new(parent, SP_TYPE_CTRL, NULL); + g_object_set(G_OBJECT(gl->origin), "anchor", SP_ANCHOR_CENTER, + "mode", SP_CTRL_MODE_COLOR, + "filled", FALSE, + "stroked", TRUE, + "stroke_color", 0x01000000, NULL); + return item; } -static gboolean sp_guideline_origin_move(SPKnot *knot, Geom::Point *position, guint state, SPGuideLine *gl) +/*static gboolean sp_guideline_origin_move(SPKnot *knot, Geom::Point *position, guint state, SPGuideLine *gl) { if(gl->locked) { return true; } sp_guideline_set_position(gl, *position); return false; -} +}*/ void sp_guideline_set_label(SPGuideLine *gl, const char* label) { @@ -281,6 +274,7 @@ void sp_guideline_set_normal(SPGuideLine *gl, Geom::Point normal_to_line) void sp_guideline_set_color(SPGuideLine *gl, unsigned int rgba) { gl->rgba = rgba; + g_object_set(G_OBJECT(gl->origin), "stroke_color", rgba, NULL); sp_canvas_item_request_update(SP_CANVAS_ITEM(gl)); } diff --git a/src/display/guideline.h b/src/display/guideline.h index d58821fc8..44aed88d9 100644 --- a/src/display/guideline.h +++ b/src/display/guideline.h @@ -16,17 +16,18 @@ #include <2geom/point.h> #include "sp-canvas-item.h" -#include "knot.h" #define SP_TYPE_GUIDELINE (sp_guideline_get_type()) #define SP_GUIDELINE(o) (G_TYPE_CHECK_INSTANCE_CAST((o), SP_TYPE_GUIDELINE, SPGuideLine)) #define SP_IS_GUIDELINE(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), SP_TYPE_GUIDELINE)) +struct SPCtrl; + struct SPGuideLine { SPCanvasItem item; Geom::Affine affine; - SPKnot *origin; // unlike 'item', this is only held locally + SPCtrl *origin; // unlike 'item', this is only held locally guint32 rgba; diff --git a/src/sp-guide.cpp b/src/sp-guide.cpp index a57947e01..2bfd0c656 100644 --- a/src/sp-guide.cpp +++ b/src/sp-guide.cpp @@ -25,6 +25,7 @@ #include "display/sp-canvas.h" #include "display/guideline.h" +#include "display/sodipodi-ctrl.h" #include "svg/svg.h" #include "svg/svg-color.h" #include "svg/stringstream.h" @@ -289,7 +290,7 @@ void SPGuide::showSPGuide() for(std::vector::const_iterator it = this->views.begin(); it != this->views.end(); ++it) { sp_canvas_item_show(SP_CANVAS_ITEM(*it)); if((*it)->origin) { - (*it)->origin->show(); + sp_canvas_item_show(SP_CANVAS_ITEM((*it)->origin)); } else { //reposition to same place to show knots sp_guideline_set_position(*it, point_on_line); @@ -317,7 +318,7 @@ void SPGuide::hideSPGuide() for(std::vector::const_iterator it = this->views.begin(); it != this->views.end(); ++it) { sp_canvas_item_hide(SP_CANVAS_ITEM(*it)); if ((*it)->origin) { - (*it)->origin->hide(); + sp_canvas_item_hide(SP_CANVAS_ITEM((*it)->origin)); } } } -- cgit v1.2.3 From b4153318caa10997f2288bba57fce9fab106b0dc Mon Sep 17 00:00:00 2001 From: "Liam P. White" Date: Fri, 15 Jan 2016 22:19:49 -0500 Subject: Dead code cleanup (bzr r14585.1.2) --- src/display/guideline.cpp | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'src') diff --git a/src/display/guideline.cpp b/src/display/guideline.cpp index 00fcfea6a..b3b0869b6 100644 --- a/src/display/guideline.cpp +++ b/src/display/guideline.cpp @@ -32,7 +32,6 @@ static void sp_guideline_render(SPCanvasItem *item, SPCanvasBuf *buf); static double sp_guideline_point(SPCanvasItem *item, Geom::Point p, SPCanvasItem **actual_item); -//static gboolean sp_guideline_origin_move(SPKnot *knot, Geom::Point *position, guint state, SPGuideLine *data); static void sp_guideline_drawline (SPCanvasBuf *buf, gint x0, gint y0, gint x1, gint y1, guint32 rgba); G_DEFINE_TYPE(SPGuideLine, sp_guideline, SP_TYPE_CANVAS_ITEM); @@ -232,15 +231,6 @@ SPCanvasItem *sp_guideline_new(SPCanvasGroup *parent, char* label, Geom::Point p return item; } -/*static gboolean sp_guideline_origin_move(SPKnot *knot, Geom::Point *position, guint state, SPGuideLine *gl) -{ - if(gl->locked) { - return true; - } - sp_guideline_set_position(gl, *position); - return false; -}*/ - void sp_guideline_set_label(SPGuideLine *gl, const char* label) { if (gl->label) { -- cgit v1.2.3 From 99c7ac2b88a264d1415dacb073b5b1a8da4bf85e Mon Sep 17 00:00:00 2001 From: "Liam P. White" Date: Sat, 16 Jan 2016 10:56:00 -0500 Subject: Header cleanup (bzr r14585.1.3) --- src/display/guideline.cpp | 3 --- src/sp-guide.cpp | 1 - 2 files changed, 4 deletions(-) (limited to 'src') diff --git a/src/display/guideline.cpp b/src/display/guideline.cpp index b3b0869b6..d34112046 100644 --- a/src/display/guideline.cpp +++ b/src/display/guideline.cpp @@ -21,9 +21,6 @@ #include "display/cairo-utils.h" #include "display/sp-canvas.h" #include "display/sodipodi-ctrl.h" -#include "ui/control-manager.h" - -using Inkscape::ControlManager; static void sp_guideline_destroy(SPCanvasItem *object); diff --git a/src/sp-guide.cpp b/src/sp-guide.cpp index 2bfd0c656..d1e101fd5 100644 --- a/src/sp-guide.cpp +++ b/src/sp-guide.cpp @@ -25,7 +25,6 @@ #include "display/sp-canvas.h" #include "display/guideline.h" -#include "display/sodipodi-ctrl.h" #include "svg/svg.h" #include "svg/svg-color.h" #include "svg/stringstream.h" -- cgit v1.2.3